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