Add watchdog mode raise

This commit is contained in:
microDev 2020-11-14 11:41:14 +05:30
parent 10e8b8cf45
commit 146adca060
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
3 changed files with 14 additions and 3 deletions

View File

@ -27,12 +27,19 @@
#include "py/runtime.h"
#include "common-hal/watchdog/WatchDogTimer.h"
#include "shared-bindings/watchdog/__init__.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "esp_task_wdt.h"
void esp_task_wdt_isr_user_handler(void) {
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception));
MP_STATE_VM(mp_pending_exception) = &mp_watchdog_timeout_exception;
#if MICROPY_ENABLE_SCHEDULER
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
}
#endif
}
void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) {

View File

@ -37,8 +37,7 @@ struct _watchdog_watchdogtimer_obj_t {
watchdog_watchdogmode_t mode;
};
// This needs to be called in order to disable the watchdog if it's set to
// "RAISE". If set to "RESET", then the watchdog cannot be reset.
// This needs to be called in order to disable the watchdog
void watchdog_reset(void);
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

View File

@ -41,6 +41,7 @@
#include "common-hal/busio/UART.h"
#include "common-hal/pulseio/PulseIn.h"
#include "common-hal/pwmio/PWMOut.h"
#include "common-hal/watchdog/WatchDogTimer.h"
#include "common-hal/wifi/__init__.h"
#include "supervisor/memory.h"
#include "supervisor/shared/tick.h"
@ -119,6 +120,10 @@ void reset_port(void) {
rtc_reset();
#endif
#if CIRCUITPY_WATCHDOG
watchdog_reset();
#endif
#if CIRCUITPY_WIFI
wifi_reset();
#endif