From 52272938b7faf8d77b9054a1bb9071fe86bdc49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 24 Jan 2021 20:27:07 +0100 Subject: [PATCH] update handling of analog monitors. Manually adding analog monotprs to the checking function is not necessary anymore --- .../safety/safety-controller.h | 1 + stm-firmware/safety/safety-controller.c | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/stm-firmware/include/reflow-controller/safety/safety-controller.h b/stm-firmware/include/reflow-controller/safety/safety-controller.h index db2b721..790d58d 100644 --- a/stm-firmware/include/reflow-controller/safety/safety-controller.h +++ b/stm-firmware/include/reflow-controller/safety/safety-controller.h @@ -48,6 +48,7 @@ struct analog_monitor_info { float min; /**< @brief Minumum value allowed */ float max; /**< @brief Maximum value allowed */ enum analog_monitor_status status; /**< @brief Current monitor status */ + enum safety_flag associated_flag; /**< @brief Associated safety flag, that will be set, if monitor out of range */ uint64_t timestamp; /**< @brief ms timestamp when @ref analog_monitor_info::value was taken. */ }; diff --git a/stm-firmware/safety/safety-controller.c b/stm-firmware/safety/safety-controller.c index 612afe5..af0a02e 100644 --- a/stm-firmware/safety/safety-controller.c +++ b/stm-firmware/safety/safety-controller.c @@ -358,24 +358,24 @@ static void safety_controller_process_active_timing_mons() static void safety_controller_process_monitor_checks(void) { static bool startup_completed = false; - enum analog_monitor_status amon_state; - float amon_value; + struct analog_monitor_info amon_info; + uint32_t idx; + uint32_t analog_mon_count; if (!startup_completed && systick_get_global_tick() >= 1000) startup_completed = true; if (startup_completed) { + analog_mon_count = safety_controller_get_analog_monitor_count(); + for (idx = 0; idx < analog_mon_count; idx++) { + if (safety_controller_get_analog_mon_by_index(idx, &amon_info)) { + panic_mode(); + } - - amon_state = safety_controller_get_analog_mon_value(ERR_AMON_VREF, &amon_value); - if (amon_state != ANALOG_MONITOR_OK) - safety_controller_report_error(ERR_FLAG_AMON_VREF); - amon_state = safety_controller_get_analog_mon_value(ERR_AMON_UC_TEMP, &amon_value); - if (amon_state != ANALOG_MONITOR_OK) - safety_controller_report_error(ERR_FLAG_AMON_UC_TEMP); - amon_state = safety_controller_get_analog_mon_value(ERR_AMON_SUPPLY_VOLT, &amon_value); - if (amon_state != ANALOG_MONITOR_OK) - safety_controller_report_error(ERR_FLAG_AMON_SUPPLY_VOLT); + if (amon_info.status != ANALOG_MONITOR_OK) { + safety_controller_report_error(amon_info.associated_flag); + } + } } safety_controller_process_active_timing_mons(); @@ -1005,6 +1005,7 @@ int safety_controller_get_analog_mon_by_index(uint32_t index, struct analog_moni info->min = mon->min; info->value = mon->value; info->timestamp = mon->timestamp; + info->associated_flag = mon->associated_flag; if (!mon->valid) { info->status = ANALOG_MONITOR_INACTIVE;