nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Data Structures | Functions
nrfcxx::clock Namespace Reference

Functions and classes related to clocks and time. More...

Data Structures

class  alarm
 Class supporting an alarm with custom callback and repeatability. More...
 
class  clock_shift
 Support for converting between time domains with the same resolution but unstable clocks. More...
 
class  hfclk
 Functions and data related to the high-frequency clock. More...
 
class  lfclk
 Functions and data related to the low-frequency clock. More...
 
class  uptime
 Support for a persistent system clock with 32 KiHz resolution. More...
 

Functions

int initialize (bool enable_hfxt=false, int lfclk_src=board::default_lfclk_src(), unsigned int lfrc_cal_interval_qs=lfclk::DefaultRCOCalInterval_qs)
 Initialize the clock system. More...
 
bool configure_pcirq (int on)
 Query or control whether the POWER_CLOCK interrupt handler is enabled. More...
 
constexpr uptime::duration_type operator""_utt (unsigned long long n)
 User-defined literal support for uptime ticks. More...
 

Detailed Description

Functions and classes related to clocks and time.

Function Documentation

◆ configure_pcirq()

bool nrfcxx::clock::configure_pcirq ( int  on)

Query or control whether the POWER_CLOCK interrupt handler is enabled.

POWER_CLOCK_IRQHandler plays a crucial role in maintaining a calibrated RC-based low-frequency clock. However, the application is not permitted to control this interrupt during periods when a soft device is enabled.

Parameters
ona positive value to enable POWER_CLOCK_IRQn; zero to disable it; a negative value to return the configured state without change.
Returns
true iff the POWER_CLOCK interrupt is enabled.

◆ initialize()

int nrfcxx::clock::initialize ( bool  enable_hfxt = false,
int  lfclk_src = board::default_lfclk_src(),
unsigned int  lfrc_cal_interval_qs = lfclk::DefaultRCOCalInterval_qs 
)

Initialize the clock system.

This configures the interrupt handler and must be invoked before any other function in this namespace. It unconditionally invokes lfclk::configure() to enable the low-frequency clock.

Parameters
enable_hfxtPassed to hfclk::hfxt_configure() to default-enable the high-frequency crystal.
lfclk_srcPassed to lfclk::source_configure() prior to invoking lfclk::configure() to set the source for the low-frequency clock. The default is a 32 KiHz crystal if the board provides one, otherwise the RC oscillator.
lfrc_cal_interval_qsPassed to lfclk::source_configure() prior to invoking lfclk::configure() to the calibration interval when lfclk_src is CLOCK_LFCLKSRC_SRC_RC.
Returns
0 on the first call, a negative error code on subsequent calls (which have no effect on the clock configuration).
Note
The POWER_CLOCK interrupt is enabled by this function. Use configure_pcirq() to release it prior to enabling soft devices.
Both the LF clock configuration and the HF crystal configuration may be changed after this function is called. Correct behavior on reconfiguration may require that the POWER_CLOCK interrupt handler be enabled.

◆ operator""_utt()

constexpr uptime::duration_type nrfcxx::clock::operator""_utt ( unsigned long long  n)
constexpr

User-defined literal support for uptime ticks.

Note
Availability of this UDL requires using namespace nrfcxx::clock.