From 2e691e3e627b0a8809a01cf761fa04cf596586be Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 27 Sep 2025 15:58:04 -0700 Subject: [PATCH] safety: move relay fault management (#2281) * safety: move relay fault management * set it --- board/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/board/main.c b/board/main.c index dcc40922..ac0fda9b 100644 --- a/board/main.c +++ b/board/main.c @@ -118,6 +118,7 @@ static void tick_handler(void) { static uint32_t controls_allowed_countdown = 0; static uint8_t prev_harness_status = HARNESS_STATUS_NC; static uint8_t loop_counter = 0U; + static bool relay_malfunction_prev = false; if (TICK_TIMER->SR != 0U) { @@ -130,6 +131,15 @@ static void tick_handler(void) { simple_watchdog_kick(); sound_tick(); + if (relay_malfunction_prev != relay_malfunction) { + if (relay_malfunction) { + fault_occurred(FAULT_RELAY_MALFUNCTION); + } else { + fault_recovered(FAULT_RELAY_MALFUNCTION); + } + } + relay_malfunction_prev = relay_malfunction; + // re-init everything that uses harness status if (harness.status != prev_harness_status) { prev_harness_status = harness.status;