summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorSean Cross <sean@xobs.io>2020-05-20 20:08:07 +0800
committerSean Cross <sean@xobs.io>2020-05-27 11:28:48 +0800
commitf4719609f7af49697e4b7e0292fc520e39b26daf (patch)
treef9a7945bd0fdc620b5d6912b29ea8e503a91ee58 /py
parent17ef2df2cacc234e98f729ab60c3af9ec02dd08d (diff)
wdt: add watchdog support
This adds shared bindings for a watchdog timer, based on the API provided by micropython. Signed-off-by: Sean Cross <sean@xobs.io>
Diffstat (limited to 'py')
-rw-r--r--py/circuitpy_defns.mk7
-rw-r--r--py/circuitpy_mpconfig.h8
-rw-r--r--py/circuitpy_mpconfig.mk4
3 files changed, 18 insertions, 1 deletions
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 9e36f2e6a..be04dba48 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -241,6 +241,9 @@ endif
ifeq ($(CIRCUITPY_USTACK),1)
SRC_PATTERNS += ustack/%
endif
+ifeq ($(CIRCUITPY_WDT),1)
+SRC_PATTERNS += wdt/%
+endif
ifeq ($(CIRCUITPY_PEW),1)
SRC_PATTERNS += _pew/%
endif
@@ -301,7 +304,9 @@ SRC_COMMON_HAL_ALL = \
rtc/RTC.c \
rtc/__init__.c \
supervisor/Runtime.c \
- supervisor/__init__.c
+ supervisor/__init__.c \
+ wdt/__init__.c \
+ wdt/WDT.c \
SRC_COMMON_HAL = $(filter $(SRC_PATTERNS), $(SRC_COMMON_HAL_ALL))
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 5f2605c92..50f1139d7 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -630,6 +630,13 @@ extern const struct _mp_obj_module_t ustack_module;
#define RE_MODULE
#endif
+#if CIRCUITPY_WDT
+extern const struct _mp_obj_module_t wdt_module;
+#define WDT_MODULE { MP_ROM_QSTR(MP_QSTR_wdt), MP_ROM_PTR(&wdt_module) },
+#else
+#define WDT_MODULE
+#endif
+
// Define certain native modules with weak links so they can be replaced with Python
// implementations. This list may grow over time.
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
@@ -700,6 +707,7 @@ extern const struct _mp_obj_module_t ustack_module;
USB_HID_MODULE \
USB_MIDI_MODULE \
USTACK_MODULE \
+ WDT_MODULE \
// If weak links are enabled, just include strong links in the main list of modules,
// and also include the underscore alternate names.
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index 0801540bc..1b74f45c3 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -228,6 +228,10 @@ CFLAGS += -DCIRCUITPY_SERIAL_UART=$(CIRCUITPY_SERIAL_UART)
CIRCUITPY_ULAB ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_ULAB=$(CIRCUITPY_ULAB)
+# watchdog hardware support
+CIRCUITPY_WDT ?= 0
+CFLAGS += -DCIRCUITPY_WDT=$(CIRCUITPY_WDT)
+
# Enabled micropython.native decorator (experimental)
CIRCUITPY_ENABLE_MPY_NATIVE ?= 0
CFLAGS += -DCIRCUITPY_ENABLE_MPY_NATIVE=$(CIRCUITPY_ENABLE_MPY_NATIVE)