Fix safety issue #11

This commit is contained in:
Mario Hüttel 2020-08-18 20:47:08 +02:00
parent fa20304df8
commit 45564a7789
1 changed files with 7 additions and 5 deletions

View File

@ -30,6 +30,8 @@
#include <reflow-controller/stack-check.h> #include <reflow-controller/stack-check.h>
#include <helper-macros/helper-macros.h> #include <helper-macros/helper-macros.h>
#include <reflow-controller/systick.h> #include <reflow-controller/systick.h>
#include <stm32/stm32f4xx.h>
#include <cmsis/core_cm4.h>
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
@ -148,11 +150,15 @@ static void safety_controller_process_active_timing_mons()
{ {
uint32_t i; uint32_t i;
volatile struct timing_mon *current_mon; volatile struct timing_mon *current_mon;
uint64_t last;
for (i = 0; i < COUNT_OF(timings); i++) { for (i = 0; i < COUNT_OF(timings); i++) {
current_mon = &timings[i]; current_mon = &timings[i];
if (current_mon->enabled) { if (current_mon->enabled) {
if (systick_ticks_have_passed(current_mon->last, current_mon->max_delta)) __disable_irq();
last = current_mon->last;
__enable_irq();
if (systick_ticks_have_passed(last, current_mon->max_delta))
safety_controller_report_error(current_mon->associated_flag); safety_controller_report_error(current_mon->associated_flag);
} }
} }
@ -164,12 +170,9 @@ static void safety_controller_process_checks()
enum analog_monitor_status amon_state; enum analog_monitor_status amon_state;
float amon_value; float amon_value;
if (!startup_completed && systick_get_global_tick() >= 1000) if (!startup_completed && systick_get_global_tick() >= 1000)
startup_completed = true; startup_completed = true;
if (startup_completed) { if (startup_completed) {
amon_state = safety_controller_get_analog_mon_value(ERR_AMON_VREF, &amon_value); amon_state = safety_controller_get_analog_mon_value(ERR_AMON_VREF, &amon_value);
if (amon_state != ANALOG_MONITOR_OK) if (amon_state != ANALOG_MONITOR_OK)
@ -181,7 +184,6 @@ static void safety_controller_process_checks()
} }
safety_controller_process_active_timing_mons(); safety_controller_process_active_timing_mons();
} }
int safety_controller_report_error(enum safety_flag flag) int safety_controller_report_error(enum safety_flag flag)