WDT driver

group nrfx_wdt

Watchdog Timer (WDT) peripheral driver.

Defines

NRFX_WDT_HAS_STOP

Symbol indicating whether watchdog stopping is supported.

NRFX_WDT_IRQ_CONFIG

WDT instance interrupt priority configuration.

NRFX_WDT_INSTANCE(id)

Macro for creating an instance of the WDT driver.

NRFX_WDT_DEFAULT_CONFIG

WDT driver default configuration.

This configuration sets up WDT with the following options:

  • run when CPU is in SLEEP mode, pause when in HALT mode

  • reload value: 2000 ms

NRFX_WDT_INST_HANDLER_GET(idx)

Macro returning WDT interrupt handler.

param[in] idx WDT index.

Returns:

Interrupt handler.

Typedefs

typedef void (*nrfx_wdt_event_handler_t)(nrf_wdt_event_t event_type, uint32_t requests, void *p_context)

WDT event handler function type.

Param event_type:

[in] WDT event.

Param requests:

[in] Value of the request status register. Bits that have been set can be used to determine which RR (Reload Request) register was the reason for timeout event. Valid only when NRF_WDT_EVENT_TIMEOUT is passed in event_type.

Param p_context:

[in] User context.

typedef nrf_wdt_rr_register_t nrfx_wdt_channel_id

WDT channel ID type.

Functions

nrfx_err_t nrfx_wdt_init(nrfx_wdt_t const *p_instance, nrfx_wdt_config_t const *p_config, nrfx_wdt_event_handler_t wdt_event_handler, void *p_context)

Function for initializing the WDT driver instance.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

  • p_config[in] Pointer to the structure with the initial configuration. NULL if configuration is to be skipped and will be done later using nrfx_wdt_reconfigure.

  • wdt_event_handler[in] Event handler provided by the user. Ignored when NRFX_WDT_CONFIG_NO_IRQ option is enabled.

  • p_context[in] User context passed in event handler. Ignored when NRFX_WDT_CONFIG_NO_IRQ option is enabled.

Return values:
  • NRFX_SUCCESS – Initialization was successful.

  • NRFX_ERROR_ALREADY – The driver is already initialized.

  • NRFX_ERROR_INVALID_STATE – The driver is already initialized. Deprecated - use NRFX_ERROR_ALREADY instead.

void nrfx_wdt_uninit(nrfx_wdt_t const *p_instance)

Function for uninitializing the WDT driver instance.

The instance can be uninitialized only when not running.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

bool nrfx_wdt_init_check(nrfx_wdt_t const *p_instance)

Function for checking if the WDT driver instance is initialized.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

Return values:
  • true – Instance is already initialized.

  • false – Instance is not initialized.

nrfx_err_t nrfx_wdt_reconfigure(nrfx_wdt_t const *p_instance, nrfx_wdt_config_t const *p_config)

Function for reconfiguring the watchdog.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

  • p_config[in] Pointer to the structure with the initial configuration.

Return values:
  • NRFX_SUCCESS – Reconfiguration was successful.

  • NRFX_ERROR_BUSY – The watchdog is already active.

  • NRFX_ERROR_INVALID_STATE – The watchdog is uninitialized.

nrfx_err_t nrfx_wdt_channel_alloc(nrfx_wdt_t const *p_instance, nrfx_wdt_channel_id *p_channel_id)

Function for allocating a watchdog channel.

Note

This function can not be called after nrfx_wdt_enable.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

  • p_channel_id[out] ID of granted channel.

Return values:
  • NRFX_SUCCESS – The channel was successfully allocated.

  • NRFX_ERROR_NO_MEM – There is no available channel to be used.

void nrfx_wdt_channels_free(nrfx_wdt_t const *p_instance)

Function for deallocating all previously allocated watchdog channels.

Note

This function can be called when watchdog is stopped, that is before nrfx_wdt_enable() or after nrfx_wdt_stop().

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

void nrfx_wdt_enable(nrfx_wdt_t const *p_instance)

Function for starting the watchdog.

Note

After calling this function the watchdog is started, so the user needs to feed all allocated watchdog channels to avoid reset. At least one watchdog channel must be allocated.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

void nrfx_wdt_feed(nrfx_wdt_t const *p_instance)

Function for feeding the watchdog.

Function feeds all allocated watchdog channels.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

void nrfx_wdt_channel_feed(nrfx_wdt_t const *p_instance, nrfx_wdt_channel_id channel_id)

Function for feeding an individual watchdog channel.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

  • channel_id[in] ID of watchdog channel.

nrfx_err_t nrfx_wdt_stop(nrfx_wdt_t const *p_instance)

Function for stopping the watchdog.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

Return values:
  • NRFX_SUCCESS – Watchdog has been successfully stopped.

  • NRFX_ERROR_FORBIDDEN – Configuration does not allow for stopping the watchdog.

NRFX_STATIC_INLINE uint32_t nrfx_wdt_task_address_get(nrfx_wdt_t const *p_instance, nrf_wdt_task_t task)

Function for returning a requested task address for the WDT driver module.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

  • task[in] One of the WDT tasks.

Returns:

Task address.

NRFX_STATIC_INLINE uint32_t nrfx_wdt_event_address_get(nrfx_wdt_t const *p_instance, nrf_wdt_event_t event)

Function for returning a requested event address for the WDT driver module.

Parameters:
  • p_instance[in] Pointer to the driver instance structure.

  • event[in] One of the WDT events.

Returns:

Event address.

struct nrfx_wdt_t
#include <nrfx_wdt.h>

Data structure of the Watchdog (WDT) driver instance.

Public Members

NRF_WDT_Type *p_reg

Pointer to a structure with WDT registers.

uint8_t drv_inst_idx

Index of the driver instance. For internal use only.

struct nrfx_wdt_config_t
#include <nrfx_wdt.h>

Structure for WDT initialization.

Public Members

uint32_t behaviour

WDT behavior flags bitmask, constructed from nrf_wdt_behaviour_mask_t.

uint32_t reload_value

WDT reload value in milliseconds.

uint8_t interrupt_priority

WDT interrupt priority.