Skip to content

Commit

Permalink
Merge pull request #881 from drugo72/avr-fixes
Browse files Browse the repository at this point in the history
Avr fixes
  • Loading branch information
malvira committed Sep 28, 2015
2 parents d65b3e1 + e51783a commit ff7129d
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 32 deletions.
6 changes: 3 additions & 3 deletions cpu/avr/Makefile.avr
Expand Up @@ -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
Expand All @@ -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 $^ $@

Expand Down
2 changes: 1 addition & 1 deletion platform/avr-raven/apps/raven-webserver/httpd-cgi.c
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions platform/avr-raven/contiki-conf.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion platform/avr-ravenlcd/Makefile
Expand Up @@ -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"
Expand Down
13 changes: 7 additions & 6 deletions platform/avr-ravenlcd/beep.c
Expand Up @@ -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;

Expand All @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion platform/avr-ravenlcd/lcd.c
Expand Up @@ -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);
Expand Down
38 changes: 26 additions & 12 deletions platform/avr-ravenlcd/menu.c
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}

/*---------------------------------------------------------------------------*/
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions platform/avr-ravenlcd/raven3290.c
Expand Up @@ -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 },
Expand Down
8 changes: 4 additions & 4 deletions platform/avr-ravenlcd/temp.c
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);

/*---------------------------------------------------------------------------*/

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ff7129d

Please sign in to comment.