aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/NRF5/NRF51822
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-07-10 12:50:42 +0200
committerStephane D'Alu <sdalu@sdalu.com>2016-07-10 12:50:42 +0200
commit7150786277099793a90295e9ce16244e65e603dc (patch)
treec423f56191549d37559ec1d45617e83f666cc8e5 /os/hal/ports/NRF5/NRF51822
parent8feec2e235fc6f28cdcdf96bacdd842f6deeb1a5 (diff)
downloadChibiOS-Contrib-7150786277099793a90295e9ce16244e65e603dc.tar.gz
ChibiOS-Contrib-7150786277099793a90295e9ce16244e65e603dc.tar.bz2
ChibiOS-Contrib-7150786277099793a90295e9ce16244e65e603dc.zip
fixed pause behaviour (paused if set to 0 not 1)
Diffstat (limited to 'os/hal/ports/NRF5/NRF51822')
-rw-r--r--os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c15
-rw-r--r--os/hal/ports/NRF5/NRF51822/hal_wdg_lld.h24
2 files changed, 29 insertions, 10 deletions
diff --git a/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c b/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c
index 4e946ee..632ccde 100644
--- a/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c
+++ b/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c
@@ -15,8 +15,8 @@
*/
/**
- * @file NRF51822/wdg_lld.c
- * @brief WDG Driver subsystem low level driver source template.
+ * @file NRF5/LLD/hal_wdg_lld.c
+ * @brief NRF5 Watchdog Driver subsystem low level driver source template.
*
* @addtogroup WDG
* @{
@@ -106,13 +106,16 @@ void wdg_lld_start(WDGDriver *wdgp) {
#endif
/* When to pause? (halt, sleep) */
- wdgp->wdt->CONFIG =
- (wdgp->config->flags.pause_on_sleep * WDT_CONFIG_SLEEP_Msk) |
- (wdgp->config->flags.pause_on_halt * WDT_CONFIG_HALT_Msk );
+ uint32_t config = 0;
+ if (!wdgp->config->flags.pause_on_sleep)
+ config |= WDT_CONFIG_SLEEP_Msk;
+ if (!wdgp->config->flags.pause_on_halt)
+ config |= WDT_CONFIG_HALT_Msk;
+ wdgp->wdt->CONFIG = config;
/* Timeout in milli-seconds */
uint64_t tout = (NRF5_LFCLK_FREQUENCY * wdgp->config->timeout_ms / 1000) - 1;
- osalDbgAssert(tout <= 0xFFFFFFFF, "watchdog timout value exceeded");
+ osalDbgAssert(tout <= 0xFFFFFFFF, "watchdog timout value exceeded");
wdgp->wdt->CRV = (uint32_t)tout;
/* Reload request (using RR0) */
diff --git a/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.h b/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.h
index 7619e13..ea5b2f0 100644
--- a/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.h
+++ b/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.h
@@ -15,8 +15,8 @@
*/
/**
- * @file NRF51822/wdg_lld.h
- * @brief WDG Driver subsystem low level driver header template.
+ * @file NRF5/LLD/hal_wdg_lld.h
+ * @brief NRF5 Watchdog Driver subsystem low level driver header template.
*
* @addtogroup WDG
* @{
@@ -72,11 +72,27 @@ typedef struct WDGDriver WDGDriver;
*/
typedef struct {
struct {
- uint8_t pause_on_sleep : 1;
- uint8_t pause_on_halt : 1;
+ /**
+ * @brief Pause watchdog while the CPU is sleeping
+ */
+ uint8_t pause_on_sleep : 1;
+ /**
+ * @brief Pause watchdog while the CPU is halted by the debugger
+ */
+ uint8_t pause_on_halt : 1;
} flags;
+ /**
+ *
+ */
uint32_t timeout_ms;
#if WDG_USE_TIMEOUT_CALLBACK == TRUE
+ /**
+ * @brief Notification callback when watchdog timedout
+ *
+ * @note About 2 cycles at NRF5_LFCLK_FREQUENCY are available
+ * before automatic reboot.
+ *
+ */
void (*callback)(void);
#endif
} WDGConfig;