Clock driver

nRF5 SDK v9.0.0

nRF51 SDK v9.0.0

Driver for managing the low-frequency clock (LFCLK) and the high-frequency clock (HFCLK). More...

Data Structures

struct nrf_drv_clock_config_t
Struct for Clock initialization. Thise parameters are used when SoftDevice is not present and low-frequency RC oscillator is selected. More...

Macros

#define NRF_DRV_CLOCK_DEAFULT_CONFIG
Clock default configuration. More...

Enumerations

enum nrf_drv_clock_lf_cal_interval_t {
RC_250MS_CALIBRATION_INTERVAL = 1,
RC_500MS_CALIBRATION_INTERVAL = 2,
RC_1000MS_CALIBRATION_INTERVAL = 4,
RC_2000MS_CALIBRATION_INTERVAL = 8,
RC_4000MS_CALIBRATION_INTERVAL = 16,
RC_8000MS_CALIBRATION_INTERVAL = 32,
RC_16000MS_CALIBRATION_INTERVAL = 64
}
Calibration interval configuration for the low-frequency RC oscillator. More...

Functions

ret_code_t nrf_drv_clock_init ( nrf_drv_clock_config_t const *p_config)
Function for initialization the nrf_drv_clock module. More...
void nrf_drv_clock_uninit (void)
Function for uninitialization the nrf_drv_clock module. More...
void nrf_drv_clock_lfclk_request (void)
Function for requesting LFCLK. LFCLK can be repeatedly requested. More...
void nrf_drv_clock_lfclk_release (void)
Function for releasing LFCLK. If there is no more requests, LFCLK source will be stopped. More...
bool nrf_drv_clock_lfclk_is_running (void)
Function for checking LFCLK state. More...
void nrf_drv_clock_hfclk_request (void)
Function for requesting high-accuracy (for NRF51 it is XTAL) source HFCLK. High-accuracy source can be repeatedly requested. More...
void nrf_drv_clock_hfclk_release (void)
Function for releasing high-accuracy source HFCLK. If there is no more requests, high-accuracy source will be released.
bool nrf_drv_clock_hfclk_is_running (void)
Function for checking HFCLK state. More...
ret_code_t nrf_drv_clock_calibration_force (void)
Function for forcing calibration. More...
ret_code_t nrf_drv_clock_is_calibrating (bool *p_is_calibrating)
Function for checking if calibration is in progress. More...
__STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr ( nrf_clock_task_t task)
Function for returning a requested task address for the clock driver module. More...
__STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr ( nrf_clock_event_t event)
Function for returning a requested event address for the clock driver module. More...

Detailed Description

Driver for managing the low-frequency clock (LFCLK) and the high-frequency clock (HFCLK).

Macro Definition Documentation

#define NRF_DRV_CLOCK_DEAFULT_CONFIG
Value:
{ \
.cal_interval = CLOCK_CONFIG_LF_RC_CAL_INTERVAL, \
.interrupt_priority = CLOCK_CONFIG_IRQ_PRIORITY, \
}

Clock default configuration.

Enumeration Type Documentation

Calibration interval configuration for the low-frequency RC oscillator.

Calibration can be affected by radio transmission. To avoid this problem, call nrf_drv_clock_calibration_force() and wait for end of calibration.

Function Documentation

ret_code_t nrf_drv_clock_calibration_force ( void )

Function for forcing calibration.

This function resets the calibration interval timer. The nrf_drv_clock_is_calibrating() function can be polled to check if calibration is still in progress.

Return values
NRF_SUCCESS If the procedure was successful.
NRF_ERROR_FORBIDDEN If Softdevice is present or selected LFCLK source is not RC oscillator.
bool nrf_drv_clock_hfclk_is_running ( void )

Function for checking HFCLK state.

Return values
true if the HFCLK is running (for NRF51 XTAL source), false if not.
void nrf_drv_clock_hfclk_request ( void )

Function for requesting high-accuracy (for NRF51 it is XTAL) source HFCLK. High-accuracy source can be repeatedly requested.

The nrf_drv_clock_hfclk_is_running() function can be polled to check if it has started.

ret_code_t nrf_drv_clock_init ( nrf_drv_clock_config_t const * p_config )

Function for initialization the nrf_drv_clock module.

After initialization, the module is in power off state (clocks are not requested).

Parameters
[in] p_config Initial configuration. Default configuration used if NULL.
Return values
NRF_SUCCESS If the procedure was successful.
MODULE_ALREADY_INITIALIZED If the driver was already initialized.
NRF_ERROR_SOFTDEVICE_NOT_ENABLED If the SoftDevice was not enabled.
ret_code_t nrf_drv_clock_is_calibrating ( bool * p_is_calibrating )

Function for checking if calibration is in progress.

Parameters
[out] p_is_calibrating true if calibration is in progress, false if not.
Return values
NRF_SUCCESS If the procedure was successful.
NRF_ERROR_FORBIDDEN If Softdevice is present or selected LFCLK source is not RC oscillator.
bool nrf_drv_clock_lfclk_is_running ( void )

Function for checking LFCLK state.

Return values
true if the LFCLK is running, false if not.
void nrf_drv_clock_lfclk_release ( void )

Function for releasing LFCLK. If there is no more requests, LFCLK source will be stopped.

Note
When Softdevice is enabled, LFCLK is always running.
void nrf_drv_clock_lfclk_request ( void )

Function for requesting LFCLK. LFCLK can be repeatedly requested.

Note
When Softdevice is enabled, LFCLK is always running.

If it is first request, selected LFCLK source will be started. The nrf_drv_clock_lfclk_is_running() function can be polled to check if it has started.

__STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr ( nrf_clock_event_t event )

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

Parameters
[in] event One of the peripheral events.
Return values
Event address.
__STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr ( nrf_clock_task_t task )

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

Parameters
[in] task One of the peripheral tasks.
Return values
Task address.
void nrf_drv_clock_uninit ( void )

Function for uninitialization the nrf_drv_clock module.

After uninitialization, the module is in idle state.


Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone .