From 4ebca98cdf92f820eada99444f47539adab0fb64 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Mon, 7 Mar 2016 20:09:25 +0100 Subject: [PATCH] Re #3340: Watchdog still disabled on Horus, but use -DWATCHDOG_DISABLED=OFF to enable it. Radio currently resets if WDT is enabled, because external module functions are not yet implemented. After the radio is stable default for WATCHDOG_DISABLED will be set to OFF --- radio/src/CMakeLists.txt | 5 +++++ radio/src/cli.cpp | 8 +++++++- radio/src/targets/horus/board_horus.h | 9 +++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index dece00c0b..a0bf6f79f 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -18,6 +18,7 @@ option(AUTOSOURCE "Automatic source detection in menus" ON) option(AUTOSWITCH "Automatic switch detection in menus" ON) option(JITTER_MEASURE "Enable ADC jitter measurement" OFF) option(JITTER_FILTER "Enable ADC jitter filtering" ON) +option(WATCHDOG_DISABLED "Disable hardware Watchdog on Horus" ON) enable_language(ASM) set(OPT s) @@ -784,6 +785,10 @@ if(JITTER_FILTER) add_definitions(-DJITTER_FILTER) endif() +if(WATCHDOG_DISABLED) + add_definitions(-DWATCHDOG_DISABLED) +endif() + if(SDCARD) add_definitions(-DSDCARD) include_directories(${FATFS_DIR} ${FATFS_DIR}/option) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index 6acf5199a..594467263 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -272,7 +272,13 @@ int cliMemoryInfo(const char ** argv) int cliReboot(const char ** argv) { #if !defined(SIMU) - NVIC_SystemReset(); + if (!strcmp(argv[1], "wdt")) { + // do a user requested watchdog test by pausing mixer thread + pausePulses(); + } + else { + NVIC_SystemReset(); + } #endif return 0; } diff --git a/radio/src/targets/horus/board_horus.h b/radio/src/targets/horus/board_horus.h index e6d066f77..a45bf10ca 100644 --- a/radio/src/targets/horus/board_horus.h +++ b/radio/src/targets/horus/board_horus.h @@ -202,8 +202,13 @@ void checkRotaryEncoder(void); #if !defined(SIMU) #define wdt_disable() void watchdogInit(unsigned int duration); -#define wdt_enable(x) // watchdogInit(1500) -#define wdt_reset() // IWDG->KR = 0xAAAA +#if defined(WATCHDOG_DISABLED) + #define wdt_enable(x) + #define wdt_reset() +#else + #define wdt_enable(x) watchdogInit(1500) + #define wdt_reset() IWDG->KR = 0xAAAA +#endif #define WAS_RESET_BY_WATCHDOG() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF)) #define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF) #define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_SFTRSTF))