POWER driver

nRF5 SDK v13.0.0

Driver for managing events and the state of POWER peripheral. More...

Data Structures

struct nrf_drv_power_config_t
General power configuration. More...
struct nrf_drv_power_pofwarn_config_t
The configuration for power failure comparator. More...
struct nrf_drv_power_usbevt_config_t
The configuration of USB related power events. More...

Functions

bool nrf_drv_power_init_check (void)
Function for checking if driver is already initialized. More...
ret_code_t nrf_drv_power_init ( nrf_drv_power_config_t const *p_config)
Initialize power module driver. More...
void nrf_drv_power_uninit (void)
Unintialize power module driver. More...
ret_code_t nrf_drv_power_pof_init ( nrf_drv_power_pofwarn_config_t const *p_config)
Initialize power failure comparator. More...
void nrf_drv_power_pof_uninit (void)
Turn off the power failure comparator. More...
ret_code_t nrf_drv_power_usbevt_init ( nrf_drv_power_usbevt_config_t const *p_config)
Initialize USB power event processing. More...
void nrf_drv_power_usbevt_uninit (void)
Uninitalize USB power event processing. More...
__STATIC_INLINE
nrf_drv_power_usb_state_t
nrf_drv_power_usbstatus_get (void)
Get the status of USB power. More...

Callback types

Defined types of callback functions

typedef void(* nrf_drv_power_pofwarn_event_handler_t )(void)
Event handler for power failure warning.
typedef void(* nrf_drv_power_usb_event_handler_t )( nrf_drv_power_usb_evt_t event)
Event handler for USB related power events. More...

Detailed Description

Driver for managing events and the state of POWER peripheral.

Typedef Documentation

typedef void(* nrf_drv_power_usb_event_handler_t)( nrf_drv_power_usb_evt_t event)

Event handler for USB related power events.

Parameters
event Event type

Enumeration Type Documentation

Power mode possible configurations.

Enumerator
NRF_DRV_POWER_MODE_CONSTLAT

NRF_DRV_POWER_MODE_CONSTLAT.

Constant latency mode

NRF_DRV_POWER_MODE_LOWPWR

NRF_DRV_POWER_MODE_LOWPWR.

Low power mode

Events from USB power system.

Enumerator
NRF_DRV_POWER_USB_EVT_DETECTED

USB power detected on the connector (plugged in).

NRF_DRV_POWER_USB_EVT_REMOVED

USB power removed from the connector.

NRF_DRV_POWER_USB_EVT_READY

USB power regulator ready.

USB power state.

The single enumerator that holds all data about current state of USB related POWER.

Organized this way that higher power state has higher numeric value

Enumerator
NRF_DRV_POWER_USB_STATE_DISCONNECTED

No power on USB lines detected

NRF_DRV_POWER_USB_STATE_CONNECTED

The USB power is detected, but USB power regulator is not ready

NRF_DRV_POWER_USB_STATE_READY

From the power point of view USB is ready for working

Function Documentation

ret_code_t nrf_drv_power_init ( nrf_drv_power_config_t const * p_config )

Initialize power module driver.

Enabled power module driver would process all the interrupts from power system.

Parameters
[in] p_config Driver configuration. Can be NULL - the default configuration from sdk_config.h file would be used then.
Return values
NRF_ERROR_INVALID_STATE Power driver has to be enabled before SoftDevice.
NRF_ERROR_MODULE_ALREADY_INITIALIZED Module is initialized already.
NRF_SUCCESS Successfully initialized.
bool nrf_drv_power_init_check ( void )

Function for checking if driver is already initialized.

This function is used to check whatever common POWER_CLOCK common interrupt should be disabled or not if Clock driver tries to disable the interrupt.

Return values
true Driver is initialized
false Driver is uninitialized
See Also
nrf_drv_power_uninit
ret_code_t nrf_drv_power_pof_init ( nrf_drv_power_pofwarn_config_t const * p_config )

Initialize power failure comparator.

Configures and setups the power failure comparator and enables it.

Parameters
[in] p_config Configuration with values and event handler. If event handler is set to NULL, interrupt would be disabled.
Return values
NRF_ERROR_INVALID_STATE POF is initialized when SD is enabled and the configuration differs from the old one and is not possible to be set using SD interface.
NRF_SUCCESS Successfully initialized and configured.
void nrf_drv_power_pof_uninit ( void )

Turn off the power failure comparator.

Disables and clears the settings of the power failure comparator.

void nrf_drv_power_uninit ( void )

Unintialize power module driver.

Disables all the interrupt handling in the module.

See Also
nrf_drv_power_init
ret_code_t nrf_drv_power_usbevt_init ( nrf_drv_power_usbevt_config_t const * p_config )

Initialize USB power event processing.

Configures and setups the USB power event processing.

Parameters
[in] p_config Configuration with values and event handler.
See Also
nrf_drv_power_usbevt_uninit
Return values
NRF_ERROR_INVALID_STATE This event cannot be initialized when SD is enabled and SD does not support USB power events.
NRF_SUCCESS Successfully initialized and configured.
void nrf_drv_power_usbevt_uninit ( void )

Uninitalize USB power event processing.

See Also
nrf_drv_power_usbevt_init
__STATIC_INLINE nrf_drv_power_usb_state_t nrf_drv_power_usbstatus_get ( void )

Get the status of USB power.

Returns
Current USB power status