From 173aeec2fc2507c8eadf44bcba58ccca73bc64fb Mon Sep 17 00:00:00 2001 From: Jan Mrna Date: Sun, 19 Jun 2022 22:54:13 +0200 Subject: [PATCH] Added device class code and default value for serial 1 --- fw/Core/Inc/config.h | 6 ++++++ fw/Core/Src/main.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/fw/Core/Inc/config.h b/fw/Core/Inc/config.h index a8c7ace..02c10ba 100644 --- a/fw/Core/Inc/config.h +++ b/fw/Core/Inc/config.h @@ -48,6 +48,10 @@ config_read(&config); * Device description data can be accessed using direct readout from the memory * Device configuration data can be accessed using config_t struct. */ + +/* device class: IAQ_Wired ; device code: 0x0010 (see serial generator repo) */ +#define CONFIG_DEVICE_CODE 0x0010 + #define CONFIG_DEFAULT_LED_ON 1 #define CONFIG_DEFAULT_LED_BRIGHTNESS 100 #define CONFIG_DEFAULT_LED_ALERT1_LIMIT 1500 @@ -55,6 +59,8 @@ config_read(&config); #define CONFIG_DEFAULT_LED_SMOOTH 1 #define CONFIG_DEFAULT_SCD4x_T_OFFSET 0 #define CONFIG_DEFAULT_BAUDRATE_INDEX 0 +#define CONFIG_DEFAULT_SERIAL_1 (CONFIG_DEVICE_CODE) +/* SERIAL_2 is not defined, as it makes no sense to have default value */ #define CONFIG_SERIAL_NUMBER_1_LENGTH 2 #define CONFIG_SERIAL_NUMBER_2_LENGTH 2 diff --git a/fw/Core/Src/main.c b/fw/Core/Src/main.c index 0b6b61b..39cd156 100644 --- a/fw/Core/Src/main.c +++ b/fw/Core/Src/main.c @@ -296,6 +296,9 @@ int main(void) int8_t config_read_status = config_read(&sensor_config); if (config_read_status != CONFIG_OK) { + /* serial_number_1 contains device class code, + * in case of EEPROM corruption it should have reasonable value */ + sensor_config.serial_number_1 = CONFIG_DEFAULT_SERIAL_1; sensor_config.modbus_addr = MODBUS_DEFAULT_SLAVE_ADDRESS; sensor_config.led_co2_alert_limit1 = CONFIG_DEFAULT_LED_ALERT1_LIMIT; sensor_config.led_co2_alert_limit2 = CONFIG_DEFAULT_LED_ALERT2_LIMIT;