nrfxlib API 3.3.99
Loading...
Searching...
No Matches
mpsl_clock.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
17#ifndef MPSL_CLOCK_H__
18#define MPSL_CLOCK_H__
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <stdint.h>
25#include <stdbool.h>
26#include "nrfx.h"
27#include "nrf_errno.h"
28#if !defined (NRF54H_SERIES)
29#include "hal/nrf_clock.h"
30#endif /* !NRF54H20_XXAA */
31
34{
38#if defined(NRF52_SERIES)
39 MPSL_CLOCK_LF_SRC_EXT_LOW_SWING = 3,
41 MPSL_CLOCK_LF_SRC_EXT_FULL_SWING = 4,
44#endif
45};
46
48#define MPSL_RECOMMENDED_RC_CTIV 16
49
51#define MPSL_RECOMMENDED_RC_TEMP_CTIV 2
52
54#define MPSL_DEFAULT_CLOCK_ACCURACY_PPM 250
55
59#define MPSL_WORST_CLOCK_ACCURACY_PPM 500
60
62#define MPSL_DEFAULT_SKIP_WAIT_LFCLK_STARTED false
63
65typedef struct
66{
68 uint8_t source;
69
79 uint8_t rc_ctiv;
80
103
107 uint16_t accuracy_ppm;
108
123
124/* @brief Available options for informing MPSL of the true high-frequency oscillator ramp-up time, in microseconds. */
131
133typedef enum {
135#if defined(NRF_CLOCK_HAS_HFCLK24M) && NRF_CLOCK_HAS_HFCLK24M
136 MPSL_CLOCK_HF_SRC_HFCLK24M = 1,
137#endif /* NRF_CLOCK_HAS_HFCLK24M */
140
142typedef enum
143{
150#if defined(NRF_CLOCK_HAS_HFCLK24M) && NRF_CLOCK_HAS_HFCLK24M
152 MPSL_CLOCK_EVT_HFCLK24M_STARTED = 1,
153#endif /* NRF_CLOCK_HAS_HFCLK24M */
154#if defined(NRF_CLOCK_HAS_XO_TUNE) && NRF_CLOCK_HAS_XO_TUNE
155 MPSL_CLOCK_EVT_XO_TUNED = 2,
156#endif /* NRF_CLOCK_HAS_XO_TUNE */
159
165typedef void (*mpsl_clock_hfclk_callback_t)(void);
166
191__attribute__((deprecated))
193
214__attribute__((deprecated))
216
231__attribute__((deprecated))
232int32_t mpsl_clock_hfclk_is_running(uint32_t * p_is_running);
233
245int32_t mpsl_clock_hfclk_latency_set(uint16_t hfclk_rampup_time_us);
246
259
270
298
318
332int32_t mpsl_clock_hfclk_src_is_running(mpsl_clock_hfclk_src_t src, uint32_t * p_is_running);
333
337typedef struct
338{
347 int32_t (*lfclk_wait)(void);
348
355 void (*lfclk_calibration_start)(void);
356
365 bool (*lfclk_calibration_is_enabled)(void);
366
375 int32_t (*lfclk_request)(void);
376
385 int32_t (*lfclk_release)(void);
386
391 uint16_t accuracy_ppm;
392
403
407typedef struct
408{
415 void (*hfclk_request)(void);
416
423 void (*hfclk_release)(void);
424
433 bool (*hfclk_is_running)(void);
434
441
462 const mpsl_clock_hfclk_ctrl_source_t * p_hfclk_ctrl_source);
463
476
477#ifdef __cplusplus
478}
479#endif
480
481#endif // MPSL_CLOCK_H__
482
int32_t mpsl_clock_hfclk_src_release(mpsl_clock_hfclk_src_t src)
Releases a high frequency clock for a given source.
void(* mpsl_clock_hfclk_request_callback_t)(mpsl_clock_evt_type_t evt_type)
High frequency clock callback.
Definition mpsl_clock.h:269
mpsl_clock_evt_type_t
Event types returned by the hfclk callback handler.
Definition mpsl_clock.h:143
@ MPSL_CLOCK_EVT_MAX
Definition mpsl_clock.h:157
@ MPSL_CLOCK_EVT_HFCLK_STARTED
HFCLK has been started.
Definition mpsl_clock.h:149
void mpsl_clock_task_trigger_on_rtc_start_set(uint32_t task_address)
Trigger a task upon start of the RTC.
int32_t mpsl_clock_hfclk_src_is_running(mpsl_clock_hfclk_src_t src, uint32_t *p_is_running)
Checks if the high frequency clock for a given source is running.
MPSL_CLOCK_LF_SRC
Low frequency clock source.
Definition mpsl_clock.h:34
@ MPSL_CLOCK_LF_SRC_XTAL
Definition mpsl_clock.h:36
@ MPSL_CLOCK_LF_SRC_RC
Definition mpsl_clock.h:35
@ MPSL_CLOCK_LF_SRC_SYNTH
Definition mpsl_clock.h:37
int32_t mpsl_clock_ctrl_source_register(const mpsl_clock_lfclk_ctrl_source_t *p_lfclk_ctrl_source, const mpsl_clock_hfclk_ctrl_source_t *p_hfclk_ctrl_source)
Register an external clock driver.
int32_t mpsl_clock_hfclk_src_request(mpsl_clock_hfclk_src_t src, mpsl_clock_hfclk_request_callback_t hfclk_started_callback)
Request a high frequency clock with a given source.
void(* mpsl_clock_hfclk_callback_t)(void)
High frequency clock callback.
Definition mpsl_clock.h:165
int32_t mpsl_clock_hfclk_latency_set(uint16_t hfclk_rampup_time_us)
Informs MPSL about the actual ramp-up time of the high-frequency crystal oscillator.
int32_t mpsl_clock_hfclk_request(mpsl_clock_hfclk_callback_t hfclk_started_callback)
Request the high frequency crystal oscillator.
int32_t mpsl_clock_ctrl_source_unregister(void)
Unregisters external clock driver from MPSL.
mpsl_clock_hfclk_src_t
Supported high frequency clock sources.
Definition mpsl_clock.h:133
@ MPSL_CLOCK_HF_SRC_XO
Definition mpsl_clock.h:134
@ MPSL_CLOCK_HF_SRC_MAX
Definition mpsl_clock.h:138
mpsl_clock_hfclk_latency_config_t
Definition mpsl_clock.h:126
@ MPSL_CLOCK_HF_LATENCY_WORST_CASE
Definition mpsl_clock.h:129
@ MPSL_CLOCK_HF_LATENCY_BEST
Definition mpsl_clock.h:127
@ MPSL_CLOCK_HF_LATENCY_TYPICAL
Definition mpsl_clock.h:128
int32_t mpsl_clock_hfclk_is_running(uint32_t *p_is_running)
Checks if the high frequency crystal oscillator is running.
int32_t mpsl_clock_hfclk_release(void)
Releases the high frequency crystal oscillator.
uint16_t startup_time_us
Value of a HFXO startup time.
Definition mpsl_clock.h:439
Type representing HFCLK clock handling external API that is expected by MPSL to be delivered on init.
Definition mpsl_clock.h:408
uint8_t rc_temp_ctiv
Definition mpsl_clock.h:102
uint8_t source
Definition mpsl_clock.h:68
uint16_t accuracy_ppm
Definition mpsl_clock.h:107
uint8_t rc_ctiv
Definition mpsl_clock.h:79
bool skip_wait_lfclk_started
Definition mpsl_clock.h:121
Type representing LFCLK oscillator source.
Definition mpsl_clock.h:66
bool skip_wait_lfclk_started
Determines whether MPSL waits for the low frequency clock to start during initialization or not....
Definition mpsl_clock.h:401
uint16_t accuracy_ppm
Value of available LFCLK accuracy.
Definition mpsl_clock.h:391
Type representing LFCLK clock handling external API that is expected by MPSL to be delivered on init.
Definition mpsl_clock.h:338