File tree Expand file tree Collapse file tree
atmel-samd/common-hal/watchdog
espressif/common-hal/watchdog
raspberrypi/common-hal/watchdog Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -243,6 +243,12 @@ void supervisor_execution_status(void) {
243243}
244244#endif
245245
246+ #if CIRCUITPY_WATCHDOG
247+ pyexec_result_t * pyexec_result (void ) {
248+ return & _exec_result ;
249+ }
250+ #endif
251+
246252// Look for the first file that exists in the list of filenames, using mp_import_stat().
247253// Return its index. If no file found, return -1.
248254STATIC const char * first_existing_file_in_list (const char * const * filenames , size_t n_filenames ) {
Original file line number Diff line number Diff line change 2828
2929#include "py/runtime.h"
3030
31+ #include "shared/runtime/pyexec.h"
32+
3133#include "shared-bindings/watchdog/__init__.h"
3234#include "shared-bindings/watchdog/WatchDogTimer.h"
35+ #include "shared-bindings/microcontroller/__init__.h"
36+
3337#include "common-hal/watchdog/WatchDogTimer.h"
3438
3539#include "component/wdt.h"
@@ -79,7 +83,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
7983}
8084
8185void watchdog_reset (void ) {
82- common_hal_watchdog_deinit (& common_hal_mcu_watchdogtimer_obj );
86+ watchdog_watchdogtimer_obj_t * self = & common_hal_mcu_watchdogtimer_obj ;
87+ if (self -> mode == WATCHDOGMODE_RESET ) {
88+ mp_obj_t exception = pyexec_result ()-> exception ;
89+ if (exception != MP_OBJ_NULL &&
90+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception )) &&
91+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_reload_exception ))) {
92+ return ;
93+ }
94+ }
95+ common_hal_watchdog_deinit (self );
8396}
8497
8598mp_float_t common_hal_watchdog_get_timeout (watchdog_watchdogtimer_obj_t * self ) {
Original file line number Diff line number Diff line change 2525 */
2626
2727#include "py/runtime.h"
28- #include "common-hal/watchdog/WatchDogTimer.h"
28+
29+ #include "shared/runtime/pyexec.h"
2930
3031#include "shared-bindings/watchdog/__init__.h"
3132#include "shared-bindings/microcontroller/__init__.h"
3233
34+ #include "common-hal/watchdog/WatchDogTimer.h"
35+
3336#include "esp_task_wdt.h"
3437
3538extern void esp_task_wdt_isr_user_handler (void );
@@ -66,7 +69,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
6669}
6770
6871void watchdog_reset (void ) {
69- common_hal_watchdog_deinit (& common_hal_mcu_watchdogtimer_obj );
72+ watchdog_watchdogtimer_obj_t * self = & common_hal_mcu_watchdogtimer_obj ;
73+ if (self -> mode == WATCHDOGMODE_RESET ) {
74+ mp_obj_t exception = pyexec_result ()-> exception ;
75+ if (exception != MP_OBJ_NULL &&
76+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception )) &&
77+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_reload_exception ))) {
78+ return ;
79+ }
80+ }
81+ common_hal_watchdog_deinit (self );
7082}
7183
7284static void wdt_config (uint32_t timeout , watchdog_watchdogmode_t mode ) {
Original file line number Diff line number Diff line change 3333#include "py/objproperty.h"
3434#include "py/runtime.h"
3535
36- #include "common-hal/watchdog/WatchDogTimer .h"
36+ #include "shared/runtime/pyexec .h"
3737
3838#include "shared-bindings/microcontroller/__init__.h"
3939#include "shared-bindings/watchdog/__init__.h"
4040#include "shared-bindings/watchdog/WatchDogTimer.h"
4141
42+ #include "common-hal/watchdog/WatchDogTimer.h"
43+
4244#include "supervisor/port.h"
4345
4446#include "nrf/timers.h"
@@ -108,7 +110,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
108110}
109111
110112void watchdog_reset (void ) {
111- common_hal_watchdog_deinit (& common_hal_mcu_watchdogtimer_obj );
113+ watchdog_watchdogtimer_obj_t * self = & common_hal_mcu_watchdogtimer_obj ;
114+ if (self -> mode == WATCHDOGMODE_RESET ) {
115+ mp_obj_t exception = pyexec_result ()-> exception ;
116+ if (exception != MP_OBJ_NULL &&
117+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception )) &&
118+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_reload_exception ))) {
119+ return ;
120+ }
121+ }
122+ common_hal_watchdog_deinit (self );
112123}
113124
114125mp_float_t common_hal_watchdog_get_timeout (watchdog_watchdogtimer_obj_t * self ) {
Original file line number Diff line number Diff line change 2525 */
2626
2727#include "py/runtime.h"
28- #include "common-hal/watchdog/WatchDogTimer.h"
28+
29+ #include "shared/runtime/pyexec.h"
2930
3031#include "shared-bindings/watchdog/__init__.h"
3132#include "shared-bindings/microcontroller/__init__.h"
3233
33- #include "src/rp2_common/hardware_watchdog/include/hardware/watchdog.h"
34+ #include "common-hal/watchdog/WatchDogTimer.h"
35+
36+ #include "hardware/watchdog.h"
3437
3538#define WATCHDOG_ENABLE watchdog_enable(self->timeout * 1000, false)
3639
@@ -47,7 +50,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
4750}
4851
4952void watchdog_reset (void ) {
50- common_hal_watchdog_deinit (& common_hal_mcu_watchdogtimer_obj );
53+ watchdog_watchdogtimer_obj_t * self = & common_hal_mcu_watchdogtimer_obj ;
54+ if (self -> mode == WATCHDOGMODE_RESET ) {
55+ mp_obj_t exception = pyexec_result ()-> exception ;
56+ if (exception != MP_OBJ_NULL &&
57+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception )) &&
58+ exception != MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_reload_exception ))) {
59+ return ;
60+ }
61+ }
62+ common_hal_watchdog_deinit (self );
5163}
5264
5365mp_float_t common_hal_watchdog_get_timeout (watchdog_watchdogtimer_obj_t * self ) {
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ extern uint8_t pyexec_repl_active;
6767int pyexec_exit_handler (const void * source , pyexec_result_t * result );
6868#endif
6969
70+ #if CIRCUITPY_WATCHDOG
71+ pyexec_result_t * pyexec_result (void );
72+ #endif
73+
7074#if MICROPY_REPL_INFO
7175mp_obj_t pyb_set_repl_info (mp_obj_t o_value );
7276MP_DECLARE_CONST_FUN_OBJ_1 (pyb_set_repl_info_obj );
You can’t perform that action at this time.
0 commit comments