1 /*
2  * Copyright (c) 2022 - 2024, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef NRF_AUXPLL_H__
35 #define NRF_AUXPLL_H__
36 
37 #include <nrfx.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /**
44  * @defgroup nrf_auxpll_hal Auxiliary PLL HAL
45  * @{
46  * @ingroup nrf_clock
47  * @brief   Hardware access layer for managing the Auxiliary Phase Locked Loop (AUXPLL) peripheral.
48  */
49 
50 /** @brief AUXPLL tasks. */
51 typedef enum
52 {
53     NRF_AUXPLL_TASK_START          = offsetof(NRF_AUXPLL_Type, TASKS_START),        /**< Start the AUXPLL. */
54     NRF_AUXPLL_TASK_STOP           = offsetof(NRF_AUXPLL_Type, TASKS_STOP),         /**< Stop the AUXPLL. */
55     NRF_AUXPLL_TASK_FREQ_NEW_FINE  = offsetof(NRF_AUXPLL_Type, TASKS_NEWFINEFREQ),  /**< Change fine frequency. */
56     NRF_AUXPLL_TASK_FREQ_NEW_BASE  = offsetof(NRF_AUXPLL_Type, TASKS_NEWBASEFREQ),  /**< Change base frequency. */
57     NRF_AUXPLL_TASK_FREQ_INC_START = offsetof(NRF_AUXPLL_Type, TASKS_FREQINCSTART), /**< Start automated frequency increment. */
58     NRF_AUXPLL_TASK_FREQ_INC_STOP  = offsetof(NRF_AUXPLL_Type, TASKS_FREQINCSTOP),  /**< Stop automated frequency increment. */
59 } nrf_auxpll_task_t;
60 
61 /** @brief AUXPLL events. */
62 typedef enum
63 {
64     NRF_AUXPLL_EVENT_STARTED = offsetof(NRF_AUXPLL_Type, EVENTS_STARTED), /**< Event indicating that AUXPLL started. */
65     NRF_AUXPLL_EVENT_STOPPED = offsetof(NRF_AUXPLL_Type, EVENTS_STOPPED), /**< Event indicating that AUXPLL stopped. */
66     NRF_AUXPLL_EVENT_LOCKED  = offsetof(NRF_AUXPLL_Type, EVENTS_LOCKED),  /**< Event indicating that AUXPLL locked. */
67 } nrf_auxpll_event_t;
68 
69 /** @brief AUXPLL interrupts. */
70 typedef enum
71 {
72     NRF_AUXPLL_INT_STARTED_MASK = AUXPLL_INTEN_STARTED_Msk, /**< AUXPLL interrupt for STARTED event. */
73     NRF_AUXPLL_INT_STOPPED_MASK = AUXPLL_INTEN_STOPPED_Msk, /**< AUXPLL interrupt for STOPPED event. */
74     NRF_AUXPLL_INT_LOCKED_MASK  = AUXPLL_INTEN_LOCKED_Msk   /**< AUXPLL interrupt for LOCKED event. */
75 } nrf_auxpll_int_mask_t;
76 
77 /** @brief AUXPLL STATUS register bit masks. */
78 typedef enum
79 {
80     NRF_AUXPLL_STATUS_MODE_MASK             = AUXPLL_STATUS_MODE_Msk,           /**< AUXPLL mode indication. 1 - Locked mode, 0 - Freerunning mode. */
81     NRF_AUXPLL_STATUS_PLL_RUNNING_MASK      = AUXPLL_STATUS_PLLRUNNING_Msk,     /**< AUXPLL running indication. 1 - PLL running, 0 - PLL not running. */
82     MRF_AUXPLL_STATUS_FREQUENCY_ACTUAL_MASK = AUXPLL_STATUS_FREQUENCYACTUAL_Msk /**< Actual fractional PLL divider ratio. */
83 } nrf_auxpll_status_mask_t;
84 
85 /** @brief AUXPLL output prescaler ratio. */
86 typedef enum
87 {
88     NRF_AUXPLL_CTRL_OUTSEL_DIV_DISABLED = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_DivDisabled, /**< Divider disabled. Bypassed external clock still supported. */
89     NRF_AUXPLL_CTRL_OUTSEL_DIV_1        = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div1,        /**< Divide by 1 */
90     NRF_AUXPLL_CTRL_OUTSEL_DIV_2        = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div2,        /**< Divide by 2 */
91     NRF_AUXPLL_CTRL_OUTSEL_DIV_3        = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div3,        /**< Divide by 3 */
92     NRF_AUXPLL_CTRL_OUTSEL_DIV_4        = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div4,        /**< Divide by 4 */
93     NRF_AUXPLL_CTRL_OUTSEL_DIV_6        = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div6,        /**< Divide by 6 */
94     NRF_AUXPLL_CTRL_OUTSEL_DIV_8        = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div8,        /**< Divide by 8 */
95     NRF_AUXPLL_CTRL_OUTSEL_DIV_12       = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div12,       /**< Divide by 12 */
96     NRF_AUXPLL_CTRL_OUTSEL_DIV_16       = AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Div16,       /**< Divide by 16 */
97 } nrf_auxpll_ctrl_outsel_t;
98 
99 /** @brief AUXPLL freerunning mode control. */
100 typedef enum
101 {
102     NRF_AUXPLL_CTRL_MODE_AUTO    = AUXPLL_AUXPLLCTRL_MODE_MODECTRL_Auto,    /**< Automatically handled by the AUXPLL peripheral. */
103     NRF_AUXPLL_CTRL_MODE_FREERUN = AUXPLL_AUXPLLCTRL_MODE_MODECTRL_Freerun, /**< Keep AUXPLL in freerunning mode. */
104     NRF_AUXPLL_CTRL_MODE_LOCKED  = AUXPLL_AUXPLLCTRL_MODE_MODECTRL_Locked   /**< Keep AUXPLL in locked mode. */
105 } nrf_auxpll_ctrl_mode_t;
106 
107 /** @brief AUXPLL Loop divider base settings. */
108 typedef enum
109 {
110     NRF_AUXPLL_DIVIDER_RANGE_LOW  = AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Low,        /**< Low range divider setting. Fractional divider in the range 3..4 */
111     NRF_AUXPLL_DIVIDER_RANGE_MID  = AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Mid,        /**< Mid range divider setting. Fractional divider in the range 4..5 */
112     NRF_AUXPLL_DIVIDER_RANGE_HIGH = AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_High,       /**< High range divider setting. Fractional divider in the range 5..6 */
113     NRF_AUXPLL_DIVIDER_RANGE_MAX  = AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_StaticHigh, /**< Maximum static divider setting. Fractional division not supported. */
114 } nrf_auxpll_divider_range_t ;
115 
116 /** @brief AUXPLL configuration. */
117 typedef struct
118 {
119     uint8_t outdrive;                 /**< Output buffer drive strength selection. Range 0..3 */
120     uint8_t current_tune;             /**< Constant current tune for ring oscillator. Range 0..15 */
121     bool sdm_off;                     /**< Turn off sigma delta modulation */
122     bool dither_off;                  /**< Turn off dither in sigma delta modulator */
123     nrf_auxpll_divider_range_t range; /**< Loop divider base settings */
124 } nrf_auxpll_config_t;
125 
126 /**
127  * @brief Function for activating the specified AUXPLL task.
128  *
129  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
130  * @param[in] task  Task to be activated.
131  */
132 NRF_STATIC_INLINE void nrf_auxpll_task_trigger(NRF_AUXPLL_Type * p_reg,
133                                                nrf_auxpll_task_t task);
134 
135 /**
136  * @brief Function for getting the address of the specified AUXPLL task register.
137  *
138  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
139  * @param[in] task  The specified task.
140  *
141  * @return Address of the specified task register.
142  */
143 NRF_STATIC_INLINE uint32_t nrf_auxpll_task_address_get(NRF_AUXPLL_Type const * p_reg,
144                                                        nrf_auxpll_task_t       task);
145 
146 /**
147  * @brief Function for clearing the specified AUXPLL event.
148  *
149  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
150  * @param[in] event Event to clear.
151  */
152 NRF_STATIC_INLINE void nrf_auxpll_event_clear(NRF_AUXPLL_Type *  p_reg,
153                                               nrf_auxpll_event_t event);
154 
155 /**
156  * @brief Function for retrieving the state of the AUXPLL event.
157  *
158  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
159  * @param[in] event Event to be checked.
160  *
161  * @retval true  The event has been generated.
162  * @retval false The event has not been generated.
163  */
164 NRF_STATIC_INLINE bool nrf_auxpll_event_check(NRF_AUXPLL_Type const * p_reg,
165                                               nrf_auxpll_event_t      event);
166 
167 /**
168  * @brief Function for getting the address of the specified AUXPLL event register.
169  *
170  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
171  * @param[in] event The specified event.
172  *
173  * @return Address of the specified event register.
174  */
175 NRF_STATIC_INLINE uint32_t nrf_auxpll_event_address_get(NRF_AUXPLL_Type const * p_reg,
176                                                         nrf_auxpll_event_t      event);
177 
178 /**
179  * @brief Function for enabling the specified interrupts.
180  *
181  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
182  * @param[in] mask  Mask of interrupts to be enabled.
183  *                  Use @ref nrf_auxpll_int_mask_t values for bit masking.
184  */
185 NRF_STATIC_INLINE void nrf_auxpll_int_enable(NRF_AUXPLL_Type * p_reg,
186                                              uint32_t          mask);
187 
188 /**
189  * @brief Function for disabling the specified interrupts.
190  *
191  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
192  * @param[in] mask  Mask of interrupts to be disabled.
193  *                  Use @ref nrf_auxpll_int_mask_t values for bit masking.
194  */
195 NRF_STATIC_INLINE void nrf_auxpll_int_disable(NRF_AUXPLL_Type * p_reg,
196                                               uint32_t          mask);
197 
198 /**
199  * @brief Function for checking if the specified interrupts are enabled.
200  *
201  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
202  * @param[in] mask  Mask of interrupts to be checked.
203  *                  Use @ref nrf_auxpll_int_mask_t values for bit masking.
204  *
205  * @return true  requested interrupts are enabled.
206  * @return false requested interrupts are disabled.
207  */
208 NRF_STATIC_INLINE bool nrf_auxpll_int_enable_check(NRF_AUXPLL_Type const * p_reg,
209                                                    uint32_t                mask);
210 
211 /**
212  * @brief Function for checking if the specified interrupts are pending.
213  *
214  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
215  * @param[in] mask  Mask of interrupts to be checked.
216  *                  Use @ref nrf_auxpll_int_mask_t values for bit masking.
217  *
218  * @return true  requested interrupts are pending.
219  * @return false requested interrupts are not pending.
220  */
221 NRF_STATIC_INLINE bool nrf_auxpll_int_pending_check(NRF_AUXPLL_Type const * p_reg,
222                                                     uint32_t                mask);
223 
224 /**
225  * @brief Function for getting AUXPLL status.
226  *
227  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
228  *
229  * @return The AUXPLL STATUS register value. Use @ref nrf_auxpll_status_mask_t values for bit masking.
230  */
231 NRF_STATIC_INLINE uint32_t nrf_auxpll_status_get(NRF_AUXPLL_Type const * p_reg);
232 
233 /**
234  * @brief Function for getting the AUXPLL configuration.
235  *
236  * @param[in]  p_reg Pointer to the structure of registers of the peripheral.
237  * @param[out] p_cfg Pointer to the structure to be filled with current AUXPLL configuration.
238  */
239 NRF_STATIC_INLINE void nrf_auxpll_config_get(NRF_AUXPLL_Type const * p_reg,
240                                              nrf_auxpll_config_t   * p_cfg);
241 
242 /**
243  * @brief Function for setting the AUXPLL configuration.
244  *
245  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
246  * @param[in] p_cfg Pointer to the structure with AUXPLL configuration.
247  */
248 NRF_STATIC_INLINE void nrf_auxpll_config_set(NRF_AUXPLL_Type *           p_reg,
249                                              nrf_auxpll_config_t const * p_cfg);
250 
251 /**
252  * @brief Function for setting the AUXPLL ring oscillator core process corner tuning.
253  *
254  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
255  * @param[in] value tuning frequency value.
256  */
257 NRF_STATIC_INLINE void nrf_auxpll_trim_ctune_set(NRF_AUXPLL_Type * p_reg,
258                                                  uint8_t           value);
259 
260 /**
261  * @brief Function for getting the AUXPLL ring oscillator core process corner tuning.
262  *
263  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
264  *
265  * @return The AUXPLL ring oscillator core process corner tuning value.
266  */
267 NRF_STATIC_INLINE uint8_t nrf_auxpll_trim_ctune_get(NRF_AUXPLL_Type const * p_reg);
268 
269 
270 /**
271  * @brief Function for setting the AUXPLL fractional PLL divider ratio tuning.
272  *
273  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
274  * @param[in] value Fractional divider ratio.
275  */
276 NRF_STATIC_INLINE void nrf_auxpll_ctrl_frequency_set(NRF_AUXPLL_Type * p_reg,
277                                                      uint16_t          value);
278 
279 /**
280  * @brief Function for getting the AUXPLL fractional PLL divider ratio.
281  *
282  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
283  *
284  * @return Fractional divider ratio.
285  */
286 NRF_STATIC_INLINE uint16_t nrf_auxpll_ctrl_frequency_get(NRF_AUXPLL_Type const * p_reg);
287 
288 /**
289  * @brief Function for setting the AUXPLL frequency increment value.
290  *
291  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
292  * @param[in] value Signed 8-bit frequency increment, applied to current value of FREQUENCY register.
293  */
294 NRF_STATIC_INLINE void nrf_auxpll_ctrl_freqinc_set(NRF_AUXPLL_Type * p_reg,
295                                                    int8_t            value);
296 
297 /**
298  * @brief Function for getting the AUXPLL frequency increment value.
299  *
300  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
301  *
302  * @return Signed 8-bit frequency increment.
303  */
304 NRF_STATIC_INLINE int8_t nrf_auxpll_ctrl_freqinc_get(NRF_AUXPLL_Type const * p_reg);
305 
306 /**
307  * @brief Function for setting the AUXPLL frequency increment period.
308  *
309  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
310  * @param[in] value Frequency increment period in 1 us steps.
311  */
312 NRF_STATIC_INLINE void nrf_auxpll_ctrl_freqinc_period_set(NRF_AUXPLL_Type * p_reg,
313                                                           uint16_t          value);
314 
315 /**
316  * @brief Function for getting the AUXPLL frequency increment period value.
317  *
318  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
319  *
320  * @return Frequency increment period.
321  */
322 NRF_STATIC_INLINE uint16_t nrf_auxpll_ctrl_freqinc_period_get(NRF_AUXPLL_Type const * p_reg);
323 
324 /**
325  * @brief Function for setting the AUXPLL output prescaler.
326  *
327  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
328  * @param[in] value Prescaler ratio.
329  */
330 NRF_STATIC_INLINE void nrf_auxpll_ctrl_outsel_set(NRF_AUXPLL_Type *        p_reg,
331                                                   nrf_auxpll_ctrl_outsel_t value);
332 
333 /**
334  * @brief Function for getting the AUXPLL output prescaler value.
335  *
336  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
337  *
338  * @return Prescaler ratio.
339  */
340 NRF_STATIC_INLINE nrf_auxpll_ctrl_outsel_t nrf_auxpll_ctrl_outsel_get(NRF_AUXPLL_Type const * p_reg);
341 
342 /**
343  * @brief Function for setting the AUXPLL mode.
344  *
345  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
346  * @param[in] value AUXPLL running mode.
347  */
348 NRF_STATIC_INLINE void nrf_auxpll_ctrl_mode_set(NRF_AUXPLL_Type *      p_reg,
349                                                 nrf_auxpll_ctrl_mode_t value);
350 
351 /**
352  * @brief Function for getting the AUXPLL mode.
353  *
354  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
355  *
356  * @return AUXPLL running mode.
357  */
358 NRF_STATIC_INLINE nrf_auxpll_ctrl_mode_t nrf_auxpll_ctrl_mode_get(NRF_AUXPLL_Type const * p_reg);
359 
360 /**
361  * @brief Enable LOCK for mirrored AUXPLL registers.
362  *
363  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
364  */
365 NRF_STATIC_INLINE void nrf_auxpll_lock(NRF_AUXPLL_Type * p_reg);
366 
367 /**
368  * @brief Disable the lock after configuring all AUXPLL mirrored registers.
369  *
370  * @details The individual mirrored registers can be updated any time when the lock is disabled.
371  *
372  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
373  */
374 NRF_STATIC_INLINE void nrf_auxpll_unlock(NRF_AUXPLL_Type * p_reg);
375 
376 /**
377  * @brief Check if mirrored AUXPLL registers are locked.
378  *
379  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
380  *
381  * @retval true  The AUXPLL mirrored register lock enabled.
382  * @retval false The AUXPLL mirrored register lock disabled.
383  */
384 NRF_STATIC_INLINE bool nrf_auxpll_lock_check(NRF_AUXPLL_Type const * p_reg);
385 
386 /**
387  * @brief Obtain static ratio when DSM is disabled.
388  *
389  * @param p_reg Pointer to the structure of registers of the peripheral.
390  *
391  * @return Static ratio value.
392  */
393 NRF_STATIC_INLINE uint8_t nrf_auxpll_static_ratio_get(NRF_AUXPLL_Type const * p_reg);
394 
395 /**
396  * @brief Check if AUXPLL is locked.
397  *
398  * @param p_reg Pointer to the structure of registers of the peripheral.
399  *
400  * @retval true The AUXPLL is locked.
401  * @retval false The AUXPLL is not locked.
402  */
403 NRF_STATIC_INLINE bool nrf_auxpll_mode_locked_check(NRF_AUXPLL_Type const * p_reg);
404 
405 /**
406  * @brief Check if AUXPLL is running.
407  *
408  * @param p_reg Pointer to the structure of registers of the peripheral.
409  *
410  * @retval true The AUXPLL is running.
411  * @retval false The AUXPLL is not running.
412  */
413 NRF_STATIC_INLINE bool nrf_auxpll_running_check(NRF_AUXPLL_Type const * p_reg);
414 
415 #ifndef NRF_DECLARE_ONLY
416 
nrf_auxpll_task_trigger(NRF_AUXPLL_Type * p_reg,nrf_auxpll_task_t task)417 NRF_STATIC_INLINE void nrf_auxpll_task_trigger(NRF_AUXPLL_Type * p_reg,
418                                                nrf_auxpll_task_t task)
419 {
420     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
421 }
422 
nrf_auxpll_task_address_get(NRF_AUXPLL_Type const * p_reg,nrf_auxpll_task_t task)423 NRF_STATIC_INLINE uint32_t nrf_auxpll_task_address_get(NRF_AUXPLL_Type const * p_reg,
424                                                        nrf_auxpll_task_t       task)
425 {
426     return nrf_task_event_address_get(p_reg, task);
427 }
428 
nrf_auxpll_event_clear(NRF_AUXPLL_Type * p_reg,nrf_auxpll_event_t event)429 NRF_STATIC_INLINE void nrf_auxpll_event_clear(NRF_AUXPLL_Type *  p_reg,
430                                               nrf_auxpll_event_t event)
431 {
432     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
433     nrf_event_readback((uint8_t *)p_reg + (uint32_t)event);
434 }
435 
nrf_auxpll_event_check(NRF_AUXPLL_Type const * p_reg,nrf_auxpll_event_t event)436 NRF_STATIC_INLINE bool nrf_auxpll_event_check(NRF_AUXPLL_Type const * p_reg,
437                                               nrf_auxpll_event_t      event)
438 {
439     return nrf_event_check(p_reg, event);
440 }
441 
nrf_auxpll_event_address_get(NRF_AUXPLL_Type const * p_reg,nrf_auxpll_event_t event)442 NRF_STATIC_INLINE uint32_t nrf_auxpll_event_address_get(NRF_AUXPLL_Type const * p_reg,
443                                                         nrf_auxpll_event_t      event)
444 {
445     return nrf_task_event_address_get(p_reg, event);
446 }
447 
nrf_auxpll_int_enable(NRF_AUXPLL_Type * p_reg,uint32_t mask)448 NRF_STATIC_INLINE void nrf_auxpll_int_enable(NRF_AUXPLL_Type * p_reg,
449                                              uint32_t          mask)
450 {
451     p_reg->INTENSET = mask;
452 }
453 
nrf_auxpll_int_disable(NRF_AUXPLL_Type * p_reg,uint32_t mask)454 NRF_STATIC_INLINE void nrf_auxpll_int_disable(NRF_AUXPLL_Type * p_reg,
455                                               uint32_t          mask)
456 {
457     p_reg->INTENCLR = mask;
458 }
459 
nrf_auxpll_int_enable_check(NRF_AUXPLL_Type const * p_reg,uint32_t mask)460 NRF_STATIC_INLINE bool nrf_auxpll_int_enable_check(NRF_AUXPLL_Type const * p_reg,
461                                                    uint32_t                mask)
462 {
463     return p_reg->INTEN & mask;
464 }
465 
nrf_auxpll_int_pending_check(NRF_AUXPLL_Type const * p_reg,uint32_t mask)466 NRF_STATIC_INLINE bool nrf_auxpll_int_pending_check(NRF_AUXPLL_Type const * p_reg,
467                                                    uint32_t                 mask)
468 {
469     return p_reg->INTPEND & mask;
470 }
471 
nrf_auxpll_status_get(NRF_AUXPLL_Type const * p_reg)472 NRF_STATIC_INLINE uint32_t nrf_auxpll_status_get(NRF_AUXPLL_Type const * p_reg)
473 {
474     return p_reg->STATUS;
475 }
476 
nrf_auxpll_config_get(NRF_AUXPLL_Type const * p_reg,nrf_auxpll_config_t * p_cfg)477 NRF_STATIC_INLINE void nrf_auxpll_config_get(NRF_AUXPLL_Type const * p_reg,
478                                              nrf_auxpll_config_t   * p_cfg)
479 {
480     NRFX_ASSERT(p_cfg);
481     uint32_t reg = p_reg->CONFIG.CFGSTATIC;
482 
483     p_cfg->outdrive =
484         (reg & AUXPLL_CONFIG_CFGSTATIC_OUTDRIVE_Msk) >> AUXPLL_CONFIG_CFGSTATIC_OUTDRIVE_Pos;
485 
486     p_cfg->current_tune =
487         (reg & AUXPLL_CONFIG_CFGSTATIC_SELCONSTANTI_Msk) >> AUXPLL_CONFIG_CFGSTATIC_SELCONSTANTI_Pos;
488 
489     p_cfg->sdm_off =
490         (reg & AUXPLL_CONFIG_CFGSTATIC_SDMOFF_Msk) >> AUXPLL_CONFIG_CFGSTATIC_SDMOFF_Pos;
491 
492     p_cfg->dither_off =
493         (reg & AUXPLL_CONFIG_CFGSTATIC_SDMDITHEROFF_Msk) >> AUXPLL_CONFIG_CFGSTATIC_SDMDITHEROFF_Pos;
494 
495     p_cfg->range = (nrf_auxpll_divider_range_t)((reg & AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Msk)
496                                       >> AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Pos);
497 }
498 
nrf_auxpll_config_set(NRF_AUXPLL_Type * p_reg,nrf_auxpll_config_t const * p_cfg)499 NRF_STATIC_INLINE void nrf_auxpll_config_set(NRF_AUXPLL_Type           * p_reg,
500                                              nrf_auxpll_config_t const * p_cfg)
501 {
502     NRFX_ASSERT(p_cfg);
503 
504     p_reg->CONFIG.CFGSTATIC =
505                     ((p_cfg->outdrive << AUXPLL_CONFIG_CFGSTATIC_OUTDRIVE_Pos)
506                       & AUXPLL_CONFIG_CFGSTATIC_OUTDRIVE_Msk)
507                   | ((p_cfg->current_tune << AUXPLL_CONFIG_CFGSTATIC_SELCONSTANTI_Pos)
508                       & AUXPLL_CONFIG_CFGSTATIC_SELCONSTANTI_Msk)
509                   | ((p_cfg->sdm_off << AUXPLL_CONFIG_CFGSTATIC_SDMOFF_Pos)
510                       & AUXPLL_CONFIG_CFGSTATIC_SDMOFF_Msk)
511                   | ((p_cfg->dither_off << AUXPLL_CONFIG_CFGSTATIC_SDMDITHEROFF_Pos)
512                       & AUXPLL_CONFIG_CFGSTATIC_SDMDITHEROFF_Msk)
513                   | ((p_cfg->range << AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Pos)
514                       & AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Msk);
515 }
516 
nrf_auxpll_trim_ctune_set(NRF_AUXPLL_Type * p_reg,uint8_t value)517 NRF_STATIC_INLINE void nrf_auxpll_trim_ctune_set(NRF_AUXPLL_Type * p_reg,
518                                                  uint8_t           value)
519 {
520     p_reg->TRIM.CTUNE = value;
521 }
522 
nrf_auxpll_trim_ctune_get(NRF_AUXPLL_Type const * p_reg)523 NRF_STATIC_INLINE uint8_t nrf_auxpll_trim_ctune_get(NRF_AUXPLL_Type const * p_reg)
524 {
525     return (uint8_t)p_reg->TRIM.CTUNE;
526 }
527 
nrf_auxpll_ctrl_frequency_set(NRF_AUXPLL_Type * p_reg,uint16_t value)528 NRF_STATIC_INLINE void nrf_auxpll_ctrl_frequency_set(NRF_AUXPLL_Type * p_reg,
529                                                      uint16_t          value)
530 {
531     p_reg->AUXPLLCTRL.FREQUENCY = value;
532 }
533 
nrf_auxpll_ctrl_frequency_get(NRF_AUXPLL_Type const * p_reg)534 NRF_STATIC_INLINE uint16_t nrf_auxpll_ctrl_frequency_get(NRF_AUXPLL_Type const * p_reg)
535 {
536     return (uint16_t)p_reg->AUXPLLCTRL.FREQUENCY;
537 }
538 
nrf_auxpll_ctrl_freqinc_set(NRF_AUXPLL_Type * p_reg,int8_t value)539 NRF_STATIC_INLINE void nrf_auxpll_ctrl_freqinc_set(NRF_AUXPLL_Type * p_reg,
540                                                    int8_t            value)
541 {
542     p_reg->AUXPLLCTRL.FREQINC = (uint8_t)value;
543 }
544 
nrf_auxpll_ctrl_freqinc_get(NRF_AUXPLL_Type const * p_reg)545 NRF_STATIC_INLINE int8_t nrf_auxpll_ctrl_freqinc_get(NRF_AUXPLL_Type const * p_reg)
546 {
547     return (int8_t)p_reg->AUXPLLCTRL.FREQINC;
548 }
549 
nrf_auxpll_ctrl_freqinc_period_set(NRF_AUXPLL_Type * p_reg,uint16_t value)550 NRF_STATIC_INLINE void nrf_auxpll_ctrl_freqinc_period_set(NRF_AUXPLL_Type * p_reg,
551                                                          uint16_t          value)
552 {
553     p_reg->AUXPLLCTRL.FREQINCPERIOD = value;
554 }
555 
nrf_auxpll_ctrl_freqinc_period_get(NRF_AUXPLL_Type const * p_reg)556 NRF_STATIC_INLINE uint16_t nrf_auxpll_ctrl_freqinc_period_get(NRF_AUXPLL_Type const * p_reg)
557 {
558     return (uint16_t)p_reg->AUXPLLCTRL.FREQINCPERIOD;
559 }
560 
nrf_auxpll_ctrl_outsel_set(NRF_AUXPLL_Type * p_reg,nrf_auxpll_ctrl_outsel_t value)561 NRF_STATIC_INLINE void nrf_auxpll_ctrl_outsel_set(NRF_AUXPLL_Type *        p_reg,
562                                                   nrf_auxpll_ctrl_outsel_t value)
563 {
564     p_reg->AUXPLLCTRL.OUTSEL = (value << AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Pos);
565 }
566 
nrf_auxpll_ctrl_outsel_get(NRF_AUXPLL_Type const * p_reg)567 NRF_STATIC_INLINE nrf_auxpll_ctrl_outsel_t nrf_auxpll_ctrl_outsel_get(NRF_AUXPLL_Type const * p_reg)
568 {
569     return (nrf_auxpll_ctrl_outsel_t)((p_reg->AUXPLLCTRL.OUTSEL & AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Msk) >>
570                                        AUXPLL_AUXPLLCTRL_OUTSEL_OUTSEL_Pos);
571 }
572 
nrf_auxpll_ctrl_mode_set(NRF_AUXPLL_Type * p_reg,nrf_auxpll_ctrl_mode_t value)573 NRF_STATIC_INLINE void nrf_auxpll_ctrl_mode_set(NRF_AUXPLL_Type *      p_reg,
574                                                 nrf_auxpll_ctrl_mode_t value)
575 {
576     p_reg->AUXPLLCTRL.MODE = value << AUXPLL_AUXPLLCTRL_MODE_MODECTRL_Pos;
577 }
578 
nrf_auxpll_ctrl_mode_get(NRF_AUXPLL_Type const * p_reg)579 NRF_STATIC_INLINE nrf_auxpll_ctrl_mode_t nrf_auxpll_ctrl_mode_get(NRF_AUXPLL_Type const * p_reg)
580 {
581     uint8_t val = (p_reg->AUXPLLCTRL.MODE & AUXPLL_AUXPLLCTRL_MODE_MODECTRL_Msk) >>
582                    AUXPLL_AUXPLLCTRL_MODE_MODECTRL_Pos;
583 
584     return (nrf_auxpll_ctrl_mode_t)val;
585 }
586 
nrf_auxpll_lock(NRF_AUXPLL_Type * p_reg)587 NRF_STATIC_INLINE void nrf_auxpll_lock(NRF_AUXPLL_Type * p_reg)
588 {
589     p_reg->MIRROR = AUXPLL_MIRROR_LOCK_Enabled;
590 }
591 
nrf_auxpll_unlock(NRF_AUXPLL_Type * p_reg)592 NRF_STATIC_INLINE void nrf_auxpll_unlock(NRF_AUXPLL_Type * p_reg)
593 {
594     p_reg->MIRROR = AUXPLL_MIRROR_LOCK_Disabled;
595 }
596 
nrf_auxpll_lock_check(NRF_AUXPLL_Type const * p_reg)597 NRF_STATIC_INLINE bool nrf_auxpll_lock_check(NRF_AUXPLL_Type const * p_reg)
598 {
599     return ((p_reg->MIRROR) & AUXPLL_MIRROR_LOCK_Enabled);
600 }
601 
nrf_auxpll_static_ratio_get(NRF_AUXPLL_Type const * p_reg)602 NRF_STATIC_INLINE uint8_t nrf_auxpll_static_ratio_get(NRF_AUXPLL_Type const * p_reg)
603 {
604     return ((p_reg->CONFIG.CFGSTATIC & AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Msk) >>
605             AUXPLL_CONFIG_CFGSTATIC_AUXPLLRANGE_Pos) + 3U;
606 }
607 
nrf_auxpll_mode_locked_check(NRF_AUXPLL_Type const * p_reg)608 NRF_STATIC_INLINE bool nrf_auxpll_mode_locked_check(NRF_AUXPLL_Type const * p_reg)
609 {
610     return (p_reg->STATUS & AUXPLL_STATUS_MODE_Msk) ==
611            (AUXPLL_STATUS_MODE_Locked << AUXPLL_STATUS_MODE_Pos);
612 }
613 
nrf_auxpll_running_check(NRF_AUXPLL_Type const * p_reg)614 NRF_STATIC_INLINE bool nrf_auxpll_running_check(NRF_AUXPLL_Type const * p_reg)
615 {
616     return (p_reg->STATUS & AUXPLL_STATUS_PLLRUNNING_Msk) ==
617            (AUXPLL_STATUS_PLLRUNNING_Running << AUXPLL_STATUS_PLLRUNNING_Pos);
618 }
619 
620 #endif // NRF_DECLARE_ONLY
621 
622 /** @} */
623 
624 #ifdef __cplusplus
625 }
626 #endif
627 
628 #endif  // NRF_AUXPLL_H__
629