CC13xx Driver Library
rfc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: rfc.h
3 * Revised: 2016-05-02 14:44:23 +0200 (Mon, 02 May 2016)
4 * Revision: 46231
5 *
6 * Description: Defines and prototypes for the RF Core.
7 *
8 * Copyright (c) 2015 - 2016, 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 <inc/hw_types.h>
63 #include <inc/hw_memmap.h>
64 #include <inc/hw_rfc_pwr.h>
65 #include <inc/hw_rfc_dbell.h>
67 #include <driverlib/rf_prop_cmd.h>
68 #include <inc/hw_fcfg1.h>
69 #include <inc/hw_adi_3_refsys.h>
70 #include <inc/hw_adi.h>
71 
72 typedef struct {
73  uint32_t configIfAdc;
74  uint32_t configRfFrontend;
75  uint32_t configSynth;
76  uint32_t configMiscAdc;
77 } rfTrim_t;
78 
79 //*****************************************************************************
80 //
81 // Support for DriverLib in ROM:
82 // This section renames all functions that are not "static inline", so that
83 // calling these functions will default to implementation in flash. At the end
84 // of this file a second renaming will change the defaults to implementation in
85 // ROM for available functions.
86 //
87 // To force use of the implementation in flash, e.g. for debugging:
88 // - Globally: Define DRIVERLIB_NOROM at project level
89 // - Per function: Use prefix "NOROM_" when calling the function
90 //
91 //*****************************************************************************
92 #if !defined(DOXYGEN)
93  #define RFCCpeIntGetAndClear NOROM_RFCCpeIntGetAndClear
94  #define RFCDoorbellSendTo NOROM_RFCDoorbellSendTo
95  #define RFCSynthPowerDown NOROM_RFCSynthPowerDown
96  #define RFCRfTrimRead NOROM_RFCRfTrimRead
97  #define RFCRfTrimSet NOROM_RFCRfTrimSet
98  #define RFCRTrim NOROM_RFCRTrim
99  #define RFCCPEPatchReset NOROM_RFCCPEPatchReset
100  #define RFCAdi3VcoLdoVoltageMode NOROM_RFCAdi3VcoLdoVoltageMode
101 #endif
102 
103 //*****************************************************************************
104 //
105 // API Functions and prototypes
106 //
107 //*****************************************************************************
108 
109 //*****************************************************************************
110 //
118 //
119 //*****************************************************************************
120 __STATIC_INLINE void
122 {
123  //
124  // Enable all clocks
125  //
126  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) =
138 }
139 
140 //*****************************************************************************
141 //
153 //
154 //*****************************************************************************
155 __STATIC_INLINE void
157 {
158  //
159  // Disable all clocks
160  //
161  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x0;
162 }
163 
164 //*****************************************************************************
165 //
167 //
168 //*****************************************************************************
169 __STATIC_INLINE void
170 RFCCpe0IntEnable(uint32_t ui32Mask)
171 {
172  //
173  // Multiplex RF Core interrupts to CPE0 IRQ.
174  //
175  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) &= ~ui32Mask;
176 
177  do
178  {
179  //
180  // Clear any pending interrupts.
181  //
182  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
183  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
184 
185  //
186  // Enable the masked interrupts
187  //
188  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
189 }
190 
191 
192 //*****************************************************************************
193 //
195 //
196 //*****************************************************************************
197 __STATIC_INLINE void
198 RFCCpe1IntEnable(uint32_t ui32Mask)
199 {
200  //
201  // Multiplex RF Core interrupts to CPE1 IRQ.
202  //
203  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) |= ui32Mask;
204 
205  do
206  {
207  //
208  // Clear any pending interrupts.
209  //
210  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
211  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
212 
213  //
214  // Enable the masked interrupts
215  //
216  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
217 }
218 
219 
220 //*****************************************************************************
221 //
224 //
225 //*****************************************************************************
226 __STATIC_INLINE void
227 RFCHwIntEnable(uint32_t ui32Mask)
228 {
229  //
230  // Clear any pending interrupts.
231  //
232  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = 0x0;
233 
234  //
235  // Enable the masked interrupts
236  //
237  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) |= ui32Mask;
238 }
239 
240 
241 //*****************************************************************************
242 //
244 //
245 //*****************************************************************************
246 __STATIC_INLINE void
247 RFCCpeIntDisable(uint32_t ui32Mask)
248 {
249  //
250  // Disable the masked interrupts
251  //
252  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN ) &= ~ui32Mask;
253 }
254 
255 
256 //*****************************************************************************
257 //
259 //
260 //*****************************************************************************
261 __STATIC_INLINE void
262 RFCHwIntDisable(uint32_t ui32Mask)
263 {
264  //
265  // Disable the masked interrupts
266  //
267  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) &= ~ui32Mask;
268 }
269 
270 
271 //*****************************************************************************
272 //
274 //
275 //*****************************************************************************
276 extern uint32_t RFCCpeIntGetAndClear(void);
277 
278 
279 //*****************************************************************************
280 //
282 //
283 //*****************************************************************************
284 __STATIC_INLINE void
285 RFCCpeIntClear(uint32_t ui32Mask)
286 {
287  do
288  {
289  //
290  // Clear interrupts that may now be pending
291  //
292  HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) = ~ui32Mask;
293  }while (HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) & ui32Mask);
294 }
295 
296 
297 //*****************************************************************************
298 //
300 //
301 //*****************************************************************************
302 __STATIC_INLINE void
303 RFCHwIntClear(uint32_t ui32Mask)
304 {
305  //
306  // Clear pending interrupts.
307  //
308  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = ~ui32Mask;
309 }
310 
311 
312 //*****************************************************************************
313 //
315 //
316 //*****************************************************************************
317 __STATIC_INLINE void
319 {
320  //
321  // Clear any pending interrupts.
322  //
323  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0x0;
324 }
325 
326 
327 //*****************************************************************************
328 //
330 //
331 //*****************************************************************************
332 extern uint32_t RFCDoorbellSendTo(uint32_t pOp);
333 
334 
335 //*****************************************************************************
336 //
338 //
339 //*****************************************************************************
340 extern void RFCSynthPowerDown(void);
341 
342 
343 //*****************************************************************************
344 //
346 //
347 //*****************************************************************************
348 extern void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t* rfTrim);
349 
350 
351 //*****************************************************************************
352 //
354 //
355 //*****************************************************************************
356 extern void RFCRfTrimSet(rfTrim_t* rfTrim);
357 
358 
359 //*****************************************************************************
360 //
362 //
363 //*****************************************************************************
364 extern void RFCRTrim(rfc_radioOp_t *pOpSetup);
365 
366 
367 //*****************************************************************************
368 //
370 //
371 //*****************************************************************************
372 extern void RFCCPEPatchReset(void);
373 
374 
375 //*****************************************************************************
376 //
378 //
379 //*****************************************************************************
380 extern void RFCAdi3VcoLdoVoltageMode(bool bEnable);
381 
382 
383 //*****************************************************************************
384 //
385 // Support for DriverLib in ROM:
386 // Redirect to implementation in ROM when available.
387 //
388 //*****************************************************************************
389 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
390  #include <driverlib/rom.h>
391  #ifdef ROM_RFCCpeIntGetAndClear
392  #undef RFCCpeIntGetAndClear
393  #define RFCCpeIntGetAndClear ROM_RFCCpeIntGetAndClear
394  #endif
395  #ifdef ROM_RFCDoorbellSendTo
396  #undef RFCDoorbellSendTo
397  #define RFCDoorbellSendTo ROM_RFCDoorbellSendTo
398  #endif
399  #ifdef ROM_RFCSynthPowerDown
400  #undef RFCSynthPowerDown
401  #define RFCSynthPowerDown ROM_RFCSynthPowerDown
402  #endif
403  #ifdef ROM_RFCRfTrimRead
404  #undef RFCRfTrimRead
405  #define RFCRfTrimRead ROM_RFCRfTrimRead
406  #endif
407  #ifdef ROM_RFCRfTrimSet
408  #undef RFCRfTrimSet
409  #define RFCRfTrimSet ROM_RFCRfTrimSet
410  #endif
411  #ifdef ROM_RFCRTrim
412  #undef RFCRTrim
413  #define RFCRTrim ROM_RFCRTrim
414  #endif
415  #ifdef ROM_RFCCPEPatchReset
416  #undef RFCCPEPatchReset
417  #define RFCCPEPatchReset ROM_RFCCPEPatchReset
418  #endif
419  #ifdef ROM_RFCAdi3VcoLdoVoltageMode
420  #undef RFCAdi3VcoLdoVoltageMode
421  #define RFCAdi3VcoLdoVoltageMode ROM_RFCAdi3VcoLdoVoltageMode
422  #endif
423 #endif
424 
425 //*****************************************************************************
426 //
427 // Mark the end of the C bindings section for C++ compilers.
428 //
429 //*****************************************************************************
430 #ifdef __cplusplus
431 }
432 #endif
433 
434 #endif // __RFC_H__
435 
436 //*****************************************************************************
437 //
440 //
441 //*****************************************************************************
uint32_t configSynth
Definition: rfc.h:75
static void RFCHwIntDisable(uint32_t ui32Mask)
Disable HW interrupt.
Definition: rfc.h:262
static void RFCCpe1IntEnable(uint32_t ui32Mask)
Enable CPE1 interrupt.
Definition: rfc.h:198
static void RFCCpeIntDisable(uint32_t ui32Mask)
Disable CPE interrupt.
Definition: rfc.h:247
static void RFCCpeIntClear(uint32_t ui32Mask)
Clear interrupt flags.
Definition: rfc.h:285
struct __RFC_STRUCT rfc_radioOp_s rfc_radioOp_t
Definition: rf_common_cmd.h:60
static void RFCCpe0IntEnable(uint32_t ui32Mask)
Enable CPE0 interrupt.
Definition: rfc.h:170
void RFCRfTrimSet(rfTrim_t *rfTrim)
Write preloaded RF trim values to CM0.
Definition: rfc.c:375
static void RFCAckIntClear(void)
Clear interrupt flags.
Definition: rfc.h:318
Definition: rfc.h:72
uint32_t RFCCpeIntGetAndClear(void)
Get and clear CPE interrupt flags.
Definition: rfc.c:104
uint32_t configMiscAdc
Definition: rfc.h:76
void RFCRTrim(rfc_radioOp_t *pOpSetup)
Check Override RTrim vs FCFG RTrim.
Definition: rfc.c:243
uint32_t configRfFrontend
Definition: rfc.h:74
void RFCCPEPatchReset(void)
Reset previously patched CPE RAM to a state where it can be patched again.
Definition: rfc.c:386
uint32_t configIfAdc
Definition: rfc.h:73
static void RFCClockDisable(void)
Disable the RF core clocks.
Definition: rfc.h:156
uint32_t RFCDoorbellSendTo(uint32_t pOp)
Send command to doorbell and wait for ack.
Definition: rfc.c:122
static void RFCHwIntEnable(uint32_t ui32Mask)
Definition: rfc.h:227
static void RFCHwIntClear(uint32_t ui32Mask)
Clear interrupt flags.
Definition: rfc.h:303
void RFCAdi3VcoLdoVoltageMode(bool bEnable)
Function to set VCOLDO reference to voltage mode.
Definition: rfc.c:406
void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t *rfTrim)
Read RF trim from flash using CM3.
Definition: rfc.c:164
static void RFCClockEnable(void)
Enable the RF core clocks.
Definition: rfc.h:121
void RFCSynthPowerDown(void)
Turn off synth, NOTE: Radio will no longer respond to commands!
Definition: rfc.c:143