summaryrefslogtreecommitdiff
path: root/shared-bindings/watchdog
diff options
context:
space:
mode:
authorSean Cross <sean@xobs.io>2020-05-21 13:47:23 +0800
committerSean Cross <sean@xobs.io>2020-05-27 11:28:49 +0800
commit595f6387c2a4f1c919cfab80b07493820ac0051b (patch)
tree40e96e0fcf52ced0cf6dc48bc3aef317af3f58a4 /shared-bindings/watchdog
parentc23f151b6b64011a97752b85e97d1d06b70b73d4 (diff)
watchdog: rename module from `wdt` and move to `microcontroller`
This also places it under the `microcontroller` object. Signed-off-by: Sean Cross <sean@xobs.io>
Diffstat (limited to 'shared-bindings/watchdog')
-rw-r--r--shared-bindings/watchdog/WatchDogTimer.c0
-rw-r--r--shared-bindings/watchdog/WatchDogTimer.h45
-rw-r--r--shared-bindings/watchdog/__init__.c66
-rw-r--r--shared-bindings/watchdog/__init__.h32
4 files changed, 143 insertions, 0 deletions
diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/shared-bindings/watchdog/WatchDogTimer.c
diff --git a/shared-bindings/watchdog/WatchDogTimer.h b/shared-bindings/watchdog/WatchDogTimer.h
new file mode 100644
index 000000000..375ca653d
--- /dev/null
+++ b/shared-bindings/watchdog/WatchDogTimer.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Noralf Trønnes
+ *
+ * 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_BINDINGS_WATCHDOG_WATCHDOGTIMER_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG_WATCHDOGTIMER_H
+
+#include <py/obj.h>
+
+// extern void common_hal_wdt_init(uint32_t duration, bool pause_during_sleep);
+// extern void common_hal_wdt_feed(void);
+// extern void common_hal_wdt_disable(void);
+
+
+// typedef struct _wdt_wdt_obj_t {
+// mp_obj_base_t base;
+// uint32_t timeout;
+// bool sleep;
+// } wdt_wdt_obj_t;
+
+extern const mp_obj_type_t watchdog_watchdogtimer_type;
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG_WATCHDOGTIMER_H
diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c
new file mode 100644
index 000000000..8289bb88a
--- /dev/null
+++ b/shared-bindings/watchdog/__init__.c
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Paul Sokolovsky
+ *
+ * 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 <string.h>
+
+#include "py/runtime.h"
+#include "shared-bindings/watchdog/__init__.h"
+// #include "shared-bindings/wdt/WDT.h"
+
+//| """Watchdog Timer
+//|
+//| The `watchdog` module provides support for a Watchdog Timer. This timer will reset the device
+//| if it hasn't been fed after a specified amount of time. This is useful to ensure the board
+//| has not crashed or locked up. You can enable the watchdog timer using :class:`wdt.WDT`.
+//| Note that on some platforms the watchdog timer cannot be disabled once it has been enabled.
+//|
+//| The WatchDogTimer is used to restart the system when the application crashes and ends
+//| up into a non recoverable state. Once started it cannot be stopped or
+//| reconfigured in any way. After enabling, the application must "feed" the
+//| watchdog periodically to prevent it from expiring and resetting the system.
+//|
+//| Note that this module can't be imported and used directly. The sole
+//| instance of :class:`WatchDogTimer` is available at
+//| :attr:`microcontroller.watchdog`."""
+//|
+//| Example usage::
+//|
+//| from microcontroller.watchdog import WatchDogTimer
+//| wdt = WatchDogTimer(timeout=2.5) # enable it with a timeout of 2.5 seconds
+//| wdt.feed()"""
+//|
+
+// STATIC const mp_rom_map_elem_t wdt_module_globals_table[] = {
+// { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wdt) },
+// { MP_ROM_QSTR(MP_QSTR_WDT), MP_ROM_PTR(&wdt_wdt_type) },
+// };
+
+// STATIC MP_DEFINE_CONST_DICT(wdt_module_globals, wdt_module_globals_table);
+
+// const mp_obj_module_t wdt_module = {
+// .base = { &mp_type_module },
+// .globals = (mp_obj_dict_t*)&wdt_module_globals,
+// };
diff --git a/shared-bindings/watchdog/__init__.h b/shared-bindings/watchdog/__init__.h
new file mode 100644
index 000000000..90426c1e6
--- /dev/null
+++ b/shared-bindings/watchdog/__init__.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
+ *
+ * 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_BINDINGS_WATCHDOG___INIT___H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG___INIT___H
+
+extern const mp_obj_type_t watchdog_type;
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG___INIT___H