File tree Expand file tree Collapse file tree 6 files changed +66
-8
lines changed
atmel-samd/common-hal/watchdog
espressif/common-hal/watchdog
raspberrypi/common-hal/watchdog Expand file tree Collapse file tree 6 files changed +66
-8
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,12 @@ void supervisor_execution_status(void) {
243
243
}
244
244
#endif
245
245
246
+ #if CIRCUITPY_WATCHDOG
247
+ pyexec_result_t * pyexec_result (void ) {
248
+ return & _exec_result ;
249
+ }
250
+ #endif
251
+
246
252
// Look for the first file that exists in the list of filenames, using mp_import_stat().
247
253
// Return its index. If no file found, return -1.
248
254
STATIC 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 28
28
29
29
#include "py/runtime.h"
30
30
31
+ #include "shared/runtime/pyexec.h"
32
+
31
33
#include "shared-bindings/watchdog/__init__.h"
32
34
#include "shared-bindings/watchdog/WatchDogTimer.h"
35
+ #include "shared-bindings/microcontroller/__init__.h"
36
+
33
37
#include "common-hal/watchdog/WatchDogTimer.h"
34
38
35
39
#include "component/wdt.h"
@@ -79,7 +83,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
79
83
}
80
84
81
85
void 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 );
83
96
}
84
97
85
98
mp_float_t common_hal_watchdog_get_timeout (watchdog_watchdogtimer_obj_t * self ) {
Original file line number Diff line number Diff line change 25
25
*/
26
26
27
27
#include "py/runtime.h"
28
- #include "common-hal/watchdog/WatchDogTimer.h"
28
+
29
+ #include "shared/runtime/pyexec.h"
29
30
30
31
#include "shared-bindings/watchdog/__init__.h"
31
32
#include "shared-bindings/microcontroller/__init__.h"
32
33
34
+ #include "common-hal/watchdog/WatchDogTimer.h"
35
+
33
36
#include "esp_task_wdt.h"
34
37
35
38
extern void esp_task_wdt_isr_user_handler (void );
@@ -66,7 +69,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
66
69
}
67
70
68
71
void 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 );
70
82
}
71
83
72
84
static void wdt_config (uint32_t timeout , watchdog_watchdogmode_t mode ) {
Original file line number Diff line number Diff line change 33
33
#include "py/objproperty.h"
34
34
#include "py/runtime.h"
35
35
36
- #include "common-hal/watchdog/WatchDogTimer .h"
36
+ #include "shared/runtime/pyexec .h"
37
37
38
38
#include "shared-bindings/microcontroller/__init__.h"
39
39
#include "shared-bindings/watchdog/__init__.h"
40
40
#include "shared-bindings/watchdog/WatchDogTimer.h"
41
41
42
+ #include "common-hal/watchdog/WatchDogTimer.h"
43
+
42
44
#include "supervisor/port.h"
43
45
44
46
#include "nrf/timers.h"
@@ -108,7 +110,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
108
110
}
109
111
110
112
void 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 );
112
123
}
113
124
114
125
mp_float_t common_hal_watchdog_get_timeout (watchdog_watchdogtimer_obj_t * self ) {
Original file line number Diff line number Diff line change 25
25
*/
26
26
27
27
#include "py/runtime.h"
28
- #include "common-hal/watchdog/WatchDogTimer.h"
28
+
29
+ #include "shared/runtime/pyexec.h"
29
30
30
31
#include "shared-bindings/watchdog/__init__.h"
31
32
#include "shared-bindings/microcontroller/__init__.h"
32
33
33
- #include "src/rp2_common/hardware_watchdog/include/hardware/watchdog.h"
34
+ #include "common-hal/watchdog/WatchDogTimer.h"
35
+
36
+ #include "hardware/watchdog.h"
34
37
35
38
#define WATCHDOG_ENABLE watchdog_enable(self->timeout * 1000, false)
36
39
@@ -47,7 +50,16 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
47
50
}
48
51
49
52
void 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 );
51
63
}
52
64
53
65
mp_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;
67
67
int pyexec_exit_handler (const void * source , pyexec_result_t * result );
68
68
#endif
69
69
70
+ #if CIRCUITPY_WATCHDOG
71
+ pyexec_result_t * pyexec_result (void );
72
+ #endif
73
+
70
74
#if MICROPY_REPL_INFO
71
75
mp_obj_t pyb_set_repl_info (mp_obj_t o_value );
72
76
MP_DECLARE_CONST_FUN_OBJ_1 (pyb_set_repl_info_obj );
You can’t perform that action at this time.
0 commit comments