From d134ebec2b8e18674e09367a68d7e494d85fff21 Mon Sep 17 00:00:00 2001 From: gitknilch Date: Wed, 16 Mar 2011 22:26:32 +0100 Subject: [PATCH 1/1] add initialization of node address via eeprom --- firmware/fnordlicht-firmware/fnordlicht.c | 2 ++ firmware/fnordlicht-firmware/storage.h | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/firmware/fnordlicht-firmware/fnordlicht.c b/firmware/fnordlicht-firmware/fnordlicht.c index b5e2ffe..f0b011b 100644 --- a/firmware/fnordlicht-firmware/fnordlicht.c +++ b/firmware/fnordlicht-firmware/fnordlicht.c @@ -42,6 +42,8 @@ static void startup(void) { /* if configuration is valid */ if (storage_valid_config()) { + /* set global address to stored value */ + global_remote.address = startup_config.startup_addr; /* read default mode from storage (do nothing if mode is invalid) */ if (startup_config.params.mode == STARTUP_PROGRAM) { diff --git a/firmware/fnordlicht-firmware/storage.h b/firmware/fnordlicht-firmware/storage.h index 09e293d..76f352e 100644 --- a/firmware/fnordlicht-firmware/storage.h +++ b/firmware/fnordlicht-firmware/storage.h @@ -44,27 +44,29 @@ struct storage_color_t #define EEPROM_MAGIC_BYTE 0x23 /* store the startup configuration in EEPROM - * size: 13 byte */ + * size: 14 bytes */ struct storage_config_t { /* magic byte, must match EEPROM_MAGIC_BYTE to mark a valid configuration */ uint8_t magic; - /* startup parameters, defined in remote_proto.h, size: 12 byte */ + /* initial node address to use at startup */ + uint8_t startup_addr; + /* startup parameters, defined in remote_proto.h, size: 12 bytes */ struct startup_parameters_t params; }; /* storage structure for EEPROM - * size: 494 byte - * (means: 18 byte left) */ + * size: 496 bytes + * (means: 16 bytes left) */ struct storage_t { - /* startup configuration, size: 12 byte */ + /* startup configuration, size: 14 bytes */ struct storage_config_t config; - /* color storage, size: 60*8 == 480 byte */ + /* color storage, size: 60*8 == 480 bytes */ struct storage_color_t color[CONFIG_EEPROM_COLORS]; - /* crc16 checksum over config and color[], size: 2 byte */ + /* crc16 checksum over config and color[], size: 2 bytes */ uint16_t checksum; }; -- 2.39.5