implement suggested changes

- update the docs
- split out common `watchdog_reset`
- revert to using `None` instead of `WatchDogMode.NONE`
This commit is contained in:
MicroDev 2023-09-24 15:23:38 +00:00 committed by GitHub
parent 05812e0618
commit 27fd60d739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 117 additions and 104 deletions

View File

@ -200,6 +200,10 @@ msgstr ""
msgid "%q must be <= %u" msgid "%q must be <= %u"
msgstr "" msgstr ""
#: py/argcheck.c
msgid "%q must be >= %d"
msgstr ""
#: shared-bindings/analogbufio/BufferedIn.c #: shared-bindings/analogbufio/BufferedIn.c
msgid "%q must be a bytearray or array of type 'H' or 'B'" msgid "%q must be a bytearray or array of type 'H' or 'B'"
msgstr "" msgstr ""
@ -447,10 +451,6 @@ msgstr ""
msgid "A hardware interrupt channel is already in use" msgid "A hardware interrupt channel is already in use"
msgstr "" msgstr ""
#: ports/espressif/common-hal/analogio/AnalogIn.c
msgid "ADC2 is being used by WiFi"
msgstr ""
#: ports/raspberrypi/common-hal/wifi/Radio.c #: ports/raspberrypi/common-hal/wifi/Radio.c
msgid "AP could not be started" msgid "AP could not be started"
msgstr "" msgstr ""
@ -4185,7 +4185,8 @@ msgstr ""
msgid "unexpected keyword argument" msgid "unexpected keyword argument"
msgstr "" msgstr ""
#: py/bc.c py/objnamedtuple.c shared-bindings/traceback/__init__.c #: py/argcheck.c py/bc.c py/objnamedtuple.c
#: shared-bindings/traceback/__init__.c
msgid "unexpected keyword argument '%q'" msgid "unexpected keyword argument '%q'"
msgstr "" msgstr ""
@ -4279,10 +4280,6 @@ msgstr ""
msgid "value out of range of target" msgid "value out of range of target"
msgstr "" msgstr ""
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
msgid "watchdog not initialized"
msgstr ""
#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/is31fl3741/FrameBuffer.c
msgid "width must be greater than zero" msgid "width must be greater than zero"
msgstr "" msgstr ""

View File

@ -28,8 +28,6 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "shared/runtime/pyexec.h"
#include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
@ -82,19 +80,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
self->mode = WATCHDOGMODE_NONE; self->mode = WATCHDOGMODE_NONE;
} }
void watchdog_reset(void) {
watchdog_watchdogtimer_obj_t *self = &common_hal_mcu_watchdogtimer_obj;
if (self->mode == WATCHDOGMODE_RESET) {
mp_obj_t exception = pyexec_result()->exception;
if (exception != MP_OBJ_NULL &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
return;
}
}
common_hal_watchdog_deinit(self);
}
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
return self->timeout; return self->timeout;
} }

View File

@ -28,6 +28,9 @@
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
#include "py/obj.h" #include "py/obj.h"
#include "shared-module/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
watchdog_watchdogmode_t mode; watchdog_watchdogmode_t mode;
}; };
// This needs to be called in order to disable the watchdog
void watchdog_reset(void);
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

View File

@ -26,8 +26,6 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "shared/runtime/pyexec.h"
#include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/watchdog/__init__.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
@ -68,19 +66,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
} }
} }
void watchdog_reset(void) {
watchdog_watchdogtimer_obj_t *self = &common_hal_mcu_watchdogtimer_obj;
if (self->mode == WATCHDOGMODE_RESET) {
mp_obj_t exception = pyexec_result()->exception;
if (exception != MP_OBJ_NULL &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
return;
}
}
common_hal_watchdog_deinit(self);
}
static void wdt_config(uint32_t timeout, watchdog_watchdogmode_t mode) { static void wdt_config(uint32_t timeout, watchdog_watchdogmode_t mode) {
// enable panic hanler in WATCHDOGMODE_RESET mode // enable panic hanler in WATCHDOGMODE_RESET mode
// initialize Task Watchdog Timer (TWDT) // initialize Task Watchdog Timer (TWDT)

View File

@ -28,6 +28,9 @@
#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
#include "py/obj.h" #include "py/obj.h"
#include "shared-module/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
watchdog_watchdogmode_t mode; watchdog_watchdogmode_t mode;
}; };
// This needs to be called in order to disable the watchdog
void watchdog_reset(void);
#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

View File

@ -33,8 +33,6 @@
#include "py/objproperty.h" #include "py/objproperty.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "shared/runtime/pyexec.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
@ -109,19 +107,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
self->mode = WATCHDOGMODE_NONE; self->mode = WATCHDOGMODE_NONE;
} }
void watchdog_reset(void) {
watchdog_watchdogtimer_obj_t *self = &common_hal_mcu_watchdogtimer_obj;
if (self->mode == WATCHDOGMODE_RESET) {
mp_obj_t exception = pyexec_result()->exception;
if (exception != MP_OBJ_NULL &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
return;
}
}
common_hal_watchdog_deinit(self);
}
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
return self->timeout; return self->timeout;
} }

View File

@ -28,6 +28,9 @@
#define MICROPY_INCLUDED_NRF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #define MICROPY_INCLUDED_NRF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
#include "py/obj.h" #include "py/obj.h"
#include "shared-module/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
@ -37,8 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
watchdog_watchdogmode_t mode; 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.
void watchdog_reset(void);
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

View File

@ -26,8 +26,6 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "shared/runtime/pyexec.h"
#include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/watchdog/__init__.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
@ -49,19 +47,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
self->mode = WATCHDOGMODE_NONE; self->mode = WATCHDOGMODE_NONE;
} }
void watchdog_reset(void) {
watchdog_watchdogtimer_obj_t *self = &common_hal_mcu_watchdogtimer_obj;
if (self->mode == WATCHDOGMODE_RESET) {
mp_obj_t exception = pyexec_result()->exception;
if (exception != MP_OBJ_NULL &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
return;
}
}
common_hal_watchdog_deinit(self);
}
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
return self->timeout; return self->timeout;
} }

View File

@ -28,6 +28,9 @@
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
#include "py/obj.h" #include "py/obj.h"
#include "shared-module/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
watchdog_watchdogmode_t mode; watchdog_watchdogmode_t mode;
}; };
// This needs to be called in order to disable the watchdog
void watchdog_reset(void);
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

View File

@ -41,10 +41,6 @@ void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
WDOG_Enable(false); WDOG_Enable(false);
} }
void watchdog_reset(void) {
common_hal_watchdog_deinit(&common_hal_mcu_watchdogtimer_obj);
}
mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) {
return self->timeout; return self->timeout;
} }

View File

@ -28,6 +28,9 @@
#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H
#include "py/obj.h" #include "py/obj.h"
#include "shared-module/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
#include "shared-bindings/watchdog/WatchDogTimer.h" #include "shared-bindings/watchdog/WatchDogTimer.h"
@ -37,7 +40,4 @@ struct _watchdog_watchdogtimer_obj_t {
watchdog_watchdogmode_t mode; watchdog_watchdogmode_t mode;
}; };
// This needs to be called in order to disable the watchdog
void watchdog_reset(void);
#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H #endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

View File

@ -192,6 +192,10 @@ void reset_port(void) {
#if CIRCUITPY_RTC #if CIRCUITPY_RTC
rtc_reset(); rtc_reset();
#endif #endif
#if CIRCUITPY_WATCHDOG
watchdog_reset();
#endif
} }
void reset_to_bootloader(void) { void reset_to_bootloader(void) {

View File

@ -666,6 +666,7 @@ SRC_SHARED_MODULE_ALL = \
usb/core/__init__.c \ usb/core/__init__.c \
usb/core/Device.c \ usb/core/Device.c \
ustack/__init__.c \ ustack/__init__.c \
watchdog/__init__.c \
zlib/__init__.c \ zlib/__init__.c \
vectorio/Circle.c \ vectorio/Circle.c \
vectorio/Polygon.c \ vectorio/Polygon.c \

View File

@ -28,16 +28,12 @@
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, NONE, WATCHDOGMODE_NONE);
MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, RAISE, WATCHDOGMODE_RAISE); MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, RAISE, WATCHDOGMODE_RAISE);
MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, RESET, WATCHDOGMODE_RESET); MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, RESET, WATCHDOGMODE_RESET);
//| class WatchDogMode: //| class WatchDogMode:
//| """Run state of the watchdog timer.""" //| """Run state of the watchdog timer."""
//| //|
//| NONE: WatchDogMode
//| """The `WatchDogTimer` is disabled."""
//|
//| RAISE: WatchDogMode //| RAISE: WatchDogMode
//| """Raise an exception when the `WatchDogTimer` expires.""" //| """Raise an exception when the `WatchDogTimer` expires."""
//| //|
@ -45,7 +41,6 @@ MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, RESET, WATCHDOGMODE_RE
//| """Reset the system when the `WatchDogTimer` expires.""" //| """Reset the system when the `WatchDogTimer` expires."""
//| //|
MAKE_ENUM_MAP(watchdog_watchdogmode) { MAKE_ENUM_MAP(watchdog_watchdogmode) {
MAKE_ENUM_MAP_ENTRY(watchdogmode, NONE),
MAKE_ENUM_MAP_ENTRY(watchdogmode, RAISE), MAKE_ENUM_MAP_ENTRY(watchdogmode, RAISE),
MAKE_ENUM_MAP_ENTRY(watchdogmode, RESET), MAKE_ENUM_MAP_ENTRY(watchdogmode, RESET),
}; };

View File

@ -71,8 +71,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watch
//| //|
//| :raises RuntimeError: if the watchdog timer cannot be disabled on this platform. //| :raises RuntimeError: if the watchdog timer cannot be disabled on this platform.
//| //|
//| .. note:: This is deprecated in ``8.1.0`` and will be removed in ``9.0.0``. //| .. note:: This is deprecated in ``9.0.0`` and will be removed in ``10.0.0``.
//| Set watchdog `mode` to `WatchDogMode.NONE` instead. //| Set watchdog `mode` to `None` instead.
//| //|
//| """ //| """
//| ... //| ...
@ -107,16 +107,17 @@ MP_PROPERTY_GETSET(watchdog_watchdogtimer_timeout_obj,
(mp_obj_t)&watchdog_watchdogtimer_get_timeout_obj, (mp_obj_t)&watchdog_watchdogtimer_get_timeout_obj,
(mp_obj_t)&watchdog_watchdogtimer_set_timeout_obj); (mp_obj_t)&watchdog_watchdogtimer_set_timeout_obj);
//| mode: WatchDogMode //| mode: Optional[WatchDogMode]
//| """The current operating mode of the WatchDogTimer `watchdog.WatchDogMode`. //| """The current operating mode of the WatchDogTimer `watchdog.WatchDogMode` or `None` when
//| the timer is disabled.
//| //|
//| Setting a `WatchDogMode` activates the WatchDog:: //| Setting a `WatchDogMode` activates the WatchDog::
//| //|
//| from microcontroller import watchdog as w //| from microcontroller import watchdog
//| from watchdog import WatchDogMode //| from watchdog import WatchDogMode
//| //|
//| w.timeout = 5 //| watchdog.timeout = 5
//| w.mode = WatchDogMode.RESET //| watchdog.mode = WatchDogMode.RESET
//| //|
//| //|
//| Once set, the `WatchDogTimer` will perform the specified action if the timer expires.""" //| Once set, the `WatchDogTimer` will perform the specified action if the timer expires."""
@ -129,7 +130,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_get_mode_obj, watchdog_watchdog
STATIC mp_obj_t watchdog_watchdogtimer_obj_set_mode(mp_obj_t self_in, mp_obj_t obj) { STATIC mp_obj_t watchdog_watchdogtimer_obj_set_mode(mp_obj_t self_in, mp_obj_t obj) {
watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_watchdog_set_mode(self, cp_enum_value(&watchdog_watchdogmode_type, obj, MP_QSTR_mode)); watchdog_watchdogmode_t mode = (obj == mp_const_none) ? WATCHDOGMODE_NONE : cp_enum_value(&watchdog_watchdogmode_type, obj, MP_QSTR_mode);
common_hal_watchdog_set_mode(self, mode);
return mp_const_none; return mp_const_none;
} }
MP_DEFINE_CONST_FUN_OBJ_2(watchdog_watchdogtimer_set_mode_obj, watchdog_watchdogtimer_obj_set_mode); MP_DEFINE_CONST_FUN_OBJ_2(watchdog_watchdogtimer_set_mode_obj, watchdog_watchdogtimer_obj_set_mode);

View File

@ -27,14 +27,14 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG_WATCHDOGTIMER_H #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG_WATCHDOGTIMER_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG_WATCHDOGTIMER_H #define MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG_WATCHDOGTIMER_H
#include <py/obj.h> #include "py/obj.h"
#include "shared-bindings/watchdog/WatchDogMode.h" #include "shared-bindings/watchdog/WatchDogMode.h"
typedef struct _watchdog_watchdogtimer_obj_t watchdog_watchdogtimer_obj_t; typedef struct _watchdog_watchdogtimer_obj_t watchdog_watchdogtimer_obj_t;
extern void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self); extern void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self);
extern void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_watchdogmode_t); extern void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_watchdogmode_t mode);
extern watchdog_watchdogmode_t common_hal_watchdog_get_mode(watchdog_watchdogtimer_obj_t *self); extern watchdog_watchdogmode_t common_hal_watchdog_get_mode(watchdog_watchdogtimer_obj_t *self);
extern void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_float_t timeout); extern void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_float_t timeout);

View File

@ -0,0 +1,47 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2023 MicroDev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/runtime.h"
#include "shared/runtime/pyexec.h"
#include "shared-module/watchdog/__init__.h"
#include "shared-bindings/watchdog/WatchDogTimer.h"
#include "shared-bindings/microcontroller/__init__.h"
void watchdog_reset(void) {
watchdog_watchdogtimer_obj_t *self = &common_hal_mcu_watchdogtimer_obj;
if (self->mode == WATCHDOGMODE_RESET) {
mp_obj_t exception = pyexec_result()->exception;
if (exception != MP_OBJ_NULL &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) &&
exception != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
return;
}
}
common_hal_watchdog_deinit(self);
}

View File

@ -0,0 +1,32 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2023 MicroDev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_MODULE_WATCHDOG___INIT___H
#define MICROPY_INCLUDED_SHARED_MODULE_WATCHDOG___INIT___H
extern void watchdog_reset(void);
#endif // MICROPY_INCLUDED_SHARED_MODULE_WATCHDOG___INIT___H