Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nrf_clock_control.h File Reference

Go to the source code of this file.

Data Structures

struct  nrf_clock_spec
 
struct  nrf_clock_control_driver_api
 

Macros

#define NRF_CLOCK_CONTROL_FREQUENCY_MAX   UINT32_MAX
 
#define NRF_CLOCK_CONTROL_ACCURACY_MAX   1
 
#define NRF_CLOCK_CONTROL_ACCURACY_PPM(ppm)
 
#define NRF_CLOCK_CONTROL_PRECISION_HIGH   1
 
#define NRF_CLOCK_CONTROL_PRECISION_DEFAULT   0
 

Functions

static int nrf_clock_control_request (const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli)
 Request a reservation to use a given clock with specified attributes.
 
int nrf_clock_control_request_sync (const struct device *dev, const struct nrf_clock_spec *spec, k_timeout_t timeout)
 Synchronously request a reservation to use a given clock with specified attributes.
 
static int nrf_clock_control_release (const struct device *dev, const struct nrf_clock_spec *spec)
 Release a reserved use of a clock.
 
static int nrf_clock_control_cancel_or_release (const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli)
 Safely cancel a reservation request.
 
static int nrf_clock_control_resolve (const struct device *dev, const struct nrf_clock_spec *req_spec, struct nrf_clock_spec *res_spec)
 Resolve a requested clock spec to resulting spec.
 
static int nrf_clock_control_get_startup_time (const struct device *dev, const struct nrf_clock_spec *spec, uint32_t *startup_time_us)
 Get the startup time of a clock.
 
void nrf_clock_control_hfxo_request (void)
 Request the HFXO from Zero Latency Interrupt context.
 
void nrf_clock_control_hfxo_release (void)
 Release the HFXO from Zero Latency Interrupt context.
 

Macro Definition Documentation

◆ NRF_CLOCK_CONTROL_ACCURACY_MAX

#define NRF_CLOCK_CONTROL_ACCURACY_MAX   1

◆ NRF_CLOCK_CONTROL_ACCURACY_PPM

#define NRF_CLOCK_CONTROL_ACCURACY_PPM ( ppm)
Value:
(ppm)

◆ NRF_CLOCK_CONTROL_FREQUENCY_MAX

#define NRF_CLOCK_CONTROL_FREQUENCY_MAX   UINT32_MAX

◆ NRF_CLOCK_CONTROL_PRECISION_DEFAULT

#define NRF_CLOCK_CONTROL_PRECISION_DEFAULT   0

◆ NRF_CLOCK_CONTROL_PRECISION_HIGH

#define NRF_CLOCK_CONTROL_PRECISION_HIGH   1

Function Documentation

◆ nrf_clock_control_cancel_or_release()

static int nrf_clock_control_cancel_or_release ( const struct device * dev,
const struct nrf_clock_spec * spec,
struct onoff_client * cli )
inlinestatic

Safely cancel a reservation request.

It may be that a client has issued a reservation request but needs to shut down before the request has completed. This function attempts to cancel the request and issues a release if cancellation fails because the request was completed. This synchronously ensures that ownership data reverts to the client so is available for a future request.

Parameters
devpointer to the clock device structure.
specthe same specification of the clock attributes that was used in the reservation request.
clia pointer to the same client state that was provided when the operation to be cancelled was issued.
Return values
ONOFF_STATE_TO_ONif the cancellation occurred before the transition completed.
ONOFF_STATE_ONif the cancellation occurred after the transition completed.
-EINVALif the parameters are invalid.
negativeother errors produced by onoff_release().

◆ nrf_clock_control_get_startup_time()

static int nrf_clock_control_get_startup_time ( const struct device * dev,
const struct nrf_clock_spec * spec,
uint32_t * startup_time_us )
inlinestatic

Get the startup time of a clock.

Parameters
devDevice structure.
specClock specification to get startup time for.
startup_time_usDestination for startup time in microseconds.
Return values
Successfulif successful.
-errnocode if failure.

◆ nrf_clock_control_hfxo_release()

void nrf_clock_control_hfxo_release ( void )

Release the HFXO from Zero Latency Interrupt context.

Function is optimized for use in Zero Latency Interrupt context.

Calls to this function must be coupled with prior calls to nrf_clock_control_hfxo_request(), because it uses basic reference counting to make sure the HFXO is released when there are no more pending requests.

◆ nrf_clock_control_hfxo_request()

void nrf_clock_control_hfxo_request ( void )

Request the HFXO from Zero Latency Interrupt context.

Function is optimized for use in Zero Latency Interrupt context. It does not give notification when the HFXO is ready, so each user must put the request early enough to make sure the HFXO ramp-up has finished on time.

This function uses reference counting so the caller must ensure that every nrf_clock_control_hfxo_request() call has a matching nrf_clock_control_hfxo_release() call.

◆ nrf_clock_control_release()

static int nrf_clock_control_release ( const struct device * dev,
const struct nrf_clock_spec * spec )
inlinestatic

Release a reserved use of a clock.

Parameters
devpointer to the clock device structure.
specthe same specification of the clock attributes that was used in the reservation request (so that the clock control module can keep track of what attributes are still requested).
Return values
non-negativethe observed state of the on-off service associated with the clock machine at the time the request was processed (see onoff_release()), if successful.
-EIOif service has recorded an error.
-ENOTSUPif the service is not in a state that permits release.

◆ nrf_clock_control_request()

static int nrf_clock_control_request ( const struct device * dev,
const struct nrf_clock_spec * spec,
struct onoff_client * cli )
inlinestatic

Request a reservation to use a given clock with specified attributes.

The return value indicates the success or failure of an attempt to initiate an operation to request the clock be made available. If initiation of the operation succeeds, the result of the request operation is provided through the configured client notification method, possibly before this call returns.

Note that the call to this function may succeed in a case where the actual request fails. Always check the operation completion result.

Parameters
devpointer to the clock device structure.
specspecification of minimal acceptable attributes, like frequency, accuracy, and precision, required for the clock. Value of 0 has the meaning of "default" and can be passed instead of a given attribute if there is no strict requirement in this regard. If there is no specific requirement for any of the attributes, this parameter can be NULL.
clipointer to client state providing instructions on synchronous expectations and how to notify the client when the request completes. Behavior is undefined if client passes a pointer object associated with an incomplete service operation.
Return values
non-negativethe observed state of the on-off service associated with the clock machine at the time the request was processed (see onoff_request()), if successful.
-EIOif service has recorded an error.
-EINVALif the function parameters are invalid or the clock attributes cannot be provided (e.g. the requested accuracy is unavailable).
-EAGAINif the reference count would overflow.

◆ nrf_clock_control_request_sync()

int nrf_clock_control_request_sync ( const struct device * dev,
const struct nrf_clock_spec * spec,
k_timeout_t timeout )

Synchronously request a reservation to use a given clock with specified attributes.

Function can only be called from thread context as it blocks until request is completed.

See also
nrf_clock_control_request().
Parameters
devpointer to the clock device structure.
specSee nrf_clock_control_request().
timeoutRequest timeout.
Return values
0if request is fulfilled.
-EWOULDBLOCKif request is called from the interrupt context.
negativeSee error codes returned by nrf_clock_control_request().

◆ nrf_clock_control_resolve()

static int nrf_clock_control_resolve ( const struct device * dev,
const struct nrf_clock_spec * req_spec,
struct nrf_clock_spec * res_spec )
inlinestatic

Resolve a requested clock spec to resulting spec.

Parameters
devDevice structure.
req_specThe requested clock specification.
res_specDestination for the resulting clock specification.
Return values
Successfulif successful.
-errnocode if failure