From 2c3c1c98610a88c9af0b9baf84b741f24521af9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 1 Jan 2021 18:04:14 +0100 Subject: [PATCH] Add external watchdog to safety controller for HW revision > 1.3 and Release Build --- .../reflow-controller/safety/safety-config.h | 4 ++ stm-firmware/safety/safety-controller.c | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/stm-firmware/include/reflow-controller/safety/safety-config.h b/stm-firmware/include/reflow-controller/safety/safety-config.h index 50ff7e6..4c63a8b 100644 --- a/stm-firmware/include/reflow-controller/safety/safety-config.h +++ b/stm-firmware/include/reflow-controller/safety/safety-config.h @@ -119,6 +119,10 @@ enum analog_value_monitor { #define SAFETY_ADC_TEMP_HIGH_LIM (65.0f) +#define SAFETY_EXT_WATCHDOG_PORT GPIOD +#define SAFETY_EXT_WATCHDOG_RCC_MASK RCC_AHB1ENR_GPIODEN +#define SAFETY_EXT_WATCHDOG_PIN (12) + /** * @brief Key used to lock the safety flags coming from the measurment ADC from external ack'ing */ diff --git a/stm-firmware/safety/safety-controller.c b/stm-firmware/safety/safety-controller.c index 4d79946..ec40416 100644 --- a/stm-firmware/safety/safety-controller.c +++ b/stm-firmware/safety/safety-controller.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -475,10 +476,23 @@ static int get_safety_flags_from_error_mem(enum safety_flag *flags) return 0; } +static void safety_controller_init_external_watchdog() +{ + rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(SAFETY_EXT_WATCHDOG_RCC_MASK)); + SAFETY_EXT_WATCHDOG_PORT->MODER &= MODER_DELETE(SAFETY_EXT_WATCHDOG_PIN); +#ifndef DEBUGBUILD + SAFETY_EXT_WATCHDOG_PORT->MODER |= OUTPUT(SAFETY_EXT_WATCHDOG_PIN); + SAFETY_EXT_WATCHDOG_PORT->ODR |= (1<ODR ^= (1< 30) { + external_watchdog_toggle(); + watchdog_counter = 0UL; + } + } +#endif return (ret ? -1 : 0); }