rflib
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 configMiscAdc;
81 } rfTrim_t;
82 
83 // Definition of maximum search depth used by the RFCOverrideUpdate function
84 #define RFC_MAX_SEARCH_DEPTH 5
85 #define RFC_PA_TYPE_ADDRESS 0x21000385
86 #define RFC_PA_TYPE_MASK 0x04
87 #define RFC_PA_GAIN_ADDRESS 0x21000398
88 #define RFC_PA_GAIN_MASK 0x003FFFFF
89 #define RFC_FE_MODE_ESCAPE_VALUE 0xFF
90 #define RFC_FE_OVERRIDE_ADDRESS 0x0703
91 #define RFC_FE_OVERRIDE_MASK 0x0000FFFF
92 
93 //*****************************************************************************
94 //
95 // Support for DriverLib in ROM:
96 // This section renames all functions that are not "static inline", so that
97 // calling these functions will default to implementation in flash. At the end
98 // of this file a second renaming will change the defaults to implementation in
99 // ROM for available functions.
100 //
101 // To force use of the implementation in flash, e.g. for debugging:
102 // - Globally: Define DRIVERLIB_NOROM at project level
103 // - Per function: Use prefix "NOROM_" when calling the function
104 //
105 //*****************************************************************************
106 #if !defined(DOXYGEN)
107  #define RFCCpeIntGetAndClear NOROM_RFCCpeIntGetAndClear
108  #define RFCDoorbellSendTo NOROM_RFCDoorbellSendTo
109  #define RFCSynthPowerDown NOROM_RFCSynthPowerDown
110  #define RFCCpePatchReset NOROM_RFCCpePatchReset
111  #define RFCOverrideSearch NOROM_RFCOverrideSearch
112  #define RFCOverrideUpdate NOROM_RFCOverrideUpdate
113  #define RFCHwIntGetAndClear NOROM_RFCHwIntGetAndClear
114  #define RFCAnaDivTxOverride NOROM_RFCAnaDivTxOverride
115 #endif
116 
117 //*****************************************************************************
118 //
119 // API Functions and prototypes
120 //
121 //*****************************************************************************
122 
123 //*****************************************************************************
124 //
132 //
133 //*****************************************************************************
134 __STATIC_INLINE void
136 {
137  // Enable basic clocks to get the CPE run
138  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = RFC_PWR_PWMCLKEN_CPERAM
139  | RFC_PWR_PWMCLKEN_CPE
140  | RFC_PWR_PWMCLKEN_RFC;
141 }
142 
143 
144 //*****************************************************************************
145 //
157 //
158 //*****************************************************************************
159 __STATIC_INLINE void
161 {
162  // Disable all clocks
163  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x0;
164 }
165 
166 
167 //*****************************************************************************
168 //
170 //
171 //*****************************************************************************
172 __STATIC_INLINE void
173 RFCCpeIntClear(uint32_t ui32Mask)
174 {
175  // Clear the masked pending interrupts.
176  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = ~ui32Mask;
177 }
178 
179 
180 //*****************************************************************************
181 //
183 //
184 //*****************************************************************************
185 __STATIC_INLINE void
186 RFCHwIntClear(uint32_t ui32Mask)
187 {
188  // Clear the masked pending interrupts.
189  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = ~ui32Mask;
190 }
191 
192 
193 //*****************************************************************************
194 //
196 //
197 //*****************************************************************************
198 __STATIC_INLINE void
199 RFCCpe0IntSelect(uint32_t ui32Mask)
200 {
201  // Multiplex RF Core interrupts to CPE0 IRQ.
202  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) &= ~ui32Mask;
203 }
204 
205 
206 //*****************************************************************************
207 //
209 //
210 //*****************************************************************************
211 __STATIC_INLINE void
212 RFCCpe1IntSelect(uint32_t ui32Mask)
213 {
214  // Multiplex RF Core interrupts to CPE1 IRQ.
215  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) |= ui32Mask;
216 }
217 
218 
219 //*****************************************************************************
220 //
222 //
223 //*****************************************************************************
224 __STATIC_INLINE void
225 RFCCpeIntEnable(uint32_t ui32Mask)
226 {
227  // Enable CPE interrupts from RF Core.
228  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
229 }
230 
231 
232 //*****************************************************************************
233 //
235 //
236 //*****************************************************************************
237 __STATIC_INLINE void
238 RFCCpe0IntSelectClearEnable(uint32_t ui32Mask)
239 {
240  // Multiplex RF Core interrupts to CPE0 IRQ.
241  RFCCpe0IntSelect(ui32Mask);
242 
243  // Clear the masked interrupts.
244  RFCCpeIntClear(ui32Mask);
245 
246  // Enable the masked interrupts.
247  RFCCpeIntEnable(ui32Mask);
248 }
249 
250 
251 //*****************************************************************************
252 //
254 //
255 //*****************************************************************************
256 __STATIC_INLINE void
257 RFCCpe1IntSelectClearEnable(uint32_t ui32Mask)
258 {
259  // Multiplex RF Core interrupts to CPE1 IRQ.
260  RFCCpe1IntSelect(ui32Mask);
261 
262  // Clear the masked interrupts.
263  RFCCpeIntClear(ui32Mask);
264 
265  // Enable the masked interrupts.
266  RFCCpeIntEnable(ui32Mask);
267 }
268 
269 
270 //*****************************************************************************
271 //
273 //
274 //*****************************************************************************
275 __STATIC_INLINE void
276 RFCHwIntEnable(uint32_t ui32Mask)
277 {
278  // Enable the masked interrupts
279  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) |= ui32Mask;
280 }
281 
282 
283 //*****************************************************************************
284 //
286 //
287 //*****************************************************************************
288 __STATIC_INLINE void
289 RFCCpeIntDisable(uint32_t ui32Mask)
290 {
291  // Disable the masked interrupts
292  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) &= ~ui32Mask;
293 }
294 
295 
296 //*****************************************************************************
297 //
299 //
300 //*****************************************************************************
301 __STATIC_INLINE void
302 RFCHwIntDisable(uint32_t ui32Mask)
303 {
304  // Disable the masked interrupts
305  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) &= ~ui32Mask;
306 }
307 
308 
309 //*****************************************************************************
310 //
312 //
313 //*****************************************************************************
314 extern uint32_t RFCCpeIntGetAndClear(uint32_t ui32Mask);
315 
316 
317 //*****************************************************************************
318 //
320 //
321 //*****************************************************************************
322 __STATIC_INLINE void
324 {
325  // Clear any pending interrupts.
326  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0x0;
327 }
328 
329 
330 //*****************************************************************************
331 //
333 //
334 //*****************************************************************************
335 extern uint32_t RFCDoorbellSendTo(uint32_t pOp);
336 
337 
338 //*****************************************************************************
339 //
341 //
342 //*****************************************************************************
343 extern void RFCSynthPowerDown(void);
344 
345 
346 //*****************************************************************************
347 //
349 //
350 //*****************************************************************************
351 extern void RFCCpePatchReset(void);
352 
353 
354 //*****************************************************************************
355 //
356 // Function to search an override list for the provided pattern within the search depth.
357 //
358 //*****************************************************************************
359 extern uint8_t RFCOverrideSearch(const uint32_t *pOverride, const uint32_t pattern, const uint32_t mask, const uint8_t searchDepth);
360 
361 
362 //*****************************************************************************
363 //
365 //
366 //*****************************************************************************
367 extern uint8_t RFCOverrideUpdate(rfc_radioOp_t *pOpSetup, uint32_t *pParams);
368 
369 
370 //*****************************************************************************
371 //
373 //
374 //*****************************************************************************
375 extern uint32_t RFCHwIntGetAndClear(uint32_t ui32Mask);
376 
377 
378 //*****************************************************************************
379 //
381 //
382 //*****************************************************************************
383 __STATIC_INLINE bool
385 {
386  return (bool)(HWREGB(RFC_PA_TYPE_ADDRESS) & RFC_PA_TYPE_MASK);
387 }
388 
389 //*****************************************************************************
390 //
392 //
393 //*****************************************************************************
394 __STATIC_INLINE uint32_t
396 {
397  return (HWREG(RFC_PA_GAIN_ADDRESS) & RFC_PA_GAIN_MASK);
398 }
399 
400 //*****************************************************************************
401 //
403 //
404 //*****************************************************************************
405 __STATIC_INLINE uint32_t
407 {
408  return (HWREG(PRCM_BASE + PRCM_O_PDCTL1RFC) |
409  HWREG(PRCM_BASE + PRCM_O_PDSTAT0RFC));
410 }
411 
412 //*****************************************************************************
413 //
415 //
416 //*****************************************************************************
417 extern uint32_t RFCAnaDivTxOverride(uint8_t loDivider, uint8_t frontEndMode);
418 
419 
420 //*****************************************************************************
421 //
422 // Support for DriverLib in ROM:
423 // Redirect to implementation in ROM when available.
424 //
425 //*****************************************************************************
426 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
427  #include DeviceFamily_constructPath(driverlib/rom.h)
428  #ifdef ROM_RFCCpeIntGetAndClear
429  #undef RFCCpeIntGetAndClear
430  #define RFCCpeIntGetAndClear ROM_RFCCpeIntGetAndClear
431  #endif
432  #ifdef ROM_RFCDoorbellSendTo
433  #undef RFCDoorbellSendTo
434  #define RFCDoorbellSendTo ROM_RFCDoorbellSendTo
435  #endif
436  #ifdef ROM_RFCSynthPowerDown
437  #undef RFCSynthPowerDown
438  #define RFCSynthPowerDown ROM_RFCSynthPowerDown
439  #endif
440  #ifdef ROM_RFCCpePatchReset
441  #undef RFCCpePatchReset
442  #define RFCCpePatchReset ROM_RFCCpePatchReset
443  #endif
444  #ifdef ROM_RFCOverrideSearch
445  #undef RFCOverrideSearch
446  #define RFCOverrideSearch ROM_RFCOverrideSearch
447  #endif
448  #ifdef ROM_RFCOverrideUpdate
449  #undef RFCOverrideUpdate
450  #define RFCOverrideUpdate ROM_RFCOverrideUpdate
451  #endif
452  #ifdef ROM_RFCHwIntGetAndClear
453  #undef RFCHwIntGetAndClear
454  #define RFCHwIntGetAndClear ROM_RFCHwIntGetAndClear
455  #endif
456  #ifdef ROM_RFCAnaDivTxOverride
457  #undef RFCAnaDivTxOverride
458  #define RFCAnaDivTxOverride ROM_RFCAnaDivTxOverride
459  #endif
460 #endif
461 
462 //*****************************************************************************
463 //
464 // Mark the end of the C bindings section for C++ compilers.
465 //
466 //*****************************************************************************
467 #ifdef __cplusplus
468 }
469 #endif
470 
471 #endif // __RFC_H__
472 
473 //*****************************************************************************
474 //
477 //
478 //*****************************************************************************
__STATIC_INLINE void RFCHwIntDisable(uint32_t ui32Mask)
Disable HW interrupt sources.
Definition: rfc.h:302
#define RFCCpePatchReset
Definition: rfc.h:110
uint32_t configSynth
Definition: rfc.h:79
__STATIC_INLINE void RFCHwIntClear(uint32_t ui32Mask)
Clear CPE interrupt flags.
Definition: rfc.h:186
#define RFCOverrideSearch
Definition: rfc.h:111
#define RFCAnaDivTxOverride
Definition: rfc.h:114
#define RFC_PA_TYPE_ADDRESS
Definition: rfc.h:85
#define RFCSynthPowerDown
Definition: rfc.h:109
__STATIC_INLINE void RFCCpeIntClear(uint32_t ui32Mask)
Clear HW interrupt flags.
Definition: rfc.h:173
#define RFCCpeIntGetAndClear
Definition: rfc.h:107
__STATIC_INLINE void RFCClockDisable(void)
Disable the RF core clocks.
Definition: rfc.h:160
__STATIC_INLINE void RFCCpe1IntSelectClearEnable(uint32_t ui32Mask)
Select, clear, and enable interrupt sources to CPE1.
Definition: rfc.h:257
__STATIC_INLINE void RFCCpeIntEnable(uint32_t ui32Mask)
Enable CPEx interrupt sources.
Definition: rfc.h:225
__STATIC_INLINE void RFCHwIntEnable(uint32_t ui32Mask)
Enable HW interrupt sources.
Definition: rfc.h:276
#define RFCDoorbellSendTo
Definition: rfc.h:108
Definition: rfc.h:76
__STATIC_INLINE bool RFCGetPaType(void)
Get the type of currently selected PA.
Definition: rfc.h:384
uint32_t configMiscAdc
Definition: rfc.h:80
uint32_t configRfFrontend
Definition: rfc.h:78
uint32_t configIfAdc
Definition: rfc.h:77
#define RFC_PA_GAIN_ADDRESS
Definition: rfc.h:87
__STATIC_INLINE void RFCCpeIntDisable(uint32_t ui32Mask)
Disable CPE interrupt sources.
Definition: rfc.h:289
__STATIC_INLINE void RFCAckIntClear(void)
Clear ACK interrupt flag.
Definition: rfc.h:323
#define RFC_PA_TYPE_MASK
Definition: rfc.h:86
__STATIC_INLINE void RFCClockEnable(void)
Enable the RF core clocks.
Definition: rfc.h:135
__STATIC_INLINE uint32_t RFCGetPowerDomainStatus(void)
Get the power domain status of the radio core.
Definition: rfc.h:406
__STATIC_INLINE void RFCCpe0IntSelectClearEnable(uint32_t ui32Mask)
Select, clear, and enable interrupt sources to CPE0.
Definition: rfc.h:238
__STATIC_INLINE uint32_t RFCGetPaGain(void)
Get the gain of currently selected PA.
Definition: rfc.h:395
__STATIC_INLINE void RFCCpe1IntSelect(uint32_t ui32Mask)
Select interrupt sources to CPE1 (assign to INT_RFC_CPE_1 interrupt vector).
Definition: rfc.h:212
Definition: rf_common_cmd.h:122
#define RFCOverrideUpdate
Definition: rfc.h:112
#define RFC_PA_GAIN_MASK
Definition: rfc.h:88
#define RFCHwIntGetAndClear
Definition: rfc.h:113
__STATIC_INLINE void RFCCpe0IntSelect(uint32_t ui32Mask)
Select interrupt sources to CPE0 (assign to INT_RFC_CPE_0 interrupt vector).
Definition: rfc.h:199
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale