From 5169ddd4bd1a4fcebb08039bb46fc094b8f79457 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Thu, 9 Jul 2020 19:58:20 +0200 Subject: [PATCH] Set watchdog to approximately 2s and add refreshing --- firmware/Src/init.c | 1 - firmware/Src/iwdg.c | 2 +- firmware/Src/main.cpp | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/Src/init.c b/firmware/Src/init.c index 34e330f..1658ff6 100644 --- a/firmware/Src/init.c +++ b/firmware/Src/init.c @@ -90,7 +90,6 @@ void init(void) MX_GPIO_Init(); MX_ADC_Init(); MX_USB_DEVICE_Init(); - MX_IWDG_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ diff --git a/firmware/Src/iwdg.c b/firmware/Src/iwdg.c index 25b15ed..a83d0ca 100644 --- a/firmware/Src/iwdg.c +++ b/firmware/Src/iwdg.c @@ -31,7 +31,7 @@ void MX_IWDG_Init(void) { hiwdg.Instance = IWDG; - hiwdg.Init.Prescaler = IWDG_PRESCALER_4; + hiwdg.Init.Prescaler = IWDG_PRESCALER_16; hiwdg.Init.Window = 4095; hiwdg.Init.Reload = 4095; if (HAL_IWDG_Init(&hiwdg) != HAL_OK) diff --git a/firmware/Src/main.cpp b/firmware/Src/main.cpp index 19cc880..60553ee 100644 --- a/firmware/Src/main.cpp +++ b/firmware/Src/main.cpp @@ -1,4 +1,5 @@ #include "init.h" +#include "iwdg.h" #include "terminal.hpp" #include "uart.hpp" @@ -37,11 +38,13 @@ static inline void initializeHardware() int main() { initializeHardware(); + MX_IWDG_Init(); terminal_t terminal; while(true) { terminal.callback(); + HAL_IWDG_Refresh(&hiwdg); } return 0;