CC13xx Driver Library
rfc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: rfc.h
3 * Revised: 2016-04-07 15:04:05 +0200 (Thu, 07 Apr 2016)
4 * Revision: 46052
5 *
6 * Description: Defines and prototypes for the RF Core.
7 *
8 * Copyright (c) 2015, 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 
70 typedef struct {
71  uint32_t configIfAdc;
72  uint32_t configRfFrontend;
73  uint32_t configSynth;
74  uint32_t configMiscAdc;
75 } rfTrim_t;
76 
77 //*****************************************************************************
78 //
79 // Support for DriverLib in ROM:
80 // This section renames all functions that are not "static inline", so that
81 // calling these functions will default to implementation in flash. At the end
82 // of this file a second renaming will change the defaults to implementation in
83 // ROM for available functions.
84 //
85 // To force use of the implementation in flash, e.g. for debugging:
86 // - Globally: Define DRIVERLIB_NOROM at project level
87 // - Per function: Use prefix "NOROM_" when calling the function
88 //
89 //*****************************************************************************
90 #if !defined(DOXYGEN)
91  #define RFCCpeIntGetAndClear NOROM_RFCCpeIntGetAndClear
92  #define RFCDoorbellSendTo NOROM_RFCDoorbellSendTo
93  #define RFCSynthPowerDown NOROM_RFCSynthPowerDown
94  #define RFCRfTrimRead NOROM_RFCRfTrimRead
95  #define RFCRfTrimSet NOROM_RFCRfTrimSet
96  #define RFCRTrim NOROM_RFCRTrim
97 #endif
98 
99 //*****************************************************************************
100 //
101 // API Functions and prototypes
102 //
103 //*****************************************************************************
104 
105 //*****************************************************************************
106 //
114 //
115 //*****************************************************************************
116 __STATIC_INLINE void
118 {
119  //
120  // Enable all clocks
121  //
122  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) =
134 }
135 
136 //*****************************************************************************
137 //
149 //
150 //*****************************************************************************
151 __STATIC_INLINE void
153 {
154  //
155  // Disable all clocks
156  //
157  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x0;
158 }
159 
160 //*****************************************************************************
161 //
163 //
164 //*****************************************************************************
165 __STATIC_INLINE void
166 RFCCpe0IntEnable(uint32_t ui32Mask)
167 {
168  //
169  // Multiplex RF Core interrupts to CPE0 IRQ.
170  //
171  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) &= ~ui32Mask;
172 
173  do
174  {
175  //
176  // Clear any pending interrupts.
177  //
178  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
179  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
180 
181  //
182  // Enable the masked interrupts
183  //
184  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
185 }
186 
187 
188 //*****************************************************************************
189 //
191 //
192 //*****************************************************************************
193 __STATIC_INLINE void
194 RFCCpe1IntEnable(uint32_t ui32Mask)
195 {
196  //
197  // Multiplex RF Core interrupts to CPE1 IRQ.
198  //
199  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) |= ui32Mask;
200 
201  do
202  {
203  //
204  // Clear any pending interrupts.
205  //
206  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
207  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
208 
209  //
210  // Enable the masked interrupts
211  //
212  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
213 }
214 
215 
216 //*****************************************************************************
217 //
220 //
221 //*****************************************************************************
222 __STATIC_INLINE void
223 RFCHwIntEnable(uint32_t ui32Mask)
224 {
225  //
226  // Clear any pending interrupts.
227  //
228  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = 0x0;
229 
230  //
231  // Enable the masked interrupts
232  //
233  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) |= ui32Mask;
234 }
235 
236 
237 //*****************************************************************************
238 //
240 //
241 //*****************************************************************************
242 __STATIC_INLINE void
243 RFCCpeIntDisable(uint32_t ui32Mask)
244 {
245  //
246  // Disable the masked interrupts
247  //
248  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN ) &= ~ui32Mask;
249 }
250 
251 
252 //*****************************************************************************
253 //
255 //
256 //*****************************************************************************
257 __STATIC_INLINE void
258 RFCHwIntDisable(uint32_t ui32Mask)
259 {
260  //
261  // Disable the masked interrupts
262  //
263  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) &= ~ui32Mask;
264 }
265 
266 
267 //*****************************************************************************
268 //
270 //
271 //*****************************************************************************
272 extern uint32_t RFCCpeIntGetAndClear(void);
273 
274 
275 //*****************************************************************************
276 //
278 //
279 //*****************************************************************************
280 __STATIC_INLINE void
281 RFCCpeIntClear(uint32_t ui32Mask)
282 {
283  do
284  {
285  //
286  // Clear interrupts that may now be pending
287  //
288  HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) = ~ui32Mask;
289  }while (HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) & ui32Mask);
290 }
291 
292 
293 //*****************************************************************************
294 //
296 //
297 //*****************************************************************************
298 __STATIC_INLINE void
299 RFCHwIntClear(uint32_t ui32Mask)
300 {
301  //
302  // Clear pending interrupts.
303  //
304  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = ~ui32Mask;
305 }
306 
307 
308 //*****************************************************************************
309 //
311 //
312 //*****************************************************************************
313 __STATIC_INLINE void
315 {
316  //
317  // Clear any pending interrupts.
318  //
319  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0x0;
320 }
321 
322 
323 //*****************************************************************************
324 //
326 //
327 //*****************************************************************************
328 extern uint32_t RFCDoorbellSendTo(uint32_t pOp);
329 
330 
331 //*****************************************************************************
332 //
334 //
335 //*****************************************************************************
336 extern void RFCSynthPowerDown(void);
337 
338 
339 //*****************************************************************************
340 //
342 //
343 //*****************************************************************************
344 extern void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t* rfTrim);
345 
346 
347 //*****************************************************************************
348 //
350 //
351 //*****************************************************************************
352 extern void RFCRfTrimSet(rfTrim_t* rfTrim);
353 
354 
355 //*****************************************************************************
356 //
358 //
359 //*****************************************************************************
360 extern void RFCRTrim(rfc_radioOp_t *pOpSetup);
361 
362 
363 //*****************************************************************************
364 //
365 // Support for DriverLib in ROM:
366 // Redirect to implementation in ROM when available.
367 //
368 //*****************************************************************************
369 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
370  #include <driverlib/rom.h>
371  #ifdef ROM_RFCCpeIntGetAndClear
372  #undef RFCCpeIntGetAndClear
373  #define RFCCpeIntGetAndClear ROM_RFCCpeIntGetAndClear
374  #endif
375  #ifdef ROM_RFCDoorbellSendTo
376  #undef RFCDoorbellSendTo
377  #define RFCDoorbellSendTo ROM_RFCDoorbellSendTo
378  #endif
379  #ifdef ROM_RFCSynthPowerDown
380  #undef RFCSynthPowerDown
381  #define RFCSynthPowerDown ROM_RFCSynthPowerDown
382  #endif
383  #ifdef ROM_RFCRfTrimRead
384  #undef RFCRfTrimRead
385  #define RFCRfTrimRead ROM_RFCRfTrimRead
386  #endif
387  #ifdef ROM_RFCRfTrimSet
388  #undef RFCRfTrimSet
389  #define RFCRfTrimSet ROM_RFCRfTrimSet
390  #endif
391  #ifdef ROM_RFCRTrim
392  #undef RFCRTrim
393  #define RFCRTrim ROM_RFCRTrim
394  #endif
395 #endif
396 
397 //*****************************************************************************
398 //
399 // Mark the end of the C bindings section for C++ compilers.
400 //
401 //*****************************************************************************
402 #ifdef __cplusplus
403 }
404 #endif
405 
406 #endif // __RFC_H__
407 
408 //*****************************************************************************
409 //
412 //
413 //*****************************************************************************
uint32_t configSynth
Definition: rfc.h:73
static void RFCHwIntDisable(uint32_t ui32Mask)
Disable HW interrupt.
Definition: rfc.h:258
static void RFCCpe1IntEnable(uint32_t ui32Mask)
Enable CPE1 interrupt.
Definition: rfc.h:194
static void RFCCpeIntDisable(uint32_t ui32Mask)
Disable CPE interrupt.
Definition: rfc.h:243
static void RFCCpeIntClear(uint32_t ui32Mask)
Clear interrupt flags.
Definition: rfc.h:281
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:166
void RFCRfTrimSet(rfTrim_t *rfTrim)
Write preloaded RF trim values to CM0.
Definition: rfc.c:341
static void RFCAckIntClear(void)
Clear interrupt flags.
Definition: rfc.h:314
Definition: rfc.h:70
uint32_t RFCCpeIntGetAndClear(void)
Get and clear CPE interrupt flags.
Definition: rfc.c:70
uint32_t configMiscAdc
Definition: rfc.h:74
void RFCRTrim(rfc_radioOp_t *pOpSetup)
Check Override RTrim vs FCFG RTrim.
Definition: rfc.c:209
uint32_t configRfFrontend
Definition: rfc.h:72
uint32_t configIfAdc
Definition: rfc.h:71
static void RFCClockDisable(void)
Disable the RF core clocks.
Definition: rfc.h:152
uint32_t RFCDoorbellSendTo(uint32_t pOp)
Send command to doorbell and wait for ack.
Definition: rfc.c:88
static void RFCHwIntEnable(uint32_t ui32Mask)
Definition: rfc.h:223
static void RFCHwIntClear(uint32_t ui32Mask)
Clear interrupt flags.
Definition: rfc.h:299
void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t *rfTrim)
Read RF trim from flash using CM3.
Definition: rfc.c:130
static void RFCClockEnable(void)
Enable the RF core clocks.
Definition: rfc.h:117
void RFCSynthPowerDown(void)
Turn off synth, NOTE: Radio will no longer respond to commands!
Definition: rfc.c:109