[tuxdroid-svn] r467 - firmware/tuxcore/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-08-21 16:49:00
|
Author: jaguarondi Date: 2007-08-21 18:48:58 +0200 (Tue, 21 Aug 2007) New Revision: 467 Modified: firmware/tuxcore/trunk/Makefile firmware/tuxcore/trunk/bootloader.c firmware/tuxcore/trunk/fifo.h firmware/tuxcore/trunk/main.c Log: * Chopped a couple of long lines. More to come. Modified: firmware/tuxcore/trunk/Makefile =================================================================== --- firmware/tuxcore/trunk/Makefile 2007-08-21 16:31:40 UTC (rev 466) +++ firmware/tuxcore/trunk/Makefile 2007-08-21 16:48:58 UTC (rev 467) @@ -42,7 +42,8 @@ endif CWARN = -Wall -Wstrict-prototypes CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CFLAGS = $(COMMON) $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) +CFLAGS = $(COMMON) $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) \ + $(CSTANDARD) $(CEXTRA) CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d ## Assembly specific flags @@ -66,7 +67,8 @@ ## Objects that must be built in order to link -OBJECTS = main.o sensors.o motors.o global.o led.o communication.o i2c.o fifo.o ir.o parser.o config.o standalone.o +OBJECTS = main.o sensors.o motors.o global.o led.o communication.o i2c.o \ + fifo.o ir.o parser.o config.o standalone.o ## Objects explicitly added by the user LINKONLYOBJECTS = @@ -117,7 +119,8 @@ ##Link $(TARGET): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) + $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) \ + -o $(TARGET) $(BOOTLOADER): bootloader.o $(CC) $(BL_LDFLAGS) bootloader.o -o $(BOOTLOADER) @@ -159,7 +162,9 @@ ## Clean target .PHONY: clean clean: - -rm -rf $(OBJECTS) svnrev.h tuxcore.elf dep/* tuxcore.hex tuxcore.eep tuxcore.lss tuxcore.map bootloader.o tuxcore_bl.hex tuxcore_bl.lss tuxcore_bl.map tuxcore_bl.elf svnrev.h dep + -rm -rf $(OBJECTS) svnrev.h tuxcore.elf dep/* tuxcore.hex tuxcore.eep \ + tuxcore.lss tuxcore.map bootloader.o tuxcore_bl.hex tuxcore_bl.lss \ + tuxcore_bl.map tuxcore_bl.elf svnrev.h dep ## Other dependencies @@ -168,6 +173,7 @@ ## Generate doxygen documentation .PHONY: doc REVISION = $(shell sed -n "s/\#define SVN_REV\> *//p" svnrev.h) +URL = $(shell sed -n "s/\#define SVN_URL\> *//p" svnrev.h) # if we're in a tag folder, we don't show 'UNRELEASED' ifeq ($(shell sed -n "s/\#define SVN_URL\> *//p" svnrev.h | grep tags),) UNRELEASED = "UNRELEASED " @@ -186,13 +192,18 @@ tuxup $(PROJECT).hex $(PROJECT).eep progisp: $(PROJECT).hex $(PROJECT).eep - $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep + $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e \ + -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep progisp_bl: $(PROJECT).hex $(PROJECT).eep $(PROJECT)_bl.hex - $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep -D -U flash:w:$(PROJECT)_bl.hex + $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e \ + -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep -D \ + -U flash:w:$(PROJECT)_bl.hex progstk: $(PROJECT).hex $(PROJECT).eep - $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep + $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex \ + -U eeprom:w:$(PROJECT).eep progstk_bl: $(PROJECT).hex $(PROJECT).eep $(PROJECT)_bl.hex - $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep -D -U flash:w:$(PROJECT)_bl.hex + $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex \ + -U eeprom:w:$(PROJECT).eep -D -U flash:w:$(PROJECT)_bl.hex Modified: firmware/tuxcore/trunk/bootloader.c =================================================================== --- firmware/tuxcore/trunk/bootloader.c 2007-08-21 16:31:40 UTC (rev 466) +++ firmware/tuxcore/trunk/bootloader.c 2007-08-21 16:48:58 UTC (rev 467) @@ -47,11 +47,12 @@ uint8_t i, twStatus, eeprom_flg = 0; volatile uint16_t _count = 0; - for (_count = 0; _count < 0xFFFF; _count++) ; /* wait for the head button to stabilize */ - if (SW_HD_PIN & SW_HD_MK) /* if head is not pushed at startup */ + /* Wait for the head button to stabilize. */ + for (_count = 0; _count < 0xFFFF; _count++) ; + if (SW_HD_PIN & SW_HD_MK) /* if head is not pushed at startup */ jump_to_application(); - LED_DDR |= LED_L_MK; /* light on left led */ + LED_DDR |= LED_L_MK; /* light on left led */ LED_PT |= LED_L_MK; TWBR = (F_CPU / 100000UL - 16) / 2; /* twi intialisation */ @@ -60,35 +61,36 @@ TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); for (;;) { - i2cWaitForComplete(); /* wait the I2C address */ + i2cWaitForComplete(); /* wait the I2C address */ if ((twStatus = TW_STATUS) != TW_SR_SLA_ACK) while (1) ; TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); - i2cWaitForComplete(); /* wait the high byte of the page address */ + i2cWaitForComplete(); /* wait the high byte of the page address */ if ((twStatus = TW_STATUS) != TW_SR_DATA_ACK) while (1) ; pageAddress.b[1] = TWDR; TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); - i2cWaitForComplete(); /* wait the low byte of the page address */ + i2cWaitForComplete(); /* wait the low byte of the page address */ if ((twStatus = TW_STATUS) != TW_SR_DATA_ACK) while (1) ; pageAddress.b[0] = TWDR; if (pageAddress.w & 0x003F) - while (1) ; /* incorrect page address */ - if (pageAddress.w >= 0x8000) /* eeprom programming */ + while (1) ; /* incorrect page address */ + if (pageAddress.w >= 0x8000) /* eeprom programming */ { - eeprom_flg = 1; /* don't overwrite the bootloader */ - pageAddress.b[1] &= 0x7F; /* remove the eeprom indication bit */ + eeprom_flg = 1; /* don't overwrite the bootloader */ + pageAddress.b[1] &= 0x7F; /* remove the eeprom indication bit */ } else if (pageAddress.w >= 0x1E00) - while (1) ; /* don't overwrite the bootloader */ + while (1) ; /* don't overwrite the bootloader */ else - eeprom_flg = 0; /* flash programming */ + eeprom_flg = 0; /* flash programming */ address = pageAddress.w; TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); - for (i = 0; i < SPM_PAGESIZE; i++) /* fill the complete page with the next data */ + /* Fill the complete page with the next data. */ + for (i = 0; i < SPM_PAGESIZE; i++) { - i2cWaitForComplete(); /* wait data */ + i2cWaitForComplete(); /* wait data */ if ((twStatus = TW_STATUS) == TW_SR_DATA_ACK) { if ((i & 0x01) == 0) @@ -110,17 +112,20 @@ TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); } else - while (1) ; /* error in communication */ + while (1) ; /* error in communication */ } i2cWaitForComplete(); if ((twStatus = TW_STATUS) != TW_SR_STOP) - while (1) ; /* if no stop at this exact position, there's something wrong with the number of bytes sent, we cancel */ - TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); /* clear the interrupt immediately so not to miss the next frame */ + /* If no stop at this exact position, there's something wrong with + * the number of bytes sent, we cancel. */ + while (1) ; + /* Clear the interrupt immediately so not to miss the next frame. */ + TWCR = _BV(TWEA) | _BV(TWEN) | _BV(TWINT); if (!eeprom_flg) { boot_page_erase(pageAddress.w); boot_spm_busy_wait(); - boot_page_write(pageAddress.w); /* Store buffer in flash page */ + boot_page_write(pageAddress.w); /* Store buffer in flash page */ boot_spm_busy_wait(); } } @@ -128,5 +133,6 @@ void i2cWaitForComplete(void) { - while (!(TWCR & _BV(TWINT))) ; /* wait for i2c interface to complete operation */ + /* Wait for i2c interface to complete operation. */ + while (!(TWCR & _BV(TWINT))) ; } Modified: firmware/tuxcore/trunk/fifo.h =================================================================== --- firmware/tuxcore/trunk/fifo.h 2007-08-21 16:31:40 UTC (rev 466) +++ firmware/tuxcore/trunk/fifo.h 2007-08-21 16:48:58 UTC (rev 467) @@ -26,11 +26,13 @@ Usage: - use the following include: \code #include "fifo.h" \endcode - - instanciate a fifo with a given name and size. The size must be a power of 2 and is limited to 128 (2, 4, 8, 16, 32, 64, or 128). + - instanciate a fifo with a given name and size. The size must be a power + of 2 and is limited to 128 (2, 4, 8, 16, 32, 64, or 128). \code FIFO_INSTANCE(fifo_name, FIFO_SIZE); \endcode - - declare a pointer to a fifo type and initialize it with the address of the fifo you just created + - declare a pointer to a fifo type and initialize it with the address of + the fifo you just created \code fifo_t *myFifo = FifoPointer(fifo_name); \endcode Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-08-21 16:31:40 UTC (rev 466) +++ firmware/tuxcore/trunk/main.c 2007-08-21 16:48:58 UTC (rev 467) @@ -220,27 +220,31 @@ /* * Communication: updating status, receiving and sending commands */ - if (updateStatusFlag && !cond_flags.sleep) /* do all stuff that needs to be updated before status are sent; we don't send status when entering sleep mode */ + /* We don't send status when entering sleep mode. */ + if (updateStatusFlag && !cond_flags.sleep) { updateStatusFlag = 0; updateStatus(); /* add sensors states to the status queue */ getLight(); /* light measurement */ } - //if (commandProcessFlag) /* XXX check if it's quick enough with the if */ + //if (commandProcessFlag) /* XXX check if it's quick enough with the if + //*/ // { // commandProcessFlag = 0; - sendCommands(); /* send status and audio commands through i2c */ + sendCommands(); /* send status and audio commands through i2c */ // } - if (commandBufIdx) /* do all stuff that needs to be updated each time a commnand or status has been received */ + if (commandBufIdx) /* do all stuff that needs to be updated each time a + commnand or status has been received */ { - parse_received_commands(); /* parse and execute received commands */ + parse_received_commands(); /* parse and execute received commands */ } standalone_behavior(); /* standalone behavior manager */ /* Entering sleep mode. */ - if ((cond_flags.sleep == COND_SLEEP) && !event_timer) /* wait for standalone actions to be done */ + /* Wait for standalone actions to be done. */ + if ((cond_flags.sleep == COND_SLEEP) && !event_timer) sleep(); /* @@ -300,7 +304,8 @@ PCMSK2 = PSW_EYES_C_MK; PCICR |= _BV(PCIE2); - /* Enable 'INT1 interrupt' for spin position switch in falling edge mode and 'INT0 interrupt' for IR receiver in falling edge mode */ + /* Enable 'INT1 interrupt' for spin position switch in falling edge mode + * and 'INT0 interrupt' for IR receiver in falling edge mode */ EICRA = _BV(ISC11); // | _BV(ISC01); EIMSK = _BV(INT1); // | _BV(INT0); @@ -308,7 +313,7 @@ * Single conversion mode */ ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); - ADMUX = 0x06; /* ADC6 selected XXX change this when adding ADC7 too */ + ADMUX = 0x06; /* ADC6 selected XXX change this when adding ADC7 too */ ADCSRA |= _BV(ADIE) | _BV(ADSC); /* set ADC interrupt and start it */ /* set external I/O as pull-up */ |