nRF5 SDK v17.1.0
Macros | Enumerations | Functions
Clock HAL

Hardware access layer for managing the CLOCK peripheral. More...

Macros

#define NRF_CLOCK_HAS_CALIBRATION   1
 Presence of the Low Frequency Clock calibration. More...
 

Enumerations

enum  nrf_clock_lfclk_t {
  NRF_CLOCK_LFCLK_RC = CLOCK_LFCLKSRC_SRC_RC,
  NRF_CLOCK_LFCLK_Xtal = CLOCK_LFCLKSRC_SRC_Xtal,
  NRF_CLOCK_LFCLK_Synth = CLOCK_LFCLKSRC_SRC_Synth,
  NRF_CLOCK_LFCLK_Xtal_Low_Swing,
  NRF_CLOCK_LFCLK_Xtal_Full_Swing
}
 Low-frequency clock sources. More...
 
enum  nrf_clock_hfclk_t {
  NRF_CLOCK_HFCLK_LOW_ACCURACY = CLOCK_HFCLKSTAT_SRC_RC,
  NRF_CLOCK_HFCLK_HIGH_ACCURACY = CLOCK_HFCLKSTAT_SRC_Xtal
}
 High-frequency clock sources. More...
 
enum  nrf_clock_start_task_status_t {
  NRF_CLOCK_START_TASK_NOT_TRIGGERED = CLOCK_LFCLKRUN_STATUS_NotTriggered,
  NRF_CLOCK_START_TASK_TRIGGERED = CLOCK_LFCLKRUN_STATUS_Triggered
}
 Trigger status of task LFCLKSTART/HFCLKSTART. More...
 
enum  nrf_clock_int_mask_t {
  NRF_CLOCK_INT_HF_STARTED_MASK = CLOCK_INTENSET_HFCLKSTARTED_Msk,
  NRF_CLOCK_INT_LF_STARTED_MASK = CLOCK_INTENSET_LFCLKSTARTED_Msk,
  NRF_CLOCK_INT_DONE_MASK = CLOCK_INTENSET_DONE_Msk,
  NRF_CLOCK_INT_CTTO_MASK = CLOCK_INTENSET_CTTO_Msk,
  NRF_CLOCK_INT_CTSTARTED_MASK = CLOCK_INTENSET_CTSTARTED_Msk,
  NRF_CLOCK_INT_CTSTOPPED_MASK = CLOCK_INTENSET_CTSTOPPED_Msk
}
 Interrupts. More...
 
enum  nrf_clock_task_t {
  NRF_CLOCK_TASK_HFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTART),
  NRF_CLOCK_TASK_HFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTOP),
  NRF_CLOCK_TASK_LFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTART),
  NRF_CLOCK_TASK_LFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTOP),
  NRF_CLOCK_TASK_CAL = offsetof(NRF_CLOCK_Type, TASKS_CAL),
  NRF_CLOCK_TASK_CTSTART = offsetof(NRF_CLOCK_Type, TASKS_CTSTART),
  NRF_CLOCK_TASK_CTSTOP = offsetof(NRF_CLOCK_Type, TASKS_CTSTOP)
}
 Tasks. More...
 
enum  nrf_clock_event_t {
  NRF_CLOCK_EVENT_HFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLKSTARTED),
  NRF_CLOCK_EVENT_LFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_LFCLKSTARTED),
  NRF_CLOCK_EVENT_DONE = offsetof(NRF_CLOCK_Type, EVENTS_DONE),
  NRF_CLOCK_EVENT_CTTO = offsetof(NRF_CLOCK_Type, EVENTS_CTTO),
  NRF_CLOCK_EVENT_CTSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_CTSTARTED),
  NRF_CLOCK_EVENT_CTSTOPPED = offsetof(NRF_CLOCK_Type, EVENTS_CTSTOPPED)
}
 Events. More...
 

Functions

__STATIC_INLINE void nrf_clock_int_enable (uint32_t int_mask)
 Function for enabling the specified interrupt. More...
 
__STATIC_INLINE void nrf_clock_int_disable (uint32_t int_mask)
 Function for disabling the specified interrupt. More...
 
__STATIC_INLINE bool nrf_clock_int_enable_check (nrf_clock_int_mask_t int_mask)
 Function for retrieving the state of the specified interrupt. More...
 
__STATIC_INLINE uint32_t nrf_clock_task_address_get (nrf_clock_task_t task)
 Function for retrieving the address of the specified task. More...
 
__STATIC_INLINE void nrf_clock_task_trigger (nrf_clock_task_t task)
 Function for setting the specified task. More...
 
__STATIC_INLINE uint32_t nrf_clock_event_address_get (nrf_clock_event_t event)
 Function for retrieving the address of the specified event. More...
 
__STATIC_INLINE void nrf_clock_event_clear (nrf_clock_event_t event)
 Function for clearing the specified event. More...
 
__STATIC_INLINE bool nrf_clock_event_check (nrf_clock_event_t event)
 Function for retrieving the state of the specified event. More...
 
__STATIC_INLINE void nrf_clock_lf_src_set (nrf_clock_lfclk_t source)
 Function for changing the low-frequency clock source. More...
 
__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get (void)
 Function for retrieving the selected source for the low-frequency clock. More...
 
__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_actv_src_get (void)
 Function for retrieving the active source of the low-frequency clock. More...
 
__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get (void)
 Function for retrieving the clock source for the LFCLK clock when the task LKCLKSTART is triggered. More...
 
__STATIC_INLINE bool nrf_clock_lf_is_running (void)
 Function for retrieving the state of the LFCLK clock. More...
 
__STATIC_INLINE
nrf_clock_start_task_status_t 
nrf_clock_lf_start_task_status_get (void)
 Function for retrieving the trigger status of the task LFCLKSTART. More...
 
__STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get (void)
 Function for retrieving the active source of the high-frequency clock. More...
 
__STATIC_INLINE bool nrf_clock_hf_is_running (nrf_clock_hfclk_t clk_src)
 Function for retrieving the state of the HFCLK clock. More...
 
__STATIC_INLINE
nrf_clock_start_task_status_t 
nrf_clock_hf_start_task_status_get (void)
 Function for retrieving the trigger status of the task HFCLKSTART. More...
 
__STATIC_INLINE void nrf_clock_cal_timer_timeout_set (uint32_t interval)
 Function for changing the calibration timer interval. More...
 
__STATIC_INLINE void nrf_clock_subscribe_set (nrf_clock_task_t task, uint8_t channel)
 Function for setting the subscribe configuration for a given CLOCK task. More...
 
__STATIC_INLINE void nrf_clock_subscribe_clear (nrf_clock_task_t task)
 Function for clearing the subscribe configuration for a given CLOCK task. More...
 
__STATIC_INLINE void nrf_clock_publish_set (nrf_clock_event_t event, uint8_t channel)
 Function for setting the publish configuration for a given CLOCK event. More...
 
__STATIC_INLINE void nrf_clock_publish_clear (nrf_clock_event_t event)
 Function for clearing the publish configuration for a given CLOCK event. More...
 

Detailed Description

Hardware access layer for managing the CLOCK peripheral.

This code can be used to managing low-frequency clock (LFCLK) and the high-frequency clock (HFCLK) settings.

Macro Definition Documentation

#define NRF_CLOCK_HAS_CALIBRATION   1

Presence of the Low Frequency Clock calibration.

In some MCUs there is possibility to use LFCLK calibration.

Enumeration Type Documentation

Events.

Enumerator
NRF_CLOCK_EVENT_HFCLKSTARTED 

HFCLK oscillator started.

NRF_CLOCK_EVENT_LFCLKSTARTED 

LFCLK oscillator started.

NRF_CLOCK_EVENT_DONE 

Calibration of LFCLK RC oscillator completed.

NRF_CLOCK_EVENT_CTTO 

Calibration timer time-out.

NRF_CLOCK_EVENT_CTSTARTED 

Calibration timer started.

NRF_CLOCK_EVENT_CTSTOPPED 

Calibration timer stopped.

High-frequency clock sources.

Enumerator
NRF_CLOCK_HFCLK_LOW_ACCURACY 

Internal 16 MHz RC oscillator.

NRF_CLOCK_HFCLK_HIGH_ACCURACY 

External 16 MHz/32 MHz crystal oscillator.

Interrupts.

Enumerator
NRF_CLOCK_INT_HF_STARTED_MASK 

Interrupt on HFCLKSTARTED event.

NRF_CLOCK_INT_LF_STARTED_MASK 

Interrupt on LFCLKSTARTED event.

NRF_CLOCK_INT_DONE_MASK 

Interrupt on DONE event.

NRF_CLOCK_INT_CTTO_MASK 

Interrupt on CTTO event.

NRF_CLOCK_INT_CTSTARTED_MASK 

Interrupt on CTSTARTED event.

NRF_CLOCK_INT_CTSTOPPED_MASK 

Interrupt on CTSTOPPED event.

Low-frequency clock sources.

Used by LFCLKSRC, LFCLKSTAT, and LFCLKSRCCOPY registers.

Enumerator
NRF_CLOCK_LFCLK_RC 

Internal 32 kHz RC oscillator.

NRF_CLOCK_LFCLK_Xtal 

External 32 kHz crystal.

NRF_CLOCK_LFCLK_Synth 

Internal 32 kHz synthesizer from HFCLK system clock.

NRF_CLOCK_LFCLK_Xtal_Low_Swing 

External 32 kHz low swing signal. Used only with the LFCLKSRC register. For the others NRF_CLOCK_LFCLK_Xtal is returned for this setting.

NRF_CLOCK_LFCLK_Xtal_Full_Swing 

External 32 kHz full swing signal. Used only with the LFCLKSRC register. For the others NRF_CLOCK_LFCLK_Xtal is returned for this setting.

Trigger status of task LFCLKSTART/HFCLKSTART.

Used by LFCLKRUN and HFCLKRUN registers.

Enumerator
NRF_CLOCK_START_TASK_NOT_TRIGGERED 

Task LFCLKSTART/HFCLKSTART has not been triggered.

NRF_CLOCK_START_TASK_TRIGGERED 

Task LFCLKSTART/HFCLKSTART has been triggered.

Tasks.

The NRF_CLOCK_TASK_LFCLKSTOP task cannot be set when the low-frequency clock is not running. The NRF_CLOCK_TASK_HFCLKSTOP task cannot be set when the high-frequency clock is not running.

Enumerator
NRF_CLOCK_TASK_HFCLKSTART 

Start HFCLK clock source.

NRF_CLOCK_TASK_HFCLKSTOP 

Stop HFCLK clock source.

NRF_CLOCK_TASK_LFCLKSTART 

Start LFCLK clock source.

NRF_CLOCK_TASK_LFCLKSTOP 

Stop LFCLK clock source.

NRF_CLOCK_TASK_CAL 

Start calibration of LFCLK RC oscillator.

NRF_CLOCK_TASK_CTSTART 

Start calibration timer.

NRF_CLOCK_TASK_CTSTOP 

Stop calibration timer.

Function Documentation

__STATIC_INLINE void nrf_clock_cal_timer_timeout_set ( uint32_t  interval)

Function for changing the calibration timer interval.

Parameters
[in]intervalNew calibration timer interval in 0.25 s resolution (range: 0.25 seconds to 31.75 seconds).
__STATIC_INLINE uint32_t nrf_clock_event_address_get ( nrf_clock_event_t  event)

Function for retrieving the address of the specified event.

This function can be used by the PPI module.

Parameters
[in]eventCLOCK Event.
Returns
Address of the specified event register.
__STATIC_INLINE bool nrf_clock_event_check ( nrf_clock_event_t  event)

Function for retrieving the state of the specified event.

Parameters
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.
__STATIC_INLINE void nrf_clock_event_clear ( nrf_clock_event_t  event)

Function for clearing the specified event.

Parameters
[in]eventEvent to clear.
__STATIC_INLINE bool nrf_clock_hf_is_running ( nrf_clock_hfclk_t  clk_src)

Function for retrieving the state of the HFCLK clock.

Parameters
[in]clk_srcClock source to be checked.
Return values
falseThe HFCLK clock is not running.
trueThe HFCLK clock is running.
__STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get ( void  )

Function for retrieving the active source of the high-frequency clock.

Return values
NRF_CLOCK_HFCLK_LOW_ACCURACYThe internal RC oscillator is the active source of the high-frequency clock.
NRF_CLOCK_HFCLK_HIGH_ACCURACYAn external crystal oscillator is the active source of the high-frequency clock.
__STATIC_INLINE nrf_clock_start_task_status_t nrf_clock_hf_start_task_status_get ( void  )

Function for retrieving the trigger status of the task HFCLKSTART.

Return values
NRF_CLOCK_START_TASK_NOT_TRIGGEREDThe task HFCLKSTART has not been triggered.
NRF_CLOCK_START_TASK_TRIGGEREDThe task HFCLKSTART has been triggered.
__STATIC_INLINE void nrf_clock_int_disable ( uint32_t  int_mask)

Function for disabling the specified interrupt.

Parameters
[in]int_maskInterrupt.
__STATIC_INLINE void nrf_clock_int_enable ( uint32_t  int_mask)

Function for enabling the specified interrupt.

Parameters
[in]int_maskInterrupt.
__STATIC_INLINE bool nrf_clock_int_enable_check ( nrf_clock_int_mask_t  int_mask)

Function for retrieving the state of the specified interrupt.

Parameters
[in]int_maskInterrupt.
Return values
trueThe interrupt is enabled.
falseThe interrupt is not enabled.
__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_actv_src_get ( void  )

Function for retrieving the active source of the low-frequency clock.

Return values
NRF_CLOCK_LFCLK_RCThe internal 32 kHz RC oscillator is the active source of the low-frequency clock.
NRF_CLOCK_LFCLK_XtalAn external 32 kHz crystal oscillator is the active source of the low-frequency clock.
NRF_CLOCK_LFCLK_SynthThe internal 32 kHz synthesizer from the HFCLK is the active source of the low-frequency clock.
__STATIC_INLINE bool nrf_clock_lf_is_running ( void  )

Function for retrieving the state of the LFCLK clock.

Return values
falseThe LFCLK clock is not running.
trueThe LFCLK clock is running.
__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get ( void  )

Function for retrieving the selected source for the low-frequency clock.

Return values
NRF_CLOCK_LFCLK_RCThe internal 32 kHz RC oscillator is the selected source for the low-frequency clock.
NRF_CLOCK_LFCLK_XtalAn external 32 kHz crystal oscillator is the selected source for the low-frequency clock.
NRF_CLOCK_LFCLK_SynthThe internal 32 kHz synthesizer from the HFCLK is the selected source for the low-frequency clock.
__STATIC_INLINE void nrf_clock_lf_src_set ( nrf_clock_lfclk_t  source)

Function for changing the low-frequency clock source.

This function cannot be called when the low-frequency clock is running.

Parameters
[in]sourceNew low-frequency clock source.
__STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get ( void  )

Function for retrieving the clock source for the LFCLK clock when the task LKCLKSTART is triggered.

Return values
NRF_CLOCK_LFCLK_RCThe internal 32 kHz RC oscillator is running and generating the LFCLK clock.
NRF_CLOCK_LFCLK_XtalAn external 32 kHz crystal oscillator is running and generating the LFCLK clock.
NRF_CLOCK_LFCLK_SynthThe internal 32 kHz synthesizer from the HFCLK is running and generating the LFCLK clock.
__STATIC_INLINE nrf_clock_start_task_status_t nrf_clock_lf_start_task_status_get ( void  )

Function for retrieving the trigger status of the task LFCLKSTART.

Return values
NRF_CLOCK_START_TASK_NOT_TRIGGEREDThe task LFCLKSTART has not been triggered.
NRF_CLOCK_START_TASK_TRIGGEREDThe task LFCLKSTART has been triggered.
__STATIC_INLINE void nrf_clock_publish_clear ( nrf_clock_event_t  event)

Function for clearing the publish configuration for a given CLOCK event.

Parameters
[in]eventEvent for which to clear the configuration.
__STATIC_INLINE void nrf_clock_publish_set ( nrf_clock_event_t  event,
uint8_t  channel 
)

Function for setting the publish configuration for a given CLOCK event.

Parameters
[in]eventEvent for which to set the configuration.
[in]channelChannel through which to publish the event.
__STATIC_INLINE void nrf_clock_subscribe_clear ( nrf_clock_task_t  task)

Function for clearing the subscribe configuration for a given CLOCK task.

Parameters
[in]taskTask for which to clear the configuration.
__STATIC_INLINE void nrf_clock_subscribe_set ( nrf_clock_task_t  task,
uint8_t  channel 
)

Function for setting the subscribe configuration for a given CLOCK task.

Parameters
[in]taskTask for which to set the configuration.
[in]channelChannel through which to subscribe events.
__STATIC_INLINE uint32_t nrf_clock_task_address_get ( nrf_clock_task_t  task)

Function for retrieving the address of the specified task.

This function can be used by the PPI module.

Parameters
[in]taskCLOCK Task.
Returns
Address of the requested task register.
__STATIC_INLINE void nrf_clock_task_trigger ( nrf_clock_task_t  task)

Function for setting the specified task.

Parameters
[in]taskTask to be activated.

Documentation feedback | Developer Zone | Subscribe | Updated