diff --git a/cube/User/Inc/config.h b/cube/User/Inc/config.h index 1d96cf8..d5a228f 100644 --- a/cube/User/Inc/config.h +++ b/cube/User/Inc/config.h @@ -8,6 +8,7 @@ typedef struct __attribute__((__packed__)) s_configBlock { char deviceName[16]; uint8_t macAddress[6]; + int32_t frontendThreshold; char brokerName[64]; char watchdogTopic[64]; char startupTopic[64]; diff --git a/cube/User/Inc/frontend.h b/cube/User/Inc/frontend.h index cbcc05a..9d5ad1d 100644 --- a/cube/User/Inc/frontend.h +++ b/cube/User/Inc/frontend.h @@ -9,6 +9,5 @@ void frontendInit(); void frontendAdcCallback(ADC_HandleTypeDef* hadc); void frontendEnable(); void frontendDisable(); -void frontendSetThreshold(int32_t threshold); #endif // _FRONTEND_H_ \ No newline at end of file diff --git a/cube/User/Src/config.c b/cube/User/Src/config.c index 80c5f5c..6fa90dc 100644 --- a/cube/User/Src/config.c +++ b/cube/User/Src/config.c @@ -1,22 +1,11 @@ #include -/* -typedef struct __attribute__((__packed__)) s_configBlock { - char deviceName[16]; - uint8_t macAddress[6]; - char brokerName[64]; - char watchdogTopic[64]; - char startupTopic[64]; - char statusTopic[64]; - char mbusDataTopic[64]; - char syslogServerName[64]; -} t_configBlock; -*/ t_configBlock defaultConfigBlock = { .deviceName = "MBGW3", .macAddress = { 0x00, 0xA0, 0x57, 0x05, 0x3E, 0x0D }, + .frontendThreshold = 240, .brokerName = "mqttbroker", .watchdogTopic = "IoT/Watchdog", .startupTopic = "IoT/MBGW3/Startup", diff --git a/cube/User/Src/frontend.c b/cube/User/Src/frontend.c index cac960d..b7cc705 100644 --- a/cube/User/Src/frontend.c +++ b/cube/User/Src/frontend.c @@ -6,9 +6,10 @@ #include #include #include +#include - +static t_configBlock *config; static volatile int32_t frontendAdcThreshold = 0; @@ -16,16 +17,15 @@ static volatile bool frontendEnabled = false; void frontendInit() { + config = getConfig(); + frontendAdcThreshold = config->frontendThreshold; + HAL_ADCEx_Calibration_Start(&frontendAdc); logMsg("frontendInit, calibration done"); HAL_ADC_Start_IT(&frontendAdc); logMsg("frontendInit, adc started"); } -void frontendSetThreshold(int32_t threshold) { - frontendAdcThreshold = threshold; -} - void frontendEnable() { frontendEnabled = true; } diff --git a/cube/User/Src/main2.c b/cube/User/Src/main2.c index 6313b8a..60cdbce 100644 --- a/cube/User/Src/main2.c +++ b/cube/User/Src/main2.c @@ -55,7 +55,6 @@ void my_setup_2() { oledPrint(OLED_SCREEN0, "cmdhandler init"); frontendInit(); - frontendSetThreshold(240); oledPrint(OLED_SCREEN0, "frontend init"); mbusCommInit();