Implement unresponsive tinySA reboot using WDG

pull/94/head
Bohdan Kmit 2 years ago
parent 31a89ceda8
commit a4602cb729

@ -223,6 +223,6 @@
/* /*
* WDG driver system settings. * WDG driver system settings.
*/ */
#define STM32_WDG_USE_IWDG FALSE #define STM32_WDG_USE_IWDG TRUE
#endif /* MCUCONF_H */ #endif /* MCUCONF_H */

@ -92,7 +92,7 @@
#else #else
// Use 32768Hz LSE // Use 32768Hz LSE
#define STM32_LSE_ENABLED TRUE #define STM32_LSE_ENABLED TRUE
#define STM32_LSI_ENABLED FALSE #define STM32_LSI_ENABLED TRUE
#define STM32_RTCSEL STM32_RTCSEL_LSE #define STM32_RTCSEL STM32_RTCSEL_LSE
#define STM32_RTC_PRESA_VALUE 32 #define STM32_RTC_PRESA_VALUE 32
#define STM32_RTC_PRESS_VALUE 1024 #define STM32_RTC_PRESS_VALUE 1024
@ -265,6 +265,6 @@
/* /*
* WDG driver system settings. * WDG driver system settings.
*/ */
#define STM32_WDG_USE_IWDG FALSE #define STM32_WDG_USE_IWDG TRUE
#endif /* MCUCONF_H */ #endif /* MCUCONF_H */

@ -175,7 +175,7 @@
* @brief Enables the WDG subsystem. * @brief Enables the WDG subsystem.
*/ */
#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
#define HAL_USE_WDG FALSE #define HAL_USE_WDG TRUE
#endif #endif
/*===========================================================================*/ /*===========================================================================*/

@ -285,6 +285,7 @@ static THD_FUNCTION(Thread1, arg)
// plot trace and other indications as raster // plot trace and other indications as raster
draw_all(completed); // flush markmap only if scan completed to prevent draw_all(completed); // flush markmap only if scan completed to prevent
// remaining traces // remaining traces
wdgReset(&WDGD1);
// STOP_PROFILE // STOP_PROFILE
} }
@ -3102,6 +3103,13 @@ int main(void)
set_sweep_frequency(ST_STOP, (freq_t) 4000000); set_sweep_frequency(ST_STOP, (freq_t) 4000000);
sweep(false); sweep(false);
#endif #endif
static const WDGConfig scan_wdgcfg = {
STM32_IWDG_PR_256,
STM32_IWDG_RL(1 * (40000 / 256)), /* 1 second */
STM32_IWDG_WIN_DISABLED
};
wdgInit();
wdgStart(&WDGD1, &scan_wdgcfg);
if (reset_state|| (caldata_recall(0) == -1)) { if (reset_state|| (caldata_recall(0) == -1)) {
load_LCD_properties(); load_LCD_properties();

@ -4932,6 +4932,7 @@ again: // Spur redu
t++; // one subscan done t++; // one subscan done
if (break_on_operation && operation_requested) // break subscanning if requested if (break_on_operation && operation_requested) // break subscanning if requested
break; // abort break; // abort
wdgReset(&WDGD1);
} while (t < local_vbw_steps); // till all sub steps done } while (t < local_vbw_steps); // till all sub steps done
TRACE(7); TRACE(7);
#ifdef TINYSA4 #ifdef TINYSA4

@ -186,6 +186,7 @@ int btn_side(void)
static int btn_check(void) static int btn_check(void)
{ {
systime_t ticks; systime_t ticks;
wdgReset(&WDGD1);
// Debounce input // Debounce input
while(TRUE){ while(TRUE){
ticks = chVTGetSystemTimeX(); ticks = chVTGetSystemTimeX();
@ -212,6 +213,7 @@ static int btn_check(void)
static int btn_wait_release(void) static int btn_wait_release(void)
{ {
while (TRUE) { while (TRUE) {
wdgReset(&WDGD1);
systime_t ticks = chVTGetSystemTimeX(); systime_t ticks = chVTGetSystemTimeX();
systime_t dt = ticks - last_button_down_ticks; systime_t dt = ticks - last_button_down_ticks;
// Debounce input // Debounce input
@ -299,6 +301,7 @@ touch_measure_x(void)
static inline int static inline int
touch_status(void) touch_status(void)
{ {
wdgReset(&WDGD1);
return adc_single_read(ADC_TOUCH_Y) > TOUCH_THRESHOLD; return adc_single_read(ADC_TOUCH_Y) > TOUCH_THRESHOLD;
} }
@ -655,6 +658,8 @@ extern const char *states[];
chThdSleepMilliseconds(40); chThdSleepMilliseconds(40);
if ((cnt++)&0x07) continue; // Not update time so fast if ((cnt++)&0x07) continue; // Not update time so fast
wdgReset(&WDGD1);
#ifdef TINYSA4 #ifdef TINYSA4
#ifdef __USE_RTC__ #ifdef __USE_RTC__
uint32_t tr = rtc_get_tr_bin(); // TR read first uint32_t tr = rtc_get_tr_bin(); // TR read first
@ -7798,6 +7803,7 @@ static void sa_save_file(uint8_t format) {
#else #else
plot_printf(fs_filename, FF_LFN_BUF, "%08x.%s", rtc_get_FAT(), file_ext[format]); plot_printf(fs_filename, FF_LFN_BUF, "%08x.%s", rtc_get_FAT(), file_ext[format]);
#endif #endif
wdgReset(&WDGD1);
} }
else { else {
ui_mode_keypad(KM_FILENAME); ui_mode_keypad(KM_FILENAME);

Loading…
Cancel
Save

Powered by TurnKey Linux.