avr: add version field and s/gv [set/get version] command
This commit is contained in:
parent
21984e237a
commit
b0fd16364e
|
@ -33,6 +33,9 @@ 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 volatile struct event_struct EEMEM EEPROM_event;
|
||||
extern volatile struct event_struct event;
|
||||
|
||||
|
@ -225,7 +228,7 @@ void ctrlDecode(void)
|
|||
break;
|
||||
|
||||
default:
|
||||
ctrlAddToTxBuffer('e');
|
||||
ctrlAddToTxBuffer('z');
|
||||
}
|
||||
|
||||
ctrlAddToTxBuffer('.');
|
||||
|
@ -240,6 +243,10 @@ void ctrlCmdGet(uint8_t cmd)
|
|||
uint32_t tmp32, tmp32_bis;
|
||||
|
||||
switch (cmd) {
|
||||
case 'v':
|
||||
ctrlWriteShortToTxBuffer(version);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
for (i = 0 ; i < MAX_SENSORS; i++) {
|
||||
ctrlWriteCharToTxBuffer(phy_to_log[i]);
|
||||
|
@ -288,7 +295,7 @@ void ctrlCmdGet(uint8_t cmd)
|
|||
break;
|
||||
|
||||
default:
|
||||
ctrlAddToTxBuffer('e');
|
||||
ctrlAddToTxBuffer('z');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,6 +306,14 @@ void ctrlCmdSet(uint8_t cmd)
|
|||
uint32_t tmp32;
|
||||
|
||||
switch (cmd) {
|
||||
case 'v':
|
||||
ctrlReadShortFromRxBuffer(&tmp16);
|
||||
|
||||
cli();
|
||||
version = tmp16;
|
||||
sei();
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
for (i = 0 ; i < MAX_SENSORS; i++) {
|
||||
ctrlReadCharFromRxBuffer(&tmp8);
|
||||
|
@ -344,13 +359,14 @@ void ctrlCmdSet(uint8_t cmd)
|
|||
break;
|
||||
|
||||
default:
|
||||
ctrlAddToTxBuffer('e');
|
||||
ctrlAddToTxBuffer('z');
|
||||
}
|
||||
}
|
||||
|
||||
void ctrlCmdCommit(void)
|
||||
{
|
||||
cli();
|
||||
eeprom_write_block((const void*)&version, (void*)&EEPROM_version, sizeof(version));
|
||||
eeprom_write_block((const void*)&event, (void*)&EEPROM_event, sizeof(event));
|
||||
eeprom_write_block((const void*)&phy_to_log, (void*)&EEPROM_phy_to_log, sizeof(phy_to_log));
|
||||
eeprom_write_block((const void*)&sensor, (void*)&EEPROM_sensor, sizeof(sensor));
|
||||
|
|
|
@ -38,6 +38,9 @@ volatile uint8_t spi_status, spi_high_hex;
|
|||
|
||||
uint8_t EEMEM first_EEPROM_byte_not_used_to_protect_from_brownout_corruption = 0xab;
|
||||
|
||||
uint16_t EEMEM EEPROM_version = 210;
|
||||
uint16_t version;
|
||||
|
||||
volatile struct event_struct EEMEM EEPROM_event = {0, 0};
|
||||
volatile struct event_struct event;
|
||||
|
||||
|
@ -228,6 +231,7 @@ ISR(ANALOG_COMP_vect)
|
|||
|
||||
void setup_datastructs(void)
|
||||
{
|
||||
eeprom_read_block((void*)&version, (const void*)&EEPROM_version, sizeof(version));
|
||||
eeprom_read_block((void*)&event, (const void*)&EEPROM_event, sizeof(event));
|
||||
eeprom_read_block((void*)&phy_to_log, (const void*)&EEPROM_phy_to_log, sizeof(phy_to_log));
|
||||
eeprom_read_block((void*)&sensor, (const void*)&EEPROM_sensor, sizeof(sensor));
|
||||
|
|
Loading…
Reference in New Issue