aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-07-10 13:35:31 +0200
committerStephane D'Alu <sdalu@sdalu.com>2016-07-10 13:35:31 +0200
commit9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1 (patch)
tree3c3960a7899dc7105679ad84b1786935017392e7 /demos
parent7e8e69551fc85ee5683a0c1e9a6675e5d7f3496c (diff)
downloadChibiOS-Contrib-9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1.tar.gz
ChibiOS-Contrib-9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1.tar.bz2
ChibiOS-Contrib-9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1.zip
moved wdg to LLD
Diffstat (limited to 'demos')
-rw-r--r--demos/NRF52/Classic/halconf.h7
-rw-r--r--demos/NRF52/Classic/main.c52
-rw-r--r--demos/NRF52/Classic/mcuconf.h3
3 files changed, 57 insertions, 5 deletions
diff --git a/demos/NRF52/Classic/halconf.h b/demos/NRF52/Classic/halconf.h
index 976c634..e218263 100644
--- a/demos/NRF52/Classic/halconf.h
+++ b/demos/NRF52/Classic/halconf.h
@@ -156,6 +156,13 @@
#define HAL_USE_USB FALSE
#endif
+/**
+ * @brief Enables the WDG subsystem.
+ */
+#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
+#define HAL_USE_WDG TRUE
+#endif
+
/*===========================================================================*/
/* ADC driver related settings. */
/*===========================================================================*/
diff --git a/demos/NRF52/Classic/main.c b/demos/NRF52/Classic/main.c
index efa6591..fde485a 100644
--- a/demos/NRF52/Classic/main.c
+++ b/demos/NRF52/Classic/main.c
@@ -10,6 +10,21 @@
#define LED_EXT 14
+bool watchdog_started = false;
+
+void watchdog_callback(void) {
+ palTogglePad(IOPORT1, LED2);
+ palTogglePad(IOPORT1, LED3);
+ palTogglePad(IOPORT1, LED4);
+}
+
+WDGConfig WDG_config = {
+ .pause_on_sleep = 0,
+ .pause_on_halt = 0,
+ .timeout_ms = 5000,
+ .callback = watchdog_callback,
+};
+
/*
* Command Random
@@ -49,10 +64,31 @@ static void cmd_random(BaseSequentialStream *chp, int argc, char *argv[]) {
+
+static void cmd_watchdog(BaseSequentialStream *chp, int argc, char *argv[]) {
+ if ((argc == 0) || (strcmp(argv[0], "start"))) {
+ chprintf(chp, "Usage: watchdog start\r\n");
+ return;
+ }
+ chprintf(chp,
+ "Watchdog started\r\n"
+ "You need to push BTN1 every 5 seconds\r\n");
+
+ watchdog_started = true;
+ wdgStart(&WDGD1, &WDG_config);
+}
+
+
+
+
+
+
+
static THD_WORKING_AREA(shell_wa, 1024);
static const ShellCommand commands[] = {
- {"random", cmd_random},
+ {"random", cmd_random },
+ {"watchdog", cmd_watchdog },
{NULL, NULL}
};
@@ -73,6 +109,10 @@ static SerialConfig serial_config = {
+
+
+
+
static THD_WORKING_AREA(waThread1, 64);
static THD_FUNCTION(Thread1, arg) {
@@ -135,11 +175,13 @@ int main(void)
test_execute((BaseSequentialStream *)&SD1);
while (true) {
- chThdSleepMilliseconds(100);
-
+ if (watchdog_started &&
+ (palReadPad(IOPORT1, BTN1) == 0)) {
+ palTogglePad(IOPORT1, LED1);
+ wdgReset(&WDGD1);
+ }
+ chThdSleepMilliseconds(250);
}
-
-
}
diff --git a/demos/NRF52/Classic/mcuconf.h b/demos/NRF52/Classic/mcuconf.h
index 9961da0..c73c34e 100644
--- a/demos/NRF52/Classic/mcuconf.h
+++ b/demos/NRF52/Classic/mcuconf.h
@@ -46,4 +46,7 @@
#define NRF5_RNG_USE_RNG0 TRUE
+#define WDG_USE_TIMEOUT_CALLBACK TRUE
+
+
#endif /* _MCUCONF_H_ */