Watchdog cleanup (#15283)

This commit is contained in:
Scott Lahteine
2019-09-29 17:57:29 -05:00
committed by GitHub
parent 24706aedbd
commit 139b7196a0
28 changed files with 73 additions and 97 deletions

View File

@ -26,6 +26,10 @@
#include "../shared/Delay.h"
#include "../../../gcode/parser.h"
#if ENABLED(USE_WATCHDOG)
#include "watchdog.h"
#endif
// U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) {
DELAY_US(val);
@ -65,4 +69,17 @@ void flashFirmware(int16_t value) {
NVIC_SystemReset();
}
void HAL_clear_reset_source(void) {
#if ENABLED(USE_WATCHDOG)
watchdog_clear_timeout_flag();
#endif
}
uint8_t HAL_get_reset_source(void) {
#if ENABLED(USE_WATCHDOG)
if (watchdog_timed_out()) return RST_WATCHDOG;
#endif
return RST_POWER_ON;
}
#endif // TARGET_LPC1768

View File

@ -164,3 +164,7 @@ void set_pwm_frequency(const pin_t pin, int f_desired);
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
*/
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
// Reset source
void HAL_clear_reset_source(void);
uint8_t HAL_get_reset_source(void);

View File

@ -56,28 +56,16 @@ void watchdog_init() {
WDT_Start(WDT_TIMEOUT);
}
void HAL_clear_reset_source() {
WDT_ClrTimeOutFlag();
}
uint8_t HAL_get_reset_source() {
if (TEST(WDT_ReadTimeOutFlag(), 0)) return RST_WATCHDOG;
return RST_POWER_ON;
}
void watchdog_reset() {
void HAL_watchdog_refresh() {
WDT_Feed();
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
TOGGLE(LED_PIN); // heartbeat indicator
#endif
}
#else
void watchdog_init() {}
void watchdog_reset() {}
void HAL_clear_reset_source() {}
uint8_t HAL_get_reset_source() { return RST_POWER_ON; }
// Timeout state
bool watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); }
void watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); }
#endif // USE_WATCHDOG

View File

@ -24,6 +24,7 @@
#define WDT_TIMEOUT 4000000 // 4 second timeout
void watchdog_init();
void watchdog_reset();
void HAL_clear_reset_source();
uint8_t HAL_get_reset_source();
void HAL_watchdog_refresh();
bool watchdog_timed_out();
void watchdog_clear_timeout_flag();