nrfx 4.5.0
Loading...
Searching...
No Matches
WDT driver

Watchdog Timer (WDT) peripheral driver. More...

Topics

 WDT peripheral driver configuration
 

Data Structures

struct  nrfx_wdt_t
 Data structure of the Watchdog (WDT) driver instance. More...
 
struct  nrfx_wdt_config_t
 Structure for WDT initialization. More...
 

Macros

#define NRFX_WDT_HAS_STOP   1
 Symbol indicating whether watchdog stopping is supported.
 
#define NRFX_WDT_IRQ_CONFIG   .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY
 WDT instance interrupt priority configuration.
 
#define NRFX_WDT_INSTANCE(reg)
 Macro for creating an instance of the WDT driver.
 
#define NRFX_WDT_DEFAULT_CONFIG
 WDT driver default configuration.
 

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.
 
typedef nrf_wdt_rr_register_t nrfx_wdt_channel_id
 WDT channel ID type.
 

Functions

int nrfx_wdt_init (nrfx_wdt_t *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.
 
void nrfx_wdt_uninit (nrfx_wdt_t *p_instance)
 Function for uninitializing the WDT driver instance.
 
bool nrfx_wdt_init_check (nrfx_wdt_t const *p_instance)
 Function for checking if the WDT driver instance is initialized.
 
int nrfx_wdt_reconfigure (nrfx_wdt_t *p_instance, nrfx_wdt_config_t const *p_config)
 Function for reconfiguring the watchdog.
 
int nrfx_wdt_channel_alloc (nrfx_wdt_t *p_instance, nrfx_wdt_channel_id *p_channel_id)
 Function for allocating a watchdog channel.
 
void nrfx_wdt_channels_free (nrfx_wdt_t *p_instance)
 Function for deallocating all previously allocated watchdog channels.
 
void nrfx_wdt_enable (nrfx_wdt_t *p_instance)
 Function for starting the watchdog.
 
void nrfx_wdt_feed (nrfx_wdt_t const *p_instance)
 Function for feeding the watchdog.
 
void nrfx_wdt_channel_feed (nrfx_wdt_t const *p_instance, nrfx_wdt_channel_id channel_id)
 Function for feeding an individual watchdog channel.
 
int nrfx_wdt_stop (nrfx_wdt_t *p_instance)
 Function for stopping the watchdog.
 
void nrfx_wdt_irq_handler (nrfx_wdt_t *p_instance)
 Driver interrupt handler.
 
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.
 
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.
 

Detailed Description

Watchdog Timer (WDT) peripheral driver.

Macro Definition Documentation

◆ NRFX_WDT_DEFAULT_CONFIG

#define NRFX_WDT_DEFAULT_CONFIG
Value:
{ \
.reload_value = 2000, \
}
@ NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK
Definition nrf_wdt.h:107
#define NRFX_WDT_IRQ_CONFIG
WDT instance interrupt priority configuration.
Definition nrfx_wdt.h:60

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_INSTANCE

#define NRFX_WDT_INSTANCE ( reg)
Value:
{ \
.p_reg = (NRF_WDT_Type *)reg, \
.cb = {0}, \
}

Macro for creating an instance of the WDT driver.

Typedef Documentation

◆ nrfx_wdt_event_handler_t

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

WDT event handler function type.

Parameters
[in]event_typeWDT event.
[in]requestsValue 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.
[in]p_contextUser context.

Function Documentation

◆ nrfx_wdt_channel_alloc()

int nrfx_wdt_channel_alloc ( nrfx_wdt_t * 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
[in]p_instancePointer to the driver instance structure.
[out]p_channel_idID of granted channel.
Return values
0The channel was successfully allocated.
-ENOMEMThere is no available channel to be used.

◆ nrfx_wdt_channel_feed()

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
[in]p_instancePointer to the driver instance structure.
[in]channel_idID of watchdog channel.

◆ nrfx_wdt_channels_free()

void nrfx_wdt_channels_free ( nrfx_wdt_t * 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
[in]p_instancePointer to the driver instance structure.

◆ nrfx_wdt_enable()

void nrfx_wdt_enable ( nrfx_wdt_t * 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
[in]p_instancePointer to the driver instance structure.

◆ nrfx_wdt_event_address_get()

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
[in]p_instancePointer to the driver instance structure.
[in]eventOne of the WDT events.
Returns
Event address.

◆ nrfx_wdt_feed()

void nrfx_wdt_feed ( nrfx_wdt_t const * p_instance)

Function for feeding the watchdog.

Function feeds all allocated watchdog channels.

Parameters
[in]p_instancePointer to the driver instance structure.

◆ nrfx_wdt_init()

int nrfx_wdt_init ( nrfx_wdt_t * 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
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the initial configuration. NULL if configuration is to be skipped and will be done later using nrfx_wdt_reconfigure.
[in]wdt_event_handlerEvent handler provided by the user. Ignored when NRFX_WDT_CONFIG_NO_IRQ option is enabled.
[in]p_contextUser context passed in event handler. Ignored when NRFX_WDT_CONFIG_NO_IRQ option is enabled.
Return values
0Initialization was successful.
-EALREADYThe driver is already initialized.

◆ nrfx_wdt_init_check()

bool nrfx_wdt_init_check ( nrfx_wdt_t const * p_instance)

Function for checking if the WDT driver instance is initialized.

Parameters
[in]p_instancePointer to the driver instance structure.
Return values
trueInstance is already initialized.
falseInstance is not initialized.

◆ nrfx_wdt_irq_handler()

void nrfx_wdt_irq_handler ( nrfx_wdt_t * p_instance)

Driver interrupt handler.

Parameters
[in]p_instancePointer to the driver instance structure.

◆ nrfx_wdt_reconfigure()

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

Function for reconfiguring the watchdog.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the initial configuration.
Return values
0Reconfiguration was successful.
-EBUSYThe watchdog is already active.
-EINPROGRESSThe watchdog is uninitialized.

◆ nrfx_wdt_stop()

int nrfx_wdt_stop ( nrfx_wdt_t * p_instance)

Function for stopping the watchdog.

Parameters
[in]p_instancePointer to the driver instance structure.
Return values
0Watchdog has been successfully stopped.
-EPERMConfiguration does not allow for stopping the watchdog.

◆ nrfx_wdt_task_address_get()

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
[in]p_instancePointer to the driver instance structure.
[in]taskOne of the WDT tasks.
Returns
Task address.

◆ nrfx_wdt_uninit()

void nrfx_wdt_uninit ( nrfx_wdt_t * p_instance)

Function for uninitializing the WDT driver instance.

The instance can be uninitialized only when not running.

Parameters
[in]p_instancePointer to the driver instance structure.