Added node id restoring and burning functions.
This commit is contained in:
parent
f617b77b87
commit
5e1db8b6fa
1 changed files with 13 additions and 0 deletions
|
@ -39,12 +39,25 @@ uint16_t node_id = 0;
|
|||
void
|
||||
node_id_restore(void)
|
||||
{
|
||||
uint16_t newid[2];
|
||||
uint8_t volatile sreg;
|
||||
|
||||
sreg = SREG; /* Save status register before disabling interrupts. */
|
||||
cli(); /* Disable interrupts. */
|
||||
eeprom_read(EEPROM_NODE_ID_START, (unsigned char *)newid, sizeof(newid));
|
||||
node_id = (newid[0] == 0xdead) ? newid[1] : 0;
|
||||
SREG = sreg; /* Enable interrupts. */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
node_id_burn(uint16_t id)
|
||||
{
|
||||
uint16_t buffer[2] = { 0xdead, id };
|
||||
uint8_t volatile sreg;
|
||||
|
||||
sreg = SREG; /* Save status register before disabling interrupts. */
|
||||
cli(); /* Disable interrupts. */
|
||||
eeprom_write(EEPROM_NODE_ID_START, (unsigned char *)buffer, sizeof(buffer));
|
||||
SREG = sreg; /* Enable interrupts. */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue