From c1729330c56b27cbdcc904d4faf88dfe80fc60ce Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 11 Oct 2020 21:31:21 -0300 Subject: [PATCH] Option to prevent (extra) Watchdog init on STM32 (#19693) --- Marlin/src/HAL/STM32/watchdog.cpp | 6 +++++- Marlin/src/HAL/STM32F1/watchdog.cpp | 4 +++- Marlin/src/pins/stm32f1/pins_MALYAN_M200.h | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp index 37e5638b05..cc18553149 100644 --- a/Marlin/src/HAL/STM32/watchdog.cpp +++ b/Marlin/src/HAL/STM32/watchdog.cpp @@ -30,7 +30,11 @@ #include "watchdog.h" #include - void watchdog_init() { IWatchdog.begin(4000000); } // 4 sec timeout + void watchdog_init() { + #if DISABLED(DISABLE_WATCHDOG_INIT) + IWatchdog.begin(4000000); // 4 sec timeout + #endif + } void HAL_watchdog_refresh() { IWatchdog.reload(); diff --git a/Marlin/src/HAL/STM32F1/watchdog.cpp b/Marlin/src/HAL/STM32F1/watchdog.cpp index 4123bc3ef0..ca91a6fe43 100644 --- a/Marlin/src/HAL/STM32F1/watchdog.cpp +++ b/Marlin/src/HAL/STM32F1/watchdog.cpp @@ -52,7 +52,9 @@ void watchdogSetup() { * @details The watchdog clock is 40Khz. We need a 4 seconds interval, so use a /256 preescaler and 625 reload value (counts down to 0) */ void watchdog_init() { - //iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD); + #if DISABLED(DISABLE_WATCHDOG_INIT) + iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD); + #endif } #endif // USE_WATCHDOG diff --git a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h index d3c26c497d..95e7e92174 100644 --- a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h +++ b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h @@ -33,6 +33,9 @@ #define BOARD_INFO_NAME "Malyan M200" #endif +// Prevents hanging from an extra watchdog init +#define DISABLE_WATCHDOG_INIT + // Assume Flash EEPROM #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION