Merge pull request #881 from drugo72/avr-fixes

Avr fixes
This commit is contained in:
Mariano Alvira 2015-09-28 09:41:21 -05:00
commit ff7129dc53
9 changed files with 48 additions and 32 deletions

View file

@ -139,10 +139,10 @@ ifndef NOAVRSIZE
avr-size -C --mcu=$(MCU) $@
endif
%.hex: %.out
%.hex: %.$(TARGET)
$(OBJCOPY) $^ -j .text -j .data -O ihex $@
%.ihex: %.out
%.ihex: %.$(TARGET)
$(OBJCOPY) $^ -O ihex $@
# Add a namelist to the kernel
@ -160,7 +160,7 @@ endif
#%.hex: %.elf
# $(OBJCOPY) -R .eeprom -R .fuse -R .signature $^ -O ihex $@
%.eep: %.out
%.eep: %.$(TARGET)
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex $^ $@

View file

@ -368,7 +368,7 @@ make_routes(void *p)
j++;
numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length);
numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted);
numprinted += httpd_cgi_sprint_ip6(*uip_ds6_route_nexthop(r), uip_appdata + numprinted);
if(r->state.lifetime < 3600) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime);
} else {

View file

@ -162,6 +162,7 @@ typedef unsigned short uip_stats_t;
#define UIP_CONF_ICMP6 1
#define UIP_CONF_UDP 1
#define UIP_CONF_TCP 1
#define UIP_CONF_BUFFER_SIZE 1300
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
#else

View file

@ -28,7 +28,7 @@ LDFLAGS = $(COMMON)
LDFLAGS += -Wl,-Map=$(PROJECT).map,--cref
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom
HEX_FLASH_FLAGS = -j .text -j .data
HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"

View file

@ -132,11 +132,11 @@ beep(void)
static uint8_t tuneindex=0;
static uint8_t pictures[] PROGMEM = {G4,4, F4,4, AS4,4, C5,2, F5,2, D5,4, C5,2, F5,2, D5,4, AS4,4, C5,4, G4,4, F4,4, 0xff};
static uint8_t axel[] PROGMEM = {FS4,2, NONE,2, A4,3, FS4,2, FS4,1, B4,2, FS4,2, E4,2, FS4,2, NONE,2, CS5,3, FS4,2, FS4,1, D5,2, CS5,2, A4,2, FS4,2, CS5,2, FS5,2, FS4,1, E4,2, E4,1, CS4,2, GS4,2, FS4,6, 0xff};
static uint8_t sandman1[] PROGMEM = {F4,2, G4,2, B4,4, A4,10, B4,2, B4,2, A4,2, B4,12, 0xff};
static uint8_t sandman2[] PROGMEM = {C4,2, E4,2, G4,2, B4,2, A4,2, G4,2, E4,2, C4,2, D4,2, F4,2, A4,2, C5,2, B4,8, 0xff};
static uint8_t furelise[] PROGMEM = {E5,1, DS5,1, E5,1, DS5,1, E5,1, B4,1, D5,1, E5,1, A4,2, NONE,1, C4,1, E4,1, A4,1, B4,2, NONE,1, E4,1, GS4,1, B4,1, C5,2, 0xff};
static const uint8_t pictures[] PROGMEM = {G4,4, F4,4, AS4,4, C5,2, F5,2, D5,4, C5,2, F5,2, D5,4, AS4,4, C5,4, G4,4, F4,4, 0xff};
static const uint8_t axel[] PROGMEM = {FS4,2, NONE,2, A4,3, FS4,2, FS4,1, B4,2, FS4,2, E4,2, FS4,2, NONE,2, CS5,3, FS4,2, FS4,1, D5,2, CS5,2, A4,2, FS4,2, CS5,2, FS5,2, FS4,1, E4,2, E4,1, CS4,2, GS4,2, FS4,6, 0xff};
static const uint8_t sandman1[] PROGMEM = {F4,2, G4,2, B4,4, A4,10, B4,2, B4,2, A4,2, B4,12, 0xff};
static const uint8_t sandman2[] PROGMEM = {C4,2, E4,2, G4,2, B4,2, A4,2, G4,2, E4,2, C4,2, D4,2, F4,2, A4,2, C5,2, B4,8, 0xff};
static const uint8_t furelise[] PROGMEM = {E5,1, DS5,1, E5,1, DS5,1, E5,1, B4,1, D5,1, E5,1, A4,2, NONE,1, C4,1, E4,1, A4,1, B4,2, NONE,1, E4,1, GS4,1, B4,1, C5,2, 0xff};
static volatile uint8_t icnt,tone;
@ -153,7 +153,8 @@ ISR(TIMER0_OVF_vect)
void play_ringtone(void)
{
uint8_t i,*noteptr;
uint8_t i;
const uint8_t *noteptr;
/* What's next on the playlist? */
switch (tuneindex++) {

View file

@ -411,7 +411,7 @@ lcd_num_putdec(int numb, lcd_padding_t padding)
}
/* Convert to BCD */
bcd = itobcd(ABS(numb));
bcd = itobcd(abs(numb));
/* Print */
return lcd_num_print(bcd, (bool)(numb<0), padding);

View file

@ -66,6 +66,27 @@ bool auto_temp=true;
/*---------------------------------------------------------------------------*/
/**
* \brief This will reliably set or clear the JTD bit of the MCUCR register.
*
* \param x True to set the JTD bit disabling JTAG.
*/
#define jtd_set(x)\
{\
__asm__ __volatile__ (\
"in __tmp_reg__,__SREG__" "\n\t"\
"cli" "\n\t"\
"out %1, %0" "\n\t"\
"out __SREG__, __tmp_reg__" "\n\t"\
"out %1, %0" "\n\t"\
: /* no outputs */\
: "r" ((uint8_t)(x ? (1<<JTD) : 0)),\
"M" (_SFR_IO_ADDR(MCUCR))\
: "r0");\
}
/*---------------------------------------------------------------------------*/
/**
* \brief This function will convert decimal to ascii.
*
@ -322,25 +343,18 @@ menu_stop_ping(void)
void
menu_debug_mode(uint8_t *val)
{
uint8_t sreg = SREG;
cli();
if(*val){
/* Disable - Could use inline ASM to meet timing requirements. */
MCUCR |= (1 << JTD);
MCUCR |= (1 << JTD);
/* Needed for timing critical JTD disable. */
if(val){
jtd_set(true);
temp_init();
/* Store setting in EEPROM. */
eeprom_write_byte(EEPROM_DEBUG_ADDR, 0xFF);
}
else{
/* Enable - Could use inline ASM to meet timing requirements. */
MCUCR &= ~(1 << JTD);
MCUCR &= ~(1 << JTD);
jtd_set(false);
/* Store setting in EEPROM. */
eeprom_write_byte(EEPROM_DEBUG_ADDR, 0x01);
}
SREG = sreg;
//SREG = sreg;
}
/*---------------------------------------------------------------------------*/
@ -353,7 +367,7 @@ menu_debug_mode(uint8_t *val)
void
menu_read_temp(uint8_t *val)
{
if(*val){
if(val){
temp_mode = TEMP_UNIT_CELCIUS;
}
else{

View file

@ -225,14 +225,14 @@ const PROGMEM tmenu_item menu_items[18] = {
{menu_text3, 2, 2, 2, 2, 0, 0 },
{menu_text4, 0, 5, 2, 11, 0, 0 },
{menu_text5, 4, 6, 8, 8, 0, 0 },
{menu_text6, 5, 5, 7, 7, (uint8_t*)1, menu_read_temp },
{menu_text7, 5, 5, 6, 6, (uint8_t*)0, menu_read_temp },
{menu_text6, 5, 5, 7, 7, (uint8_t*)0, menu_read_temp },
{menu_text7, 5, 5, 6, 6, (uint8_t*)1, menu_read_temp },
{menu_text8, 4, 9, 5, 5, 0, 0 },
{menu_text9, 8, 14, 10, 10, (uint8_t*)0, menu_prepare_temp },
{menu_text10, 8, 15, 9, 9, (uint8_t*)1, menu_prepare_temp },
{menu_text11, 0, 12, 4, 16, 0, 0 },
{menu_text12, 11, 11, 13, 13, (uint8_t*)1, menu_debug_mode },
{menu_text13, 11, 11, 12, 12, (uint8_t*)0, menu_debug_mode },
{menu_text12, 11, 11, 13, 13, (uint8_t*)0, menu_debug_mode },
{menu_text13, 11, 11, 12, 12, (uint8_t*)1, menu_debug_mode },
{menu_text14, 9, 14, 14, 14, 0, 0 },
{menu_text15, 10, 15, 15, 15, 0, 0 },
// {menu_text16, 0, 16, 11, 17, (uint8_t*)&menu_text16, menu_run_sleep },

View file

@ -58,7 +58,7 @@ static uint16_t temp_table_celcius[];
static uint16_t temp_table_fahrenheit[];
#else /* !DOXYGEN */
/** Celcius temperatures (ADC-value) from -15 to 60 degrees */
static uint16_t temp_table_celcius[] PROGMEM = {
static const uint16_t temp_table_celcius[] PROGMEM = {
923,917,911,904,898,891,883,876,868,860,851,843,834,825,815,
806,796,786,775,765,754,743,732,720,709,697,685,673,661,649,
636,624,611,599,586,574,562,549,537,524,512,500,488,476,464,
@ -68,7 +68,7 @@ static uint16_t temp_table_celcius[] PROGMEM = {
};
/** Fahrenheit temperatures (ADC-value) from 0 to 140 degrees */
static uint16_t temp_table_fahrenheit[] PROGMEM = {
static const uint16_t temp_table_fahrenheit[] PROGMEM = {
938, 935, 932, 929, 926, 923, 920, 916, 913, 909, 906, 902, 898,
894, 891, 887, 882, 878, 874, 870, 865, 861, 856, 851, 847, 842,
837, 832, 827, 822, 816, 811, 806, 800, 795, 789, 783, 778, 772,
@ -99,7 +99,7 @@ bool temp_initialized = false;
*
* \return EOF on error
*/
static int find_temp(int16_t value, uint16_t* array, int count);
static int find_temp(int16_t value, const uint16_t* array, int count);
/*---------------------------------------------------------------------------*/
@ -232,7 +232,7 @@ temp_get(temp_unit_t unit)
* \return EOF on error
*/
static int
find_temp(int16_t value, uint16_t* array, int count)
find_temp(int16_t value, const uint16_t* array, int count)
{
int i = 0;
int table_val = 0;