Skip to content

Commit 27fd60d

Browse files
authored
implement suggested changes
- update the docs - split out common `watchdog_reset` - revert to using `None` instead of `WatchDogMode.NONE`
1 parent 05812e0 commit 27fd60d

File tree

18 files changed

+117
-104
lines changed

18 files changed

+117
-104
lines changed

locale/circuitpython.pot

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ msgstr ""
200200
msgid "%q must be <= %u"
201201
msgstr ""
202202

203+
#: py/argcheck.c
204+
msgid "%q must be >= %d"
205+
msgstr ""
206+
203207
#: shared-bindings/analogbufio/BufferedIn.c
204208
msgid "%q must be a bytearray or array of type 'H' or 'B'"
205209
msgstr ""
@@ -447,10 +451,6 @@ msgstr ""
447451
msgid "A hardware interrupt channel is already in use"
448452
msgstr ""
449453

450-
#: ports/espressif/common-hal/analogio/AnalogIn.c
451-
msgid "ADC2 is being used by WiFi"
452-
msgstr ""
453-
454454
#: ports/raspberrypi/common-hal/wifi/Radio.c
455455
msgid "AP could not be started"
456456
msgstr ""
@@ -4185,7 +4185,8 @@ msgstr ""
41854185
msgid "unexpected keyword argument"
41864186
msgstr ""
41874187

4188-
#: py/bc.c py/objnamedtuple.c shared-bindings/traceback/__init__.c
4188+
#: py/argcheck.c py/bc.c py/objnamedtuple.c
4189+
#: shared-bindings/traceback/__init__.c
41894190
msgid "unexpected keyword argument '%q'"
41904191
msgstr ""
41914192

@@ -4279,10 +4280,6 @@ msgstr ""
42794280
msgid "value out of range of target"
42804281
msgstr ""
42814282

4282-
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
4283-
msgid "watchdog not initialized"
4284-
msgstr ""
4285-
42864283
#: shared-bindings/is31fl3741/FrameBuffer.c
42874284
msgid "width must be greater than zero"
42884285
msgstr ""

ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
#include "py/runtime.h"
3030

31-
#include "shared/runtime/pyexec.h"
32-
3331
#include "shared-bindings/watchdog/__init__.h"
3432
#include "shared-bindings/watchdog/WatchDogTimer.h"
3533
#include "shared-bindings/microcontroller/__init__.h"
@@ -82,19 +80,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
8280
self->mode = WATCHDOGMODE_NONE;
8381
}
8482

85-
void watchdog_reset(void) {
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);
96-
}
97-
9883
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
9984
return self->timeout;
10085
}

ports/atmel-samd/common-hal/watchdog/WatchDogTimer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
2929

3030
#include "py/obj.h"
31+
32+
#include "shared-module/watchdog/__init__.h"
33+
3134
#include "shared-bindings/watchdog/WatchDogMode.h"
3235
#include "shared-bindings/watchdog/WatchDogTimer.h"
3336

@@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
3740
watchdog_watchdogmode_t mode;
3841
};
3942

40-
// This needs to be called in order to disable the watchdog
41-
void watchdog_reset(void);
42-
4343
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

ports/espressif/common-hal/watchdog/WatchDogTimer.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
#include "py/runtime.h"
2828

29-
#include "shared/runtime/pyexec.h"
30-
3129
#include "shared-bindings/watchdog/__init__.h"
3230
#include "shared-bindings/microcontroller/__init__.h"
3331

@@ -68,19 +66,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
6866
}
6967
}
7068

71-
void watchdog_reset(void) {
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);
82-
}
83-
8469
static void wdt_config(uint32_t timeout, watchdog_watchdogmode_t mode) {
8570
// enable panic hanler in WATCHDOGMODE_RESET mode
8671
// initialize Task Watchdog Timer (TWDT)

ports/espressif/common-hal/watchdog/WatchDogTimer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
2929

3030
#include "py/obj.h"
31+
32+
#include "shared-module/watchdog/__init__.h"
33+
3134
#include "shared-bindings/watchdog/WatchDogMode.h"
3235
#include "shared-bindings/watchdog/WatchDogTimer.h"
3336

@@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
3740
watchdog_watchdogmode_t mode;
3841
};
3942

40-
// This needs to be called in order to disable the watchdog
41-
void watchdog_reset(void);
42-
4343
#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

ports/nrf/common-hal/watchdog/WatchDogTimer.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include "py/objproperty.h"
3434
#include "py/runtime.h"
3535

36-
#include "shared/runtime/pyexec.h"
37-
3836
#include "shared-bindings/microcontroller/__init__.h"
3937
#include "shared-bindings/watchdog/__init__.h"
4038
#include "shared-bindings/watchdog/WatchDogTimer.h"
@@ -109,19 +107,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
109107
self->mode = WATCHDOGMODE_NONE;
110108
}
111109

112-
void watchdog_reset(void) {
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);
123-
}
124-
125110
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
126111
return self->timeout;
127112
}

ports/nrf/common-hal/watchdog/WatchDogTimer.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#define MICROPY_INCLUDED_NRF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
2929

3030
#include "py/obj.h"
31+
32+
#include "shared-module/watchdog/__init__.h"
33+
3134
#include "shared-bindings/watchdog/WatchDogMode.h"
3235
#include "shared-bindings/watchdog/WatchDogTimer.h"
3336

@@ -37,8 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
3740
watchdog_watchdogmode_t mode;
3841
};
3942

40-
// This needs to be called in order to disable the watchdog if it's set to
41-
// "RAISE". If set to "RESET", then the watchdog cannot be reset.
42-
void watchdog_reset(void);
43-
4443
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
#include "py/runtime.h"
2828

29-
#include "shared/runtime/pyexec.h"
30-
3129
#include "shared-bindings/watchdog/__init__.h"
3230
#include "shared-bindings/microcontroller/__init__.h"
3331

@@ -49,19 +47,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
4947
self->mode = WATCHDOGMODE_NONE;
5048
}
5149

52-
void watchdog_reset(void) {
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);
63-
}
64-
6550
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
6651
return self->timeout;
6752
}

ports/raspberrypi/common-hal/watchdog/WatchDogTimer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
2929

3030
#include "py/obj.h"
31+
32+
#include "shared-module/watchdog/__init__.h"
33+
3134
#include "shared-bindings/watchdog/WatchDogMode.h"
3235
#include "shared-bindings/watchdog/WatchDogTimer.h"
3336

@@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
3740
watchdog_watchdogmode_t mode;
3841
};
3942

40-
// This needs to be called in order to disable the watchdog
41-
void watchdog_reset(void);
42-
4343
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

ports/silabs/common-hal/watchdog/WatchDogTimer.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
4141
WDOG_Enable(false);
4242
}
4343

44-
void watchdog_reset(void) {
45-
common_hal_watchdog_deinit(&common_hal_mcu_watchdogtimer_obj);
46-
}
47-
4844
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
4945
return self->timeout;
5046
}

0 commit comments

Comments
 (0)