diff options
Diffstat (limited to 'os/hal/ports')
-rw-r--r-- | os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c | 15 | ||||
-rw-r--r-- | os/hal/ports/NRF5/NRF51822/hal_wdg_lld.h | 24 |
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;
|