From b641230fc857f1fdd7a76b81adfd4600060013c3 Mon Sep 17 00:00:00 2001 From: Bart Van Der Meerssche Date: Sun, 16 Jan 2011 23:25:11 +0100 Subject: [PATCH] [avr] add {hw,sw} {major,minor} sensor board versioning --- mote/v2/avr/ctrl.c | 31 ++++++++++++++++++++++++------- mote/v2/avr/main.c | 5 +++-- mote/v2/avr/main.h | 7 +++++++ mote/v2/avr/makefile | 12 ++++++++++++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/mote/v2/avr/ctrl.c b/mote/v2/avr/ctrl.c index 1981e42..561d385 100644 --- a/mote/v2/avr/ctrl.c +++ b/mote/v2/avr/ctrl.c @@ -34,8 +34,8 @@ cBuffer ctrlTxBuffer; // ctrl transmit buffer static char ctrlRxData[CTRL_RX_BUFFER_SIZE]; static char ctrlTxData[CTRL_TX_BUFFER_SIZE]; -extern uint16_t EEMEM EEPROM_version; -extern uint16_t version; +extern struct version_struct EEMEM EEPROM_version; +extern struct version_struct version; extern struct event_struct EEMEM EEPROM_event; extern struct event_struct event; @@ -257,8 +257,14 @@ void ctrlCmdGet(uint8_t cmd) uint32_t tmp32, tmp32_bis; switch (cmd) { - case 'v': - ctrlWriteShortToTxBuffer(version); + case 'h': + ctrlWriteShortToTxBuffer(version.hw_major); + ctrlWriteCharToTxBuffer(version.hw_minor); + break; + + case 's': + ctrlWriteCharToTxBuffer(version.sw_major); + ctrlWriteCharToTxBuffer(version.sw_minor); break; case 'p': @@ -315,19 +321,30 @@ void ctrlCmdGet(uint8_t cmd) void ctrlCmdSet(uint8_t cmd) { - uint8_t i = 0, tmp8 = 0; + uint8_t i = 0, tmp8 = 0, tmp8_bis = 0; uint16_t tmp16 = 0; uint32_t tmp32 = 0; switch (cmd) { - case 'v': + case 'h': ctrlReadShortFromRxBuffer(&tmp16); + ctrlReadCharFromRxBuffer(&tmp8); cli(); - version = tmp16; + version.hw_major = tmp16; + version.hw_minor = tmp8; sei(); break; + case 's': + ctrlReadCharFromRxBuffer(&tmp8); + ctrlReadCharFromRxBuffer(&tmp8_bis); + + cli(); + version.sw_major = tmp8; + version.sw_minor = tmp8_bis; + sei(); + case 'p': for (i = 0 ; i < MAX_SENSORS; i++) { ctrlReadCharFromRxBuffer(&tmp8); diff --git a/mote/v2/avr/main.c b/mote/v2/avr/main.c index e0b5e2b..586ee9f 100644 --- a/mote/v2/avr/main.c +++ b/mote/v2/avr/main.c @@ -40,8 +40,9 @@ uint8_t spi_high_hex; uint8_t EEMEM first_EEPROM_byte_not_used_to_protect_from_brownout_corruption = 0xbe; -uint8_t EEMEM EEPROM_version[2] = {2, 1}; -uint8_t version[2]; +struct version_struct EEMEM EEPROM_version = + {HW_VERSION_MAJOR, HW_VERSION_MINOR, SW_VERSION_MAJOR, SW_VERSION_MINOR}; +struct version_struct version; struct event_struct EEMEM EEPROM_event = {0, 0}; struct event_struct event; diff --git a/mote/v2/avr/main.h b/mote/v2/avr/main.h index abd4151..ad21d1e 100644 --- a/mote/v2/avr/main.h +++ b/mote/v2/avr/main.h @@ -1,3 +1,10 @@ +struct version_struct { + uint16_t hw_major; + uint8_t hw_minor; + uint8_t sw_major; + uint8_t sw_minor; +}; + #define SPI_NO_OP_1 1 #define SPI_NO_OP_2 2 #define SPI_START_TX 4 diff --git a/mote/v2/avr/makefile b/mote/v2/avr/makefile index eaa277f..b56856a 100644 --- a/mote/v2/avr/makefile +++ b/mote/v2/avr/makefile @@ -49,6 +49,11 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- +# Sensor board versioning: +HW_VERSION_MAJOR = 2 +HW_VERSION_MINOR = 0 +SW_VERSION_MAJOR = 1 +SW_VERSION_MINOR = 0 # MCU name MCU = atmega168 @@ -125,6 +130,13 @@ CDEFS += -Winline # Inline all 'simple-enough' functions (seems to be done by default in -Os) CDEFS += -finline-functions +# Sensor board ID +CDEFS += -DBOARD_ID=$(BOARD_ID) + +# Sensor board hw/sw major/minor version +CDEFS += -DHW_VERSION_MAJOR=$(HW_VERSION_MAJOR) -DHW_VERSION_MINOR=$(HW_VERSION_MINOR) +CDEFS += -DSW_VERSION_MAJOR=$(SW_VERSION_MAJOR) -DSW_VERSION_MINOR=$(SW_VERSION_MINOR) + # uncomment and adapt these line if you want different UART library buffer size CDEFS += -DUART_RX_BUFFER_SIZE=64 CDEFS += -DUART_TX_BUFFER_SIZE=64