rflib
cc13x1_cc26x1/driverlib/rfc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: rfc.h
3 * Revised: 2018-08-08 14:03:25 +0200 (Wed, 08 Aug 2018)
4 * Revision: 52338
5 *
6 * Description: Defines and prototypes for the RF Core.
7 *
8 * Copyright (c) 2015 - 2017, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 //*****************************************************************************
40 //
43 //
44 //*****************************************************************************
45 
46 #ifndef __RFC_H__
47 #define __RFC_H__
48 
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include <ti/devices/DeviceFamily.h>
63 #include DeviceFamily_constructPath(inc/hw_types.h)
64 #include DeviceFamily_constructPath(inc/hw_memmap.h)
65 #include DeviceFamily_constructPath(inc/hw_rfc_pwr.h)
66 #include DeviceFamily_constructPath(inc/hw_rfc_dbell.h)
67 #include DeviceFamily_constructPath(inc/hw_fcfg1.h)
68 #include DeviceFamily_constructPath(inc/hw_adi_3_refsys.h)
69 #include DeviceFamily_constructPath(inc/hw_adi.h)
70 #include DeviceFamily_constructPath(inc/hw_prcm.h)
71 #include "rf_common_cmd.h"
72 #include "rf_prop_cmd.h"
73 #include "rf_ble_cmd.h"
74 
75 // Definition of RFTRIM container
76 typedef struct {
77  uint32_t configIfAdc;
78  uint32_t configRfFrontend;
79  uint32_t configSynth;
80  uint32_t configRfCommon;
81  uint8_t loDivider;
82  uint8_t noTrim;
83 } rfTrim_t;
84 
85 // Definition of maximum search depth used by the RFCOverrideUpdate function
86 #define RFC_MAX_SEARCH_DEPTH 5
87 #define RFC_PA_TYPE_ADDRESS 0x21000385
88 #define RFC_PA_TYPE_MASK 0x04
89 #define RFC_PA_GAIN_ADDRESS 0x21000398
90 #define RFC_PA_GAIN_MASK 0x003FFFFF
91 #define RFC_FE_MODE_ESCAPE_VALUE 0xFF
92 #define RFC_FE_OVERRIDE_ADDRESS 0x0703
93 #define RFC_FE_OVERRIDE_MASK 0x0000FFFF
94 
95 //*****************************************************************************
96 //
97 // Support for DriverLib in ROM:
98 // This section renames all functions that are not "static inline", so that
99 // calling these functions will default to implementation in flash. At the end
100 // of this file a second renaming will change the defaults to implementation in
101 // ROM for available functions.
102 //
103 // To force use of the implementation in flash, e.g. for debugging:
104 // - Globally: Define DRIVERLIB_NOROM at project level
105 // - Per function: Use prefix "NOROM_" when calling the function
106 //
107 //*****************************************************************************
108 #if !defined(DOXYGEN)
109  #define RFCCpeIntGetAndClear NOROM_RFCCpeIntGetAndClear
110  #define RFCDoorbellSendTo NOROM_RFCDoorbellSendTo
111  #define RFCSynthPowerDown NOROM_RFCSynthPowerDown
112  #define RFCCpePatchReset NOROM_RFCCpePatchReset
113  #define RFCOverrideSearch NOROM_RFCOverrideSearch
114  #define RFCOverrideUpdate NOROM_RFCOverrideUpdate
115  #define RFCHwIntGetAndClear NOROM_RFCHwIntGetAndClear
116  #define RFCAnaDivTxOverride NOROM_RFCAnaDivTxOverride
117  #define RFCRfTrimRead NOROM_RFCRfTrimRead
118  #define RFCRfTrimSet NOROM_RFCRfTrimSet
119 #endif
120 
121 //*****************************************************************************
122 //
123 // API Functions and prototypes
124 //
125 //*****************************************************************************
126 
127 //*****************************************************************************
128 //
136 //
137 //*****************************************************************************
138 __STATIC_INLINE void
139 RFCClockEnable(void)
140 {
141  // Enable basic clocks to get the CPE run
142  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = RFC_PWR_PWMCLKEN_CPERAM
143  | RFC_PWR_PWMCLKEN_CPE
144  | RFC_PWR_PWMCLKEN_RFC;
145 }
146 
147 
148 //*****************************************************************************
149 //
161 //
162 //*****************************************************************************
163 __STATIC_INLINE void
164 RFCClockDisable(void)
165 {
166  // Disable all clocks
167  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x0;
168 }
169 
170 
171 //*****************************************************************************
172 //
174 //
175 //*****************************************************************************
176 __STATIC_INLINE void
177 RFCCpeIntClear(uint32_t ui32Mask)
178 {
179  // Clear the masked pending interrupts.
180  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = ~ui32Mask;
181 }
182 
183 
184 //*****************************************************************************
185 //
187 //
188 //*****************************************************************************
189 __STATIC_INLINE void
190 RFCHwIntClear(uint32_t ui32Mask)
191 {
192  // Clear the masked pending interrupts.
193  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = ~ui32Mask;
194 }
195 
196 
197 //*****************************************************************************
198 //
200 //
201 //*****************************************************************************
202 __STATIC_INLINE void
203 RFCCpe0IntSelect(uint32_t ui32Mask)
204 {
205  // Multiplex RF Core interrupts to CPE0 IRQ.
206  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) &= ~ui32Mask;
207 }
208 
209 
210 //*****************************************************************************
211 //
213 //
214 //*****************************************************************************
215 __STATIC_INLINE void
216 RFCCpe1IntSelect(uint32_t ui32Mask)
217 {
218  // Multiplex RF Core interrupts to CPE1 IRQ.
219  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) |= ui32Mask;
220 }
221 
222 
223 //*****************************************************************************
224 //
226 //
227 //*****************************************************************************
228 __STATIC_INLINE void
229 RFCCpeIntEnable(uint32_t ui32Mask)
230 {
231  // Enable CPE interrupts from RF Core.
232  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
233 }
234 
235 
236 //*****************************************************************************
237 //
239 //
240 //*****************************************************************************
241 __STATIC_INLINE void
242 RFCCpe0IntSelectClearEnable(uint32_t ui32Mask)
243 {
244  // Multiplex RF Core interrupts to CPE0 IRQ.
245  RFCCpe0IntSelect(ui32Mask);
246 
247  // Clear the masked interrupts.
248  RFCCpeIntClear(ui32Mask);
249 
250  // Enable the masked interrupts.
251  RFCCpeIntEnable(ui32Mask);
252 }
253 
254 
255 //*****************************************************************************
256 //
258 //
259 //*****************************************************************************
260 __STATIC_INLINE void
261 RFCCpe1IntSelectClearEnable(uint32_t ui32Mask)
262 {
263  // Multiplex RF Core interrupts to CPE1 IRQ.
264  RFCCpe1IntSelect(ui32Mask);
265 
266  // Clear the masked interrupts.
267  RFCCpeIntClear(ui32Mask);
268 
269  // Enable the masked interrupts.
270  RFCCpeIntEnable(ui32Mask);
271 }
272 
273 
274 //*****************************************************************************
275 //
277 //
278 //*****************************************************************************
279 __STATIC_INLINE void
280 RFCHwIntEnable(uint32_t ui32Mask)
281 {
282  // Enable the masked interrupts
283  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) |= ui32Mask;
284 }
285 
286 
287 //*****************************************************************************
288 //
290 //
291 //*****************************************************************************
292 __STATIC_INLINE void
293 RFCCpeIntDisable(uint32_t ui32Mask)
294 {
295  // Disable the masked interrupts
296  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) &= ~ui32Mask;
297 }
298 
299 
300 //*****************************************************************************
301 //
303 //
304 //*****************************************************************************
305 __STATIC_INLINE void
306 RFCHwIntDisable(uint32_t ui32Mask)
307 {
308  // Disable the masked interrupts
309  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) &= ~ui32Mask;
310 }
311 
312 
313 //*****************************************************************************
314 //
316 //
317 //*****************************************************************************
318 extern uint32_t RFCCpeIntGetAndClear(uint32_t ui32Mask);
319 
320 
321 //*****************************************************************************
322 //
324 //
325 //*****************************************************************************
326 __STATIC_INLINE void
327 RFCAckIntClear(void)
328 {
329  // Clear any pending interrupts.
330  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0x0;
331 }
332 
333 
334 //*****************************************************************************
335 //
337 //
338 //*****************************************************************************
339 extern uint32_t RFCDoorbellSendTo(uint32_t pOp);
340 
341 
342 //*****************************************************************************
343 //
345 //
346 //*****************************************************************************
347 extern void RFCSynthPowerDown(void);
348 
349 
350 //*****************************************************************************
351 //
353 //
354 //*****************************************************************************
355 extern void RFCCpePatchReset(void);
356 
357 
358 //*****************************************************************************
359 //
360 // Function to search an override list for the provided pattern within the search depth.
361 //
362 //*****************************************************************************
363 extern uint8_t RFCOverrideSearch(const uint32_t *pOverride, const uint32_t pattern, const uint32_t mask, const uint8_t searchDepth);
364 
365 
366 //*****************************************************************************
367 //
369 //
370 //*****************************************************************************
371 extern uint8_t RFCOverrideUpdate(rfc_radioOp_t *pOpSetup, uint32_t *pParams);
372 
373 
374 //*****************************************************************************
375 //
377 //
378 //*****************************************************************************
379 extern uint32_t RFCHwIntGetAndClear(uint32_t ui32Mask);
380 
381 
382 //*****************************************************************************
383 //
385 //
386 //*****************************************************************************
387 __STATIC_INLINE bool
388 RFCGetPaType(void)
389 {
390  return (bool)(HWREGB(RFC_PA_TYPE_ADDRESS) & RFC_PA_TYPE_MASK);
391 }
392 
393 //*****************************************************************************
394 //
396 //
397 //*****************************************************************************
398 __STATIC_INLINE uint32_t
399 RFCGetPaGain(void)
400 {
401  return (HWREG(RFC_PA_GAIN_ADDRESS) & RFC_PA_GAIN_MASK);
402 }
403 
404 //*****************************************************************************
405 //
407 //
408 //*****************************************************************************
409 __STATIC_INLINE uint32_t
411 {
412  return (HWREG(PRCM_BASE + PRCM_O_PDCTL1RFC) |
413  HWREG(PRCM_BASE + PRCM_O_PDSTAT0RFC));
414 }
415 
416 //*****************************************************************************
417 //
419 //
420 //*****************************************************************************
421 extern uint32_t RFCAnaDivTxOverride(uint8_t loDivider, uint8_t frontEndMode);
422 
423 
424 //*****************************************************************************
425 //
427 //
428 //*****************************************************************************
429 extern void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t *rfTrim);
430 
431 
432 //*****************************************************************************
433 //
435 //
436 //*****************************************************************************
437 extern void RFCRfTrimSet(rfTrim_t *rfTrim);
438 
439 
440 //*****************************************************************************
441 //
442 // Support for DriverLib in ROM:
443 // Redirect to implementation in ROM when available.
444 //
445 //*****************************************************************************
446 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
447  #include DeviceFamily_constructPath(driverlib/rom.h)
448  #ifdef ROM_RFCCpeIntGetAndClear
449  #undef RFCCpeIntGetAndClear
450  #define RFCCpeIntGetAndClear ROM_RFCCpeIntGetAndClear
451  #endif
452  #ifdef ROM_RFCDoorbellSendTo
453  #undef RFCDoorbellSendTo
454  #define RFCDoorbellSendTo ROM_RFCDoorbellSendTo
455  #endif
456  #ifdef ROM_RFCSynthPowerDown
457  #undef RFCSynthPowerDown
458  #define RFCSynthPowerDown ROM_RFCSynthPowerDown
459  #endif
460  #ifdef ROM_RFCCpePatchReset
461  #undef RFCCpePatchReset
462  #define RFCCpePatchReset ROM_RFCCpePatchReset
463  #endif
464  #ifdef ROM_RFCOverrideSearch
465  #undef RFCOverrideSearch
466  #define RFCOverrideSearch ROM_RFCOverrideSearch
467  #endif
468  #ifdef ROM_RFCOverrideUpdate
469  #undef RFCOverrideUpdate
470  #define RFCOverrideUpdate ROM_RFCOverrideUpdate
471  #endif
472  #ifdef ROM_RFCHwIntGetAndClear
473  #undef RFCHwIntGetAndClear
474  #define RFCHwIntGetAndClear ROM_RFCHwIntGetAndClear
475  #endif
476  #ifdef ROM_RFCAnaDivTxOverride
477  #undef RFCAnaDivTxOverride
478  #define RFCAnaDivTxOverride ROM_RFCAnaDivTxOverride
479  #endif
480  #ifdef ROM_RFCRfTrimRead
481  #undef RFCRfTrimRead
482  #define RFCRfTrimRead ROM_RFCRfTrimRead
483  #endif
484  #ifdef ROM_RFCRfTrimSet
485  #undef RFCRfTrimSet
486  #define RFCRfTrimSet ROM_RFCRfTrimSet
487  #endif
488 #endif
489 
490 //*****************************************************************************
491 //
492 // Mark the end of the C bindings section for C++ compilers.
493 //
494 //*****************************************************************************
495 #ifdef __cplusplus
496 }
497 #endif
498 
499 #endif // __RFC_H__
500 
501 //*****************************************************************************
502 //
505 //
506 //*****************************************************************************
__STATIC_INLINE void RFCHwIntDisable(uint32_t ui32Mask)
Disable HW interrupt sources.
Definition: cc13x2_cc26x2/driverlib/rfc.h:302
uint8_t loDivider
Definition: cc13x1_cc26x1/driverlib/rfc.h:81
#define RFCCpePatchReset
Definition: cc13x1_cc26x1/driverlib/rfc.h:112
__STATIC_INLINE void RFCHwIntClear(uint32_t ui32Mask)
Clear CPE interrupt flags.
Definition: cc13x2_cc26x2/driverlib/rfc.h:186
#define RFCOverrideSearch
Definition: cc13x1_cc26x1/driverlib/rfc.h:113
#define RFCRfTrimSet
Definition: cc13x1_cc26x1/driverlib/rfc.h:118
#define RFCAnaDivTxOverride
Definition: cc13x1_cc26x1/driverlib/rfc.h:116
#define RFC_PA_TYPE_ADDRESS
Definition: cc13x1_cc26x1/driverlib/rfc.h:87
#define RFCSynthPowerDown
Definition: cc13x1_cc26x1/driverlib/rfc.h:111
__STATIC_INLINE void RFCCpeIntClear(uint32_t ui32Mask)
Clear HW interrupt flags.
Definition: cc13x2_cc26x2/driverlib/rfc.h:173
#define RFCCpeIntGetAndClear
Definition: cc13x1_cc26x1/driverlib/rfc.h:109
__STATIC_INLINE void RFCClockDisable(void)
Disable the RF core clocks.
Definition: cc13x2_cc26x2/driverlib/rfc.h:160
__STATIC_INLINE void RFCCpe1IntSelectClearEnable(uint32_t ui32Mask)
Select, clear, and enable interrupt sources to CPE1.
Definition: cc13x2_cc26x2/driverlib/rfc.h:257
uint8_t noTrim
Definition: cc13x1_cc26x1/driverlib/rfc.h:82
__STATIC_INLINE void RFCCpeIntEnable(uint32_t ui32Mask)
Enable CPEx interrupt sources.
Definition: cc13x2_cc26x2/driverlib/rfc.h:225
__STATIC_INLINE void RFCHwIntEnable(uint32_t ui32Mask)
Enable HW interrupt sources.
Definition: cc13x2_cc26x2/driverlib/rfc.h:276
#define RFCDoorbellSendTo
Definition: cc13x1_cc26x1/driverlib/rfc.h:110
Definition: cc13x2_cc26x2/driverlib/rfc.h:76
__STATIC_INLINE bool RFCGetPaType(void)
Get the type of currently selected PA.
Definition: cc13x2_cc26x2/driverlib/rfc.h:384
uint32_t configRfCommon
Definition: cc13x1_cc26x1/driverlib/rfc.h:80
#define RFC_PA_GAIN_ADDRESS
Definition: cc13x1_cc26x1/driverlib/rfc.h:89
__STATIC_INLINE void RFCCpeIntDisable(uint32_t ui32Mask)
Disable CPE interrupt sources.
Definition: cc13x2_cc26x2/driverlib/rfc.h:289
__STATIC_INLINE void RFCAckIntClear(void)
Clear ACK interrupt flag.
Definition: cc13x2_cc26x2/driverlib/rfc.h:323
#define RFC_PA_TYPE_MASK
Definition: cc13x1_cc26x1/driverlib/rfc.h:88
__STATIC_INLINE void RFCClockEnable(void)
Enable the RF core clocks.
Definition: cc13x2_cc26x2/driverlib/rfc.h:135
__STATIC_INLINE uint32_t RFCGetPowerDomainStatus(void)
Get the power domain status of the radio core.
Definition: cc13x2_cc26x2/driverlib/rfc.h:406
__STATIC_INLINE void RFCCpe0IntSelectClearEnable(uint32_t ui32Mask)
Select, clear, and enable interrupt sources to CPE0.
Definition: cc13x2_cc26x2/driverlib/rfc.h:238
__STATIC_INLINE uint32_t RFCGetPaGain(void)
Get the gain of currently selected PA.
Definition: cc13x2_cc26x2/driverlib/rfc.h:395
__STATIC_INLINE void RFCCpe1IntSelect(uint32_t ui32Mask)
Select interrupt sources to CPE1 (assign to INT_RFC_CPE_1 interrupt vector).
Definition: cc13x2_cc26x2/driverlib/rfc.h:212
Definition: cc13x2_cc26x2/driverlib/rf_common_cmd.h:122
#define RFCOverrideUpdate
Definition: cc13x1_cc26x1/driverlib/rfc.h:114
#define RFC_PA_GAIN_MASK
Definition: cc13x1_cc26x1/driverlib/rfc.h:90
#define RFCHwIntGetAndClear
Definition: cc13x1_cc26x1/driverlib/rfc.h:115
__STATIC_INLINE void RFCCpe0IntSelect(uint32_t ui32Mask)
Select interrupt sources to CPE0 (assign to INT_RFC_CPE_0 interrupt vector).
Definition: cc13x2_cc26x2/driverlib/rfc.h:199
#define RFCRfTrimRead
Definition: cc13x1_cc26x1/driverlib/rfc.h:117
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale