1 /******************************************************************************
2 * Filename: ckmd.h
3 *
4 * Description: Defines and prototypes for the CKMD module.
5 *
6 * Copyright (c) 2023 Texas Instruments Incorporated
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1) Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * 2) Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * 3) Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ******************************************************************************/
35
36 #ifndef __CKMD_H__
37 #define __CKMD_H__
38
39 //*****************************************************************************
40 //
41 //! \addtogroup system_control_group
42 //! @{
43 //! \addtogroup ckmd_api
44 //! @{
45 //
46 //*****************************************************************************
47
48 //*****************************************************************************
49 //
50 // If building with a C++ compiler, make all of the definitions in this header
51 // have a C binding.
52 //
53 //*****************************************************************************
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 #include <stdbool.h>
59 #include <stdint.h>
60
61 #include "../inc/hw_types.h"
62 #include "../inc/hw_memmap.h"
63 #include "../inc/hw_ckmd.h"
64 #include "../inc/hw_fcfg.h"
65
66 //*****************************************************************************
67 //
68 //! \name LFOSC Temperature Coefficient Temperature Limits
69 //!
70 //! If the temperature in Celsius is within the range [
71 //! \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MIN,
72 //! \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MAX ], inclusive, then the
73 //! temperature coefficient \ref CKMDGetLfoscMidTempCoefficientPpmPerC() shall
74 //! be used, otherwise \ref CKMDGetLfoscExtTempCoefficientPpmPerC().
75 //!
76 //! If \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MIN is INT16_MIN, then there is no
77 //! lower limit for the above mentioned temperature range.
78 //!
79 //! If \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MAX is INT16_MAX, then there is no
80 //! upper limit for the above mentioned temperature range.
81 //!
82 //! \{
83 //
84 //*****************************************************************************
85 #define CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MIN (INT16_MIN)
86 #define CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MAX (70)
87 //! \}
88
89 //*****************************************************************************
90 //
91 // API Functions and prototypes
92 //
93 //*****************************************************************************
94
95 //*****************************************************************************
96 //
97 //! \brief Sets initial HFXT capacitor ramp trims
98 //!
99 //! This function sets the initial HFXT capacitor ramp trims. It will
100 //! overwrite the initial HFXT ramp trim values set during startup.
101 //!
102 //! This trim value is used when initially turning on the HFXT.
103 //!
104 //! \note The value for \c capTrim must be found experimentally based on the
105 //! chosen crystal and desired ramp behaviour.
106 //!
107 //! \param q1CapTrim Initial Q1 capacitor trim.
108 //! \param q2CapTrim Initial Q2 capacitor trim.
109 //!
110 //! \return None
111 //!
112 //! \sa CKMD_O_HFXTINIT for trim range
113 //
114 //*****************************************************************************
CKMDSetInitialCapTrim(uint32_t q1CapTrim,uint32_t q2CapTrim)115 __STATIC_INLINE void CKMDSetInitialCapTrim(uint32_t q1CapTrim, uint32_t q2CapTrim)
116 {
117 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & ~(CKMD_HFXTINIT_Q1CAP_M | CKMD_HFXTINIT_Q2CAP_M);
118 tmp |= (q1CapTrim << CKMD_HFXTINIT_Q1CAP_S) & CKMD_HFXTINIT_Q1CAP_M;
119 tmp |= (q2CapTrim << CKMD_HFXTINIT_Q2CAP_S) & CKMD_HFXTINIT_Q2CAP_M;
120 HWREG(CKMD_BASE + CKMD_O_HFXTINIT) = tmp;
121 }
122
123 //*****************************************************************************
124 //
125 //! \brief Sets initial HFXT Q1 capacitor ramp trim
126 //!
127 //! This function sets the initial HFXT Q1 capacitor ramp trim. It will
128 //! overwrite the initial HFXT ramp trim value set during startup.
129 //!
130 //! This trim value is used when initially turning on the HFXT.
131 //!
132 //! \note The value for \c q1Cap must be found experimentally based on the
133 //! chosen crystal and desired ramp behaviour.
134 //!
135 //! \param q1Cap Initial Q1 capacitor trim.
136 //!
137 //! \return None
138 //!
139 //! \sa CKMD_O_HFXTINIT for trim range
140 //
141 //*****************************************************************************
CKMDSetInitialQ1CapTrim(uint32_t q1Cap)142 __STATIC_INLINE void CKMDSetInitialQ1CapTrim(uint32_t q1Cap)
143 {
144 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & ~CKMD_HFXTINIT_Q1CAP_M;
145 tmp |= (q1Cap << CKMD_HFXTINIT_Q1CAP_S) & CKMD_HFXTINIT_Q1CAP_M;
146 HWREG(CKMD_BASE + CKMD_O_HFXTINIT) = tmp;
147 }
148
149 //*****************************************************************************
150 //
151 //! \brief Sets initial HFXT Q2 capacitor ramp trim
152 //!
153 //! This function sets the initial HFXT Q2 capacitor ramp trim. It will
154 //! overwrite the initial HFXT ramp trim value set during startup.
155 //!
156 //! This trim value is used when initially turning on the HFXT.
157 //!
158 //! \note The value for \c q2Cap must be found experimentally based on the
159 //! chosen crystal and desired ramp behaviour.
160 //!
161 //! \param q2Cap Initial Q2 capacitor trim.
162 //!
163 //! \return None
164 //!
165 //! \sa CKMD_O_HFXTINIT for trim range
166 //
167 //*****************************************************************************
CKMDSetInitialQ2CapTrim(uint32_t q2Cap)168 __STATIC_INLINE void CKMDSetInitialQ2CapTrim(uint32_t q2Cap)
169 {
170 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & ~CKMD_HFXTINIT_Q2CAP_M;
171 tmp |= (q2Cap << CKMD_HFXTINIT_Q2CAP_S) & CKMD_HFXTINIT_Q2CAP_M;
172 HWREG(CKMD_BASE + CKMD_O_HFXTINIT) = tmp;
173 }
174
175 //*****************************************************************************
176 //
177 //! \brief Sets initial HFXT IREF ramp trim
178 //!
179 //! This function sets initial HFXT IREF ramp trim. It will overwrite the
180 //! initial HFXT ramp trim value set during startup.
181 //!
182 //! This trim value is used when initially turning on the HFXT.
183 //!
184 //! \note The value for \c iref must be found experimentally based on the
185 //! chosen crystal and desired ramp behaviour.
186 //!
187 //! \param iref Initial IREF trim.
188 //!
189 //! \return None
190 //!
191 //! \sa CKMD_O_HFXTINIT for trim range
192 //
193 //*****************************************************************************
CKMDSetInitialIrefTrim(uint32_t iref)194 __STATIC_INLINE void CKMDSetInitialIrefTrim(uint32_t iref)
195 {
196 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & ~CKMD_HFXTINIT_IREF_M;
197 tmp |= (iref << CKMD_HFXTINIT_IREF_S) & CKMD_HFXTINIT_IREF_M;
198 HWREG(CKMD_BASE + CKMD_O_HFXTINIT) = tmp;
199 }
200
201 //*****************************************************************************
202 //
203 //! \brief Sets initial HFXT IDAC ramp trim
204 //!
205 //! This function sets the initial HFXT IDAC ramp trim. It will overwrite the
206 //! initial HFXT ramp trim value set during startup.
207 //!
208 //! This trim value is used when initially turning on the HFXT.
209 //!
210 //! \note The value for \c idac must be found experimentally based on the
211 //! chosen crystal and desired ramp behaviour.
212 //!
213 //! \param idac Initial IDAC trim.
214 //!
215 //! \return None
216 //!
217 //! \sa CKMD_O_HFXTINIT for trim range
218 //
219 //*****************************************************************************
CKMDSetInitialIdacTrim(uint32_t idac)220 __STATIC_INLINE void CKMDSetInitialIdacTrim(uint32_t idac)
221 {
222 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & ~CKMD_HFXTINIT_IDAC_M;
223 tmp |= (idac << CKMD_HFXTINIT_IDAC_S) & CKMD_HFXTINIT_IDAC_M;
224 HWREG(CKMD_BASE + CKMD_O_HFXTINIT) = tmp;
225 }
226
227 //*****************************************************************************
228 //
229 //! \brief Sets initial HFXT amplitude threshold ramp trim
230 //!
231 //! This function sets the initial HFXT amplitude threshold ramp trim. It will
232 //! overwrite the initial HFXT ramp trim value set during startup.
233 //!
234 //! This trim value is used when initially turning on the HFXT.
235 //!
236 //! \note The value for \c amplitudeThreshold must be found experimentally based
237 //! on the chosen crystal and desired ramp behaviour.
238 //!
239 //! \param amplitudeThreshold Initial amplitude threshold trim.
240 //!
241 //! \return None
242 //!
243 //! \sa CKMD_O_HFXTINIT for trim range
244 //
245 //*****************************************************************************
CKMDSetInitialAmplitudeThresholdTrim(uint32_t amplitudeThreshold)246 __STATIC_INLINE void CKMDSetInitialAmplitudeThresholdTrim(uint32_t amplitudeThreshold)
247 {
248 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & ~CKMD_HFXTINIT_AMPTHR_M;
249 tmp |= (amplitudeThreshold << CKMD_HFXTINIT_AMPTHR_S) & CKMD_HFXTINIT_AMPTHR_M;
250 HWREG(CKMD_BASE + CKMD_O_HFXTINIT) = tmp;
251 }
252
253 //*****************************************************************************
254 //
255 //! \brief Gets initial HFXT Q1 capacitor ramp trim
256 //!
257 //! This function gets the initial HFXT Q1 capacitor ramp trim.
258 //!
259 //! \return Initial Q1 capacitor trim.
260 //!
261 //! \sa CKMD_O_HFXTINIT for trim range
262 //
263 //*****************************************************************************
CKMDGetInitialQ1CapTrim(void)264 __STATIC_INLINE uint32_t CKMDGetInitialQ1CapTrim(void)
265 {
266 return (HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & CKMD_HFXTINIT_Q1CAP_M) >> CKMD_HFXTINIT_Q1CAP_S;
267 }
268
269 //*****************************************************************************
270 //
271 //! \brief Gets initial HFXT Q2 capacitor ramp trim
272 //!
273 //! This function gets the initial HFXT Q2 capacitor ramp trim.
274 //!
275 //! \return Initial Q2 capacitor trim.
276 //!
277 //! \sa CKMD_O_HFXTINIT for trim range
278 //
279 //*****************************************************************************
CKMDGetInitialQ2CapTrim(void)280 __STATIC_INLINE uint32_t CKMDGetInitialQ2CapTrim(void)
281 {
282 return (HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & CKMD_HFXTINIT_Q2CAP_M) >> CKMD_HFXTINIT_Q2CAP_S;
283 }
284
285 //*****************************************************************************
286 //
287 //! \brief Gets initial HFXT IREF ramp trim
288 //!
289 //! This function gets the initial HFXT IREF ramp trim.
290 //!
291 //! \return Initial IREF trim.
292 //!
293 //! \sa CKMD_O_HFXTINIT for trim range
294 //
295 //*****************************************************************************
CKMDGetInitialIrefTrim(void)296 __STATIC_INLINE uint32_t CKMDGetInitialIrefTrim(void)
297 {
298 return (HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & CKMD_HFXTINIT_IREF_M) >> CKMD_HFXTINIT_IREF_S;
299 }
300
301 //*****************************************************************************
302 //
303 //! \brief Gets initial HFXT IDAC ramp trim
304 //!
305 //! This function gets the initial HFXT IDAC ramp trim.
306 //!
307 //! \return Initial IDAC trim.
308 //!
309 //! \sa CKMD_O_HFXTINIT for trim range
310 //
311 //*****************************************************************************
CKMDGetInitialIdacTrim(void)312 __STATIC_INLINE uint32_t CKMDGetInitialIdacTrim(void)
313 {
314 return (HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & CKMD_HFXTINIT_IDAC_M) >> CKMD_HFXTINIT_IDAC_S;
315 }
316
317 //*****************************************************************************
318 //
319 //! \brief Gets initial HFXT amplitude threshold ramp trim
320 //!
321 //! This function initial HFXT amplitude threshold ramp trim.
322 //!
323 //! \return Initial amplitude threshold trim.
324 //!
325 //! \sa CKMD_O_HFXTINIT for trim range
326 //
327 //*****************************************************************************
CKMDGetInitialAmplitudeThresholdTrim(void)328 __STATIC_INLINE uint32_t CKMDGetInitialAmplitudeThresholdTrim(void)
329 {
330 return (HWREG(CKMD_BASE + CKMD_O_HFXTINIT) & CKMD_HFXTINIT_AMPTHR_M) >> CKMD_HFXTINIT_AMPTHR_S;
331 }
332
333 //*****************************************************************************
334 //
335 //! \brief Sets target HFXT capacitor ramp trims
336 //!
337 //! This function sets the target HFXT capacitor ramp trims. It will
338 //! overwrite the target HFXT ramp trim values set during startup.
339 //!
340 //! This trim value is used when target turning on the HFXT.
341 //!
342 //! \note The value for \c capTrim must be found experimentally based on the
343 //! chosen crystal and desired ramp behaviour.
344 //!
345 //! \param q1CapTrim Target Q1 capacitor trim.
346 //! \param q2CapTrim Target Q2 capacitor trim.
347 //!
348 //! \return None
349 //!
350 //! \sa CKMD_O_HFXTTARG for trim range
351 //
352 //*****************************************************************************
CKMDSetTargetCapTrim(uint32_t q1CapTrim,uint32_t q2CapTrim)353 __STATIC_INLINE void CKMDSetTargetCapTrim(uint32_t q1CapTrim, uint32_t q2CapTrim)
354 {
355 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & ~(CKMD_HFXTTARG_Q1CAP_M | CKMD_HFXTTARG_Q2CAP_M);
356 tmp |= (q1CapTrim << CKMD_HFXTTARG_Q1CAP_S) & CKMD_HFXTTARG_Q1CAP_M;
357 tmp |= (q2CapTrim << CKMD_HFXTTARG_Q2CAP_S) & CKMD_HFXTTARG_Q2CAP_M;
358 HWREG(CKMD_BASE + CKMD_O_HFXTTARG) = tmp;
359 }
360
361 //*****************************************************************************
362 //
363 //! \brief Sets target HFXT Q1 capacitor ramp trim
364 //!
365 //! This function target HFXT Q1 capacitor ramp trim. It will overwrite the
366 //! target HFXT ramp trim value set during startup.
367 //!
368 //! This trim value is used after HFXT has ramped to change crystal performance.
369 //!
370 //! \note The value for \c q1Cap must be found experimentally based on the
371 //! chosen crystal and desired ramp behaviour.
372 //!
373 //! \param q1Cap Target Q1 capacitor trim.
374 //!
375 //! \return None
376 //
377 //*****************************************************************************
CKMDSetTargetQ1CapTrim(uint32_t q1Cap)378 __STATIC_INLINE void CKMDSetTargetQ1CapTrim(uint32_t q1Cap)
379 {
380 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & ~CKMD_HFXTTARG_Q1CAP_M;
381 tmp |= (q1Cap << CKMD_HFXTTARG_Q1CAP_S) & CKMD_HFXTTARG_Q1CAP_M;
382 HWREG(CKMD_BASE + CKMD_O_HFXTTARG) = tmp;
383 }
384
385 //*****************************************************************************
386 //
387 //! \brief Sets target HFXT Q2 capacitor ramp trim
388 //!
389 //! This function target HFXT Q2 capacitor ramp trim. It will overwrite the
390 //! target HFXT ramp trim value set during startup.
391 //!
392 //! This trim value is used after HFXT has ramped to change crystal performance.
393 //!
394 //! \note The value for \c q2Cap must be found experimentally based on the
395 //! chosen crystal and desired ramp behaviour.
396 //!
397 //! \param q2Cap Target Q2 capacitor trim.
398 //!
399 //! \return None
400 //
401 //*****************************************************************************
CKMDSetTargetQ2CapTrim(uint32_t q2Cap)402 __STATIC_INLINE void CKMDSetTargetQ2CapTrim(uint32_t q2Cap)
403 {
404 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & ~CKMD_HFXTTARG_Q2CAP_M;
405 tmp |= (q2Cap << CKMD_HFXTTARG_Q2CAP_S) & CKMD_HFXTTARG_Q2CAP_M;
406 HWREG(CKMD_BASE + CKMD_O_HFXTTARG) = tmp;
407 }
408
409 //*****************************************************************************
410 //
411 //! \brief Sets target HFXT IREF ramp trim
412 //!
413 //! This function target HFXT IREF ramp trim. It will overwrite the target
414 //! HFXT ramp trim value set during startup.
415 //!
416 //! This trim value is used after HFXT has ramped to change crystal performance.
417 //!
418 //! \note The value for \c iref must be found experimentally based on the
419 //! chosen crystal and desired ramp behaviour.
420 //!
421 //! \param iref Target IREF trim.
422 //!
423 //! \return None
424 //
425 //*****************************************************************************
CKMDSetTargetIrefTrim(uint32_t iref)426 __STATIC_INLINE void CKMDSetTargetIrefTrim(uint32_t iref)
427 {
428 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & ~CKMD_HFXTTARG_IREF_M;
429 tmp |= (iref << CKMD_HFXTTARG_IREF_S) & CKMD_HFXTTARG_IREF_M;
430 HWREG(CKMD_BASE + CKMD_O_HFXTTARG) = tmp;
431 }
432
433 //*****************************************************************************
434 //
435 //! \brief Sets target HFXT IDAC ramp trim
436 //!
437 //! This function target HFXT IDAC ramp trim. It will overwrite the target
438 //! HFXT ramp trim value set during startup.
439 //!
440 //! This trim value is used after HFXT has ramped to change crystal performance.
441 //!
442 //! \note The value for \c idac must be found experimentally based on the
443 //! chosen crystal and desired ramp behaviour.
444 //!
445 //! \param idac Target IDAC trim.
446 //!
447 //! \return None
448 //
449 //*****************************************************************************
CKMDSetTargetIdacTrim(uint32_t idac)450 __STATIC_INLINE void CKMDSetTargetIdacTrim(uint32_t idac)
451 {
452 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & ~CKMD_HFXTTARG_IDAC_M;
453 tmp |= (idac << CKMD_HFXTTARG_IDAC_S) & CKMD_HFXTTARG_IDAC_M;
454 HWREG(CKMD_BASE + CKMD_O_HFXTTARG) = tmp;
455 }
456
457 //*****************************************************************************
458 //
459 //! \brief Sets target HFXT amplitude threshold ramp trim
460 //!
461 //! This function target HFXT amplitude threshold ramp trim. It will overwrite
462 //! the target HFXT ramp trim value set during startup.
463 //!
464 //! This trim value is used after HFXT has ramped to change crystal performance.
465 //!
466 //! \note The value for \c amplitudeThreshold must be found experimentally based
467 //! on the chosen crystal and desired ramp behaviour.
468 //!
469 //! \param amplitudeThreshold Target amplitude threshold trim.
470 //!
471 //! \return None
472 //
473 //*****************************************************************************
CKMDSetTargetAmplitudeThresholdTrim(uint32_t amplitudeThreshold)474 __STATIC_INLINE void CKMDSetTargetAmplitudeThresholdTrim(uint32_t amplitudeThreshold)
475 {
476 uint32_t tmp = HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & ~CKMD_HFXTTARG_AMPTHR_M;
477 tmp |= (amplitudeThreshold << CKMD_HFXTTARG_AMPTHR_S) & CKMD_HFXTTARG_AMPTHR_M;
478 HWREG(CKMD_BASE + CKMD_O_HFXTTARG) = tmp;
479 }
480
481 //*****************************************************************************
482 //
483 //! \brief Gets target HFXT Q1 capacitor ramp trim
484 //!
485 //! This function gets the target HFXT Q1 capacitor ramp trim.
486 //!
487 //! \return Target Q1 capacitor trim.
488 //!
489 //! \sa CKMD_O_HFXTTARG for trim range
490 //
491 //*****************************************************************************
CKMDGetTargetQ1CapTrim(void)492 __STATIC_INLINE uint32_t CKMDGetTargetQ1CapTrim(void)
493 {
494 return (HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & CKMD_HFXTTARG_Q1CAP_M) >> CKMD_HFXTTARG_Q1CAP_S;
495 }
496
497 //*****************************************************************************
498 //
499 //! \brief Gets target HFXT Q2 capacitor ramp trim
500 //!
501 //! This function gets the target HFXT Q2 capacitor ramp trim.
502 //!
503 //! \return Target Q2 capacitor trim.
504 //!
505 //! \sa CKMD_O_HFXTTARG for trim range
506 //
507 //*****************************************************************************
CKMDGetTargetQ2CapTrim(void)508 __STATIC_INLINE uint32_t CKMDGetTargetQ2CapTrim(void)
509 {
510 return (HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & CKMD_HFXTTARG_Q2CAP_M) >> CKMD_HFXTTARG_Q2CAP_S;
511 }
512
513 //*****************************************************************************
514 //
515 //! \brief Gets target HFXT IREF ramp trim
516 //!
517 //! This function gets the target HFXT IREF ramp trim.
518 //!
519 //! \return Target IREF trim.
520 //!
521 //! \sa CKMD_O_HFXTTARG for trim range
522 //
523 //*****************************************************************************
CKMDGetTargetIrefTrim(void)524 __STATIC_INLINE uint32_t CKMDGetTargetIrefTrim(void)
525 {
526 return (HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & CKMD_HFXTTARG_IREF_M) >> CKMD_HFXTTARG_IREF_S;
527 }
528
529 //*****************************************************************************
530 //
531 //! \brief Gets target HFXT IDAC ramp trim
532 //!
533 //! This function gets the target HFXT IDAC ramp trim.
534 //!
535 //! \return Target IDAC trim.
536 //!
537 //! \sa CKMD_O_HFXTTARG for trim range
538 //
539 //*****************************************************************************
CKMDGetTargetIdacTrim(void)540 __STATIC_INLINE uint32_t CKMDGetTargetIdacTrim(void)
541 {
542 return (HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & CKMD_HFXTTARG_IDAC_M) >> CKMD_HFXTTARG_IDAC_S;
543 }
544
545 //*****************************************************************************
546 //
547 //! \brief Gets target HFXT amplitude threshold ramp trim
548 //!
549 //! This function target HFXT amplitude threshold ramp trim.
550 //!
551 //! \return Target amplitude threshold trim.
552 //!
553 //! \sa CKMD_O_HFXTTARG for trim range
554 //
555 //*****************************************************************************
CKMDGetTargetAmplitudeThresholdTrim(void)556 __STATIC_INLINE uint32_t CKMDGetTargetAmplitudeThresholdTrim(void)
557 {
558 return (HWREG(CKMD_BASE + CKMD_O_HFXTTARG) & CKMD_HFXTTARG_AMPTHR_M) >> CKMD_HFXTTARG_AMPTHR_S;
559 }
560
561 //*****************************************************************************
562 //
563 //! \brief Gets the worst-case LFOSC frequency jump due to RTN.
564 //!
565 //! \return The absolute value of the worst-case jump due to RTN in ppm.
566 //
567 //*****************************************************************************
CKMDGetLfoscRtnPpm(void)568 __STATIC_INLINE uint_least16_t CKMDGetLfoscRtnPpm(void)
569 {
570 // Only App trims revision 5 and newer has a ppmRtn field. For older
571 // revisions use a default value of 20 (equivalent to 600ppm)
572 uint8_t ppmRtn = 20;
573 if (fcfg->appTrims.revision >= 0x5)
574 {
575 ppmRtn = fcfg->appTrims.cc23x0r5.lfOscParams.ppmRtn;
576 }
577
578 // The ppmTempMid field uses units of 30ppm, convert to ppm
579 return ppmRtn * 30;
580 }
581
582 //*****************************************************************************
583 //
584 //! \brief Gets the the worst-case LFOSC temperature coefficient in the "middle"
585 //! temperature range.
586 //!
587 //! This function can be used to determine the the worst-case LFOSC temperature
588 //! coefficient in units of ppm/C in the temperature range [
589 //! \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MIN,
590 //! \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MAX ].
591 //!
592 //! \return The absolute value of worst-case temperature coefficient in ppm/C.
593 //
594 //*****************************************************************************
CKMDGetLfoscMidTempCoefficientPpmPerC(void)595 __STATIC_INLINE uint_least16_t CKMDGetLfoscMidTempCoefficientPpmPerC(void)
596 {
597 // Only App trims revision 5 and newer has a ppmTempMid field. For older
598 // revisions use a default value of 20 (equivalent to 260ppm/C)
599 uint8_t ppmTempMid = 20;
600 if (fcfg->appTrims.revision >= 0x5)
601 {
602 ppmTempMid = fcfg->appTrims.cc23x0r5.lfOscParams.ppmTempMid;
603 }
604
605 // The ppmTempMid field uses units of 13ppm/C, convert to ppm/C
606 return ppmTempMid * 13;
607 }
608
609 //*****************************************************************************
610 //
611 //! \brief Gets the the worst-case LFOSC temperature coefficient in the
612 //! "extended" temperature range.
613 //!
614 //! This function can be used to determine the the worst-case LFOSC temperature
615 //! coefficient in units of ppm/C when the temperature is outside of the
616 //! temperature range [
617 //! \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MIN,
618 //! \ref CKMD_LFOSC_MID_TEMP_COEFFICIENT_RANGE_MAX ].
619 //!
620 //! \return The absolute value of worst-case temperature coefficient in ppm/C.
621 //
622 //*****************************************************************************
CKMDGetLfoscExtTempCoefficientPpmPerC(void)623 __STATIC_INLINE uint_least16_t CKMDGetLfoscExtTempCoefficientPpmPerC(void)
624 {
625 // Only App trims revision 5 and newer has a ppmTempExt field. For older
626 // revisions use a default value of 20 (equivalent to 700ppm/C)
627 uint8_t ppmTempExt = 20;
628 if (fcfg->appTrims.revision >= 0x5)
629 {
630 ppmTempExt = fcfg->appTrims.cc23x0r5.lfOscParams.ppmTempExt;
631 }
632
633 // The ppmTempExt field uses units of 35ppm/C, convert to ppm/C
634 return ppmTempExt * 35;
635 }
636
637 //*****************************************************************************
638 //
639 // Mark the end of the C bindings section for C++ compilers.
640 //
641 //*****************************************************************************
642 #ifdef __cplusplus
643 }
644 #endif
645
646 //*****************************************************************************
647 //
648 //! Close the Doxygen group.
649 //! @}
650 //! @}
651 //
652 //*****************************************************************************
653
654 #endif // __CKMD_H__
655