aboutsummaryrefslogtreecommitdiffstats
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
parent7e8e69551fc85ee5683a0c1e9a6675e5d7f3496c (diff)
downloadChibiOS-Contrib-9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1.tar.gz
ChibiOS-Contrib-9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1.tar.bz2
ChibiOS-Contrib-9cf4f9dfc7f6bcd1c46c96d9e388bf677e7148f1.zip
moved wdg to LLD
-rw-r--r--demos/NRF52/Classic/halconf.h7
-rw-r--r--demos/NRF52/Classic/main.c52
-rw-r--r--demos/NRF52/Classic/mcuconf.h3
-rw-r--r--os/hal/ports/NRF5/NRF51822/platform.mk4
-rw-r--r--os/hal/ports/NRF5/NRF52832/platform.mk4
-rw-r--r--testhal/NRF51/NRF51822/WDG/main.c8
6 files changed, 67 insertions, 11 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_ */
diff --git a/os/hal/ports/NRF5/NRF51822/platform.mk b/os/hal/ports/NRF5/NRF51822/platform.mk
index eff2f20..9ddbeee 100644
--- a/os/hal/ports/NRF5/NRF51822/platform.mk
+++ b/os/hal/ports/NRF5/NRF51822/platform.mk
@@ -29,7 +29,7 @@ ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),)
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c
endif
ifneq ($(findstring HAL_USE_WDG TRUE,$(HALCONF)),)
-PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c
+PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c
endif
ifneq ($(findstring HAL_USE_RNG TRUE,$(HALCONF)),)
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c
@@ -52,7 +52,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_adc_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c \
- ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c \
+ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_pwm_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_qei_lld.c
diff --git a/os/hal/ports/NRF5/NRF52832/platform.mk b/os/hal/ports/NRF5/NRF52832/platform.mk
index 855752c..fd3912c 100644
--- a/os/hal/ports/NRF5/NRF52832/platform.mk
+++ b/os/hal/ports/NRF5/NRF52832/platform.mk
@@ -12,6 +12,9 @@ endif
ifneq ($(findstring HAL_USE_SERIAL TRUE,$(HALCONF)),)
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c
endif
+ifneq ($(findstring HAL_USE_WDG TRUE,$(HALCONF)),)
+PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c
+endif
ifneq ($(findstring HAL_USE_RNG TRUE,$(HALCONF)),)
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c
endif
@@ -21,6 +24,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_pal_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_st_lld.c \
+ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c
endif
diff --git a/testhal/NRF51/NRF51822/WDG/main.c b/testhal/NRF51/NRF51822/WDG/main.c
index cdbf89b..92942b9 100644
--- a/testhal/NRF51/NRF51822/WDG/main.c
+++ b/testhal/NRF51/NRF51822/WDG/main.c
@@ -40,10 +40,10 @@ int main(void) {
palSetPad(IOPORT1, LED1);
WDGConfig WDG_config = {
- .flags.pause_on_sleep = 0,
- .flags.pause_on_halt = 0,
- .timeout_ms = 5000,
- .callback = timeout_callback
+ .pause_on_sleep = 0,
+ .pause_on_halt = 0,
+ .timeout_ms = 5000,
+ .callback = timeout_callback
};
wdgStart(&WDGD1, &WDG_config);