WDT HAL

group nrf_wdt_hal

Hardware access layer for managing the Watchdog Timer (WDT) peripheral.

Defines

NRF_WDT_INST_GET(idx)

Macro getting pointer to the structure of registers of the WDT peripheral.

Parameters:
  • idx[in] WDT instance index.

Returns:

Pointer to the structure of registers of the WDT peripheral.

NRF_WDT_HAS_STOP

Presence of Task STOP functionality.

NRF_WDT_HAS_NMI

Presence of non-maskable interrupt configuration.

NRF_WDT_CHANNEL_NUMBER

Number of WDT channels.

NRF_WDT_RR_VALUE

WDT register reload value.

Enums

enum nrf_wdt_task_t

WDT tasks.

Values:

enumerator NRF_WDT_TASK_START

Task for starting WDT.

enumerator NRF_WDT_TASK_STOP

Task for stopping WDT.

enum nrf_wdt_event_t

WDT events.

Values:

enumerator NRF_WDT_EVENT_TIMEOUT

Event from WDT time-out.

enumerator NRF_WDT_EVENT_STOPPED

Event from WDT stop.

enum nrf_wdt_behaviour_mask_t

WDT behavior in the SLEEP or HALT CPU modes.

Values:

enumerator NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK

WDT will run when CPU is in SLEEP mode.

enumerator NRF_WDT_BEHAVIOUR_RUN_HALT_MASK

WDT will run when CPU is in HALT mode.

enumerator NRF_WDT_BEHAVIOUR_STOP_ENABLE_MASK

WDT allows stopping.

enum nrf_wdt_rr_register_t

WDT reload request registers.

Values:

enumerator NRF_WDT_RR0

Reload request register 0.

enumerator NRF_WDT_RR1

Reload request register 1.

enumerator NRF_WDT_RR2

Reload request register 2.

enumerator NRF_WDT_RR3

Reload request register 3.

enumerator NRF_WDT_RR4

Reload request register 4.

enumerator NRF_WDT_RR5

Reload request register 5.

enumerator NRF_WDT_RR6

Reload request register 6.

enumerator NRF_WDT_RR7

Reload request register 7.

enum nrf_wdt_rr_register_mask_t

WDT reload request registers mask.

Values:

enumerator NRF_WDT_RR0_MASK

Mask for reload request register 0.

enumerator NRF_WDT_RR1_MASK

Mask for reload request register 1.

enumerator NRF_WDT_RR2_MASK

Mask for reload request register 2.

enumerator NRF_WDT_RR3_MASK

Mask for reload request register 3.

enumerator NRF_WDT_RR4_MASK

Mask for reload request register 4.

enumerator NRF_WDT_RR5_MASK

Mask for reload request register 5.

enumerator NRF_WDT_RR6_MASK

Mask for reload request register 6.

enumerator NRF_WDT_RR7_MASK

Mask for reload request register 7.

enum nrf_wdt_int_mask_t

WDT interrupts.

Values:

enumerator NRF_WDT_INT_TIMEOUT_MASK

WDT interrupt from time-out event.

enumerator NRF_WDT_INT_STOPPED_MASK

WDT interrupt from stop event.

Functions

NRF_STATIC_INLINE void nrf_wdt_behaviour_set(NRF_WDT_Type *p_reg, uint32_t mask)

Function for configuring the watchdog behaviour when the CPU is sleeping or halted.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Watchdog behaviour mask, created using nrf_wdt_behaviour_mask_t.

NRF_STATIC_INLINE void nrf_wdt_task_trigger(NRF_WDT_Type *p_reg, nrf_wdt_task_t task)

Function for starting the WDT task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task.

NRF_STATIC_INLINE void nrf_wdt_event_clear(NRF_WDT_Type *p_reg, nrf_wdt_event_t event)

Function for clearing the WDT event register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event.

NRF_STATIC_INLINE bool nrf_wdt_event_check(NRF_WDT_Type const *p_reg, nrf_wdt_event_t event)

Function for retrieving the state of the WDT event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to be checked.

Return values:
  • true – The event has been generated.

  • false – The event has not been generated.

NRF_STATIC_INLINE void nrf_wdt_int_enable(NRF_WDT_Type *p_reg, uint32_t mask)

Function for enabling the specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be enabled. Use nrf_wdt_int_mask_t values for bit masking.

NRF_STATIC_INLINE uint32_t nrf_wdt_int_enable_check(NRF_WDT_Type const *p_reg, uint32_t mask)

Function for checking if the specified interrupts are enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be checked. Use nrf_wdt_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRF_STATIC_INLINE void nrf_wdt_int_disable(NRF_WDT_Type *p_reg, uint32_t mask)

Function for disabling the specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be disabled. Use nrf_wdt_int_mask_t values for bit masking.

NRF_STATIC_INLINE void nrf_wdt_nmi_int_enable(NRF_WDT_Type *p_reg, uint32_t mask)

Function for enabling the specified non-maskable interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be enabled. Use nrf_wdt_int_mask_t values for bit masking.

NRF_STATIC_INLINE uint32_t nrf_wdt_nmi_int_enable_check(NRF_WDT_Type const *p_reg, uint32_t mask)

Function for checking if the specified non-maskable interrupts are enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be checked. Use nrf_wdt_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRF_STATIC_INLINE void nrf_wdt_nmi_int_disable(NRF_WDT_Type *p_reg, uint32_t mask)

Function for disabling a specified non-maskable interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be disabled. Use nrf_wdt_int_mask_t values for bit masking.

NRF_STATIC_INLINE void nrf_wdt_subscribe_set(NRF_WDT_Type *p_reg, nrf_wdt_task_t task, uint8_t channel)

Function for setting the subscribe configuration for a given WDT task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task for which to set the configuration.

  • channel[in] Channel through which to subscribe events.

NRF_STATIC_INLINE void nrf_wdt_subscribe_clear(NRF_WDT_Type *p_reg, nrf_wdt_task_t task)

Function for clearing the subscribe configuration for a given WDT task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task for which to clear the configuration.

NRF_STATIC_INLINE void nrf_wdt_publish_set(NRF_WDT_Type *p_reg, nrf_wdt_event_t event, uint8_t channel)

Function for setting the publish configuration for a given WDT event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event for which to set the configuration.

  • channel[in] Channel through which to publish the event.

NRF_STATIC_INLINE void nrf_wdt_publish_clear(NRF_WDT_Type *p_reg, nrf_wdt_event_t event)

Function for clearing the publish configuration for a given WDT event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event for which to clear the configuration.

NRF_STATIC_INLINE uint32_t nrf_wdt_task_address_get(NRF_WDT_Type const *p_reg, nrf_wdt_task_t task)

Function for returning the address of a specific WDT task register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task.

Returns:

Address of requested task register.

NRF_STATIC_INLINE uint32_t nrf_wdt_event_address_get(NRF_WDT_Type const *p_reg, nrf_wdt_event_t event)

Function for returning the address of a specific WDT event register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event.

Returns:

Address of requested event register.

NRF_STATIC_INLINE bool nrf_wdt_started_check(NRF_WDT_Type const *p_reg)

Function for retrieving the watchdog status.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – The watchdog is started.

  • false – The watchdog is not started.

NRF_STATIC_INLINE bool nrf_wdt_request_status_check(NRF_WDT_Type const *p_reg, nrf_wdt_rr_register_t rr_register)

Function for retrieving the watchdog reload request status for specified register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • rr_register[in] Reload request register to be checked.

Return values:
  • true – Reload request is running.

  • false – No reload requests are running.

NRF_STATIC_INLINE uint32_t nrf_wdt_request_status_get(NRF_WDT_Type const *p_reg)

Function for retrieving the watchdog reload requests status mask.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Running reload requests mask, constructed with nrf_wdt_rr_register_mask_t.

NRF_STATIC_INLINE void nrf_wdt_reload_value_set(NRF_WDT_Type *p_reg, uint32_t reload_value)

Function for setting the watchdog reload value.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • reload_value[in] Watchdog counter initial value.

NRF_STATIC_INLINE uint32_t nrf_wdt_reload_value_get(NRF_WDT_Type const *p_reg)

Function for retrieving the watchdog reload value.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Reload value.

NRF_STATIC_INLINE void nrf_wdt_reload_request_enable(NRF_WDT_Type *p_reg, nrf_wdt_rr_register_t rr_register)

Function for enabling a specific reload request register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • rr_register[in] Reload request register to be enabled.

NRF_STATIC_INLINE void nrf_wdt_reload_request_disable(NRF_WDT_Type *p_reg, nrf_wdt_rr_register_t rr_register)

Function for disabling a specific reload request register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • rr_register[in] Reload request register to be disabled.

NRF_STATIC_INLINE bool nrf_wdt_reload_request_enable_check(NRF_WDT_Type const *p_reg, nrf_wdt_rr_register_t rr_register)

Function for retrieving the status of a specific reload request register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • rr_register[in] Reload request register to be checked.

Return values:
  • true – The reload request register is enabled.

  • false – The reload request register is not enabled.

NRF_STATIC_INLINE void nrf_wdt_reload_request_set(NRF_WDT_Type *p_reg, nrf_wdt_rr_register_t rr_register)

Function for setting a specific reload request register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • rr_register[in] Reload request register to set.

NRF_STATIC_INLINE void nrf_wdt_task_stop_enable_set(NRF_WDT_Type *p_reg, bool enable)

Function for enabling or disabling stopping the watchdog.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if stopping is to be enabled, false otherwise.