From 74d748ef3326efc90e77bf6444282824e896d180 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Sun, 11 Oct 2020 17:47:39 -0300 Subject: [PATCH 1/2] re-enable watchdog for STM32F1, and add a option for the board disable the watchdog init, as it can have a harware watchdog enabled or the bootloader already inited it --- Marlin/src/HAL/STM32/watchdog.cpp | 6 +++++- Marlin/src/HAL/STM32F1/watchdog.cpp | 4 +++- Marlin/src/pins/stm32f1/pins_MALYAN_M200.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp index 37e5638b05c0..cc1855314968 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 4123bc3ef0ff..ca91a6fe4350 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 d3c26c497d8f..d94d69e2d38b 100644 --- a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h +++ b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h @@ -90,3 +90,5 @@ #define MALYAN_FAN2_PIN PB3 // FAN2 header on board - CONTROLLER FAN #define FAN1_PIN MALYAN_FAN2_PIN + +#define DISABLE_WATCHDOG_INIT From 7465e6b6982c6c568cf6729162bb31615a1c6963 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 11 Oct 2020 19:30:18 -0500 Subject: [PATCH 2/2] Update pins_MALYAN_M200.h --- Marlin/src/pins/stm32f1/pins_MALYAN_M200.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h index d94d69e2d38b..95e7e92174fa 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 @@ -90,5 +93,3 @@ #define MALYAN_FAN2_PIN PB3 // FAN2 header on board - CONTROLLER FAN #define FAN1_PIN MALYAN_FAN2_PIN - -#define DISABLE_WATCHDOG_INIT