CLOCK driver

group nrfx_clock

CLOCK peripheral driver.

Typedefs

typedef void (*nrfx_clock_event_handler_t)(nrfx_clock_evt_type_t event)

Clock event handler.

Param event:

[in] Event.

Enums

enum nrfx_clock_evt_type_t

Clock events.

Values:

enumerator NRFX_CLOCK_EVT_HFCLK_STARTED

HFCLK has been started.

enumerator NRFX_CLOCK_EVT_LFCLK_STARTED

LFCLK has been started.

enumerator NRFX_CLOCK_EVT_PLL_STARTED

PLL has been started.

enumerator NRFX_CLOCK_EVT_CTTO

Calibration timeout.

enumerator NRFX_CLOCK_EVT_CAL_DONE

Calibration has been done.

enumerator NRFX_CLOCK_EVT_HFCLKAUDIO_STARTED

HFCLKAUDIO has been started.

enumerator NRFX_CLOCK_EVT_HFCLK192M_STARTED

HFCLK192M has been started.

Functions

nrfx_err_t nrfx_clock_init(nrfx_clock_event_handler_t event_handler)

Function for initializing internal structures in the nrfx_clock module.

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

Parameters:
  • event_handler[in] Event handler provided by the user. If not provided, driver works in blocking mode.

Return values:
  • NRFX_SUCCESS – The procedure is successful.

  • NRFX_ERROR_ALREADY – The driver is already initialized.

void nrfx_clock_enable(void)

Function for enabling interrupts in the clock module.

void nrfx_clock_disable(void)

Function for disabling interrupts in the clock module.

void nrfx_clock_uninit(void)

Function for uninitializing the clock module.

bool nrfx_clock_init_check(void)

Function for checking if the clock driver is initialized.

Return values:
  • true – Driver is already initialized.

  • false – Driver is not initialized.

void nrfx_clock_start(nrf_clock_domain_t domain)

Function for starting the specified clock domain.

Parameters:
  • domain[in] Clock domain.

void nrfx_clock_stop(nrf_clock_domain_t domain)

Function for stopping the specified clock domain.

Parameters:
  • domain[in] Clock domain.

NRFX_STATIC_INLINE bool nrfx_clock_is_running(nrf_clock_domain_t domain, void *p_clk_src)

Function for checking the specified clock domain state.

XTAL source is assumed for domains with multiple sources.

Parameters:
  • domain[in] Clock domain.

  • p_clk_src[out] Pointer to a clock source that is running. Set to NULL if not needed. Ignored for HFCLKAUDIO domain. Variable pointed by p_clk_src must be of either nrf_clock_lfclk_t type for LFCLK or nrf_clock_hfclk_t type for HFCLK and HFCLK192M.

Return values:
  • true – The clock domain is running.

  • false – The clock domain is not running.

nrfx_err_t nrfx_clock_divider_set(nrf_clock_domain_t domain, nrf_clock_hfclk_div_t div)

Function for setting the specified clock domain divider.

Parameters:
  • domain[in] Clock domain.

  • div[in] New divider for the clock domain.

Return values:
  • NRFX_SUCCESS – Divider successfully set.

  • NRFX_ERROR_NOT_SUPPORTED – Domain does not support setting the divider.

  • NRFX_ERROR_INVALID_PARAM – Divider not supported by the specified domain.

NRFX_STATIC_INLINE nrf_clock_hfclk_div_t nrfx_clock_divider_get(nrf_clock_domain_t domain)

Function for getting the specified clock domain divider.

Parameters:
  • domain[in] Clock domain.

Returns:

Current divider for the specified clock domain.

NRFX_STATIC_INLINE void nrfx_clock_lfclk_start(void)

Function for starting the LFCLK.

Note

This function is deprecated. Use nrfx_clock_start instead.

NRFX_STATIC_INLINE void nrfx_clock_lfclk_stop(void)

Function for stopping the LFCLK.

Note

This function is deprecated. Use nrfx_clock_stop instead.

NRFX_STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)

Function for checking the LFCLK state.

Note

This function is deprecated. Use nrfx_clock_is_running instead.

Return values:
  • true – The LFCLK is running.

  • false – The LFCLK is not running.

NRFX_STATIC_INLINE void nrfx_clock_hfclk_start(void)

Function for starting the high-accuracy source HFCLK.

Note

This function is deprecated. Use nrfx_clock_start instead.

NRFX_STATIC_INLINE void nrfx_clock_hfclk_stop(void)

Function for stopping the external high-accuracy source HFCLK.

Note

This function is deprecated. Use nrfx_clock_stop instead.

NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)

Function for checking the HFCLK state.

Note

This function is deprecated. Use nrfx_clock_is_running instead.

Return values:
  • true – The HFCLK is running (XTAL source).

  • false – The HFCLK is not running.

NRFX_STATIC_INLINE void nrfx_clock_hfclkaudio_config_set(uint16_t freq_value)

Function for setting the HFCLKAUDIO configuration.

The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps. To calculate freq_value corresponding to the chosen frequency, use the following equation: FREQ_VALUE = 2^16 * ((12 * f_out / 32M) - 4)

Warning

Chosen frequency must fit in 11.176 MHz - 11.402 MHz or 12.165 MHz - 12.411 MHz frequency bands.

Parameters:
  • freq_value[in] New FREQ_VALUE for HFCLKAUDIO.

NRFX_STATIC_INLINE uint16_t nrfx_clock_hfclkaudio_config_get(void)

Function for getting the HFCLKAUDIO configuration.

The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps. To calculate frequency corresponding to the returned FREQ_VALUE, use the following equation: f_out = 32M * (4 + FREQ_VALUE * 2^(-16))/12

Returns:

Current value of FREQ_VALUE for HFCLKAUDIO.

nrfx_err_t nrfx_clock_calibration_start(void)

Function for starting the calibration of internal LFCLK.

This function starts the calibration process. The process cannot be aborted. LFCLK and HFCLK must be running before this function is called.

Return values:
  • NRFX_SUCCESS – The procedure is successful.

  • NRFX_ERROR_INVALID_STATE – The low-frequency of high-frequency clock is off.

  • NRFX_ERROR_BUSY – Clock is in the calibration phase.

nrfx_err_t nrfx_clock_is_calibrating(void)

Function for checking if calibration is in progress.

This function indicates that the system is in calibration phase.

Return values:
  • NRFX_SUCCESS – The procedure is successful.

  • NRFX_ERROR_BUSY – Clock is in the calibration phase.

void nrfx_clock_calibration_timer_start(uint8_t interval)

Function for starting calibration timer.

Parameters:
  • interval[in] Time after which the CTTO event and interrupt will be generated (in 0.25 s units).

void nrfx_clock_calibration_timer_stop(void)

Function for stopping the calibration timer.

NRFX_STATIC_INLINE uint32_t nrfx_clock_task_address_get(nrf_clock_task_t task)

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

Parameters:
  • task[in] One of the peripheral tasks.

Returns:

Task address.

NRFX_STATIC_INLINE uint32_t nrfx_clock_event_address_get(nrf_clock_event_t event)

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

Parameters:
  • event[in] One of the peripheral events.

Returns:

Event address.