CC13xx Driver Library
rfc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: rfc.h
3 * Revised: 2016-02-17 14:00:56 +0100 (Wed, 17 Feb 2016)
4 * Revision: 45684
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 #endif
97 
98 //*****************************************************************************
99 //
100 // API Functions and prototypes
101 //
102 //*****************************************************************************
103 
104 //*****************************************************************************
105 //
113 //
114 //*****************************************************************************
115 __STATIC_INLINE void
117 {
118  //
119  // Enable all clocks
120  //
121  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) =
133 }
134 
135 //*****************************************************************************
136 //
148 //
149 //*****************************************************************************
150 __STATIC_INLINE void
152 {
153  //
154  // Disable all clocks
155  //
156  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x0;
157 }
158 
159 //*****************************************************************************
160 //
162 //
163 //*****************************************************************************
164 __STATIC_INLINE void
165 RFCCpe0IntEnable(uint32_t ui32Mask)
166 {
167  //
168  // Multiplex RF Core interrupts to CPE0 IRQ.
169  //
170  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) &= ~ui32Mask;
171 
172  do
173  {
174  //
175  // Clear any pending interrupts.
176  //
177  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
178  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
179 
180  //
181  // Enable the masked interrupts
182  //
183  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
184 }
185 
186 
187 //*****************************************************************************
188 //
190 //
191 //*****************************************************************************
192 __STATIC_INLINE void
193 RFCCpe1IntEnable(uint32_t ui32Mask)
194 {
195  //
196  // Multiplex RF Core interrupts to CPE1 IRQ.
197  //
198  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) |= ui32Mask;
199 
200  do
201  {
202  //
203  // Clear any pending interrupts.
204  //
205  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
206  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
207 
208  //
209  // Enable the masked interrupts
210  //
211  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
212 }
213 
214 
215 //*****************************************************************************
216 //
219 //
220 //*****************************************************************************
221 __STATIC_INLINE void
222 RFCHwIntEnable(uint32_t ui32Mask)
223 {
224  //
225  // Clear any pending interrupts.
226  //
227  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = 0x0;
228 
229  //
230  // Enable the masked interrupts
231  //
232  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) |= ui32Mask;
233 }
234 
235 
236 //*****************************************************************************
237 //
239 //
240 //*****************************************************************************
241 __STATIC_INLINE void
242 RFCCpeIntDisable(uint32_t ui32Mask)
243 {
244  //
245  // Disable the masked interrupts
246  //
247  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN ) &= ~ui32Mask;
248 }
249 
250 
251 //*****************************************************************************
252 //
254 //
255 //*****************************************************************************
256 __STATIC_INLINE void
257 RFCHwIntDisable(uint32_t ui32Mask)
258 {
259  //
260  // Disable the masked interrupts
261  //
262  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) &= ~ui32Mask;
263 }
264 
265 
266 //*****************************************************************************
267 //
269 //
270 //*****************************************************************************
271 extern uint32_t RFCCpeIntGetAndClear(void);
272 
273 
274 //*****************************************************************************
275 //
277 //
278 //*****************************************************************************
279 __STATIC_INLINE void
280 RFCCpeIntClear(uint32_t ui32Mask)
281 {
282  do
283  {
284  //
285  // Clear interrupts that may now be pending
286  //
287  HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) = ~ui32Mask;
288  }while (HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) & ui32Mask);
289 }
290 
291 
292 //*****************************************************************************
293 //
295 //
296 //*****************************************************************************
297 __STATIC_INLINE void
298 RFCHwIntClear(uint32_t ui32Mask)
299 {
300  //
301  // Clear pending interrupts.
302  //
303  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = ~ui32Mask;
304 }
305 
306 
307 //*****************************************************************************
308 //
310 //
311 //*****************************************************************************
312 __STATIC_INLINE void
314 {
315  //
316  // Clear any pending interrupts.
317  //
318  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0x0;
319 }
320 
321 
322 //*****************************************************************************
323 //
325 //
326 //*****************************************************************************
327 extern uint32_t RFCDoorbellSendTo(uint32_t pOp);
328 
329 
330 //*****************************************************************************
331 //
333 //
334 //*****************************************************************************
335 extern void RFCSynthPowerDown(void);
336 
337 
338 //*****************************************************************************
339 //
341 //
342 //*****************************************************************************
343 extern void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t* rfTrim);
344 
345 
346 //*****************************************************************************
347 //
349 //
350 //*****************************************************************************
351 extern void RFCRfTrimSet(rfTrim_t* rfTrim);
352 
353 
354 //*****************************************************************************
355 //
356 // Support for DriverLib in ROM:
357 // Redirect to implementation in ROM when available.
358 //
359 //*****************************************************************************
360 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
361  #include <driverlib/rom.h>
362  #ifdef ROM_RFCCpeIntGetAndClear
363  #undef RFCCpeIntGetAndClear
364  #define RFCCpeIntGetAndClear ROM_RFCCpeIntGetAndClear
365  #endif
366  #ifdef ROM_RFCDoorbellSendTo
367  #undef RFCDoorbellSendTo
368  #define RFCDoorbellSendTo ROM_RFCDoorbellSendTo
369  #endif
370  #ifdef ROM_RFCSynthPowerDown
371  #undef RFCSynthPowerDown
372  #define RFCSynthPowerDown ROM_RFCSynthPowerDown
373  #endif
374  #ifdef ROM_RFCRfTrimRead
375  #undef RFCRfTrimRead
376  #define RFCRfTrimRead ROM_RFCRfTrimRead
377  #endif
378  #ifdef ROM_RFCRfTrimSet
379  #undef RFCRfTrimSet
380  #define RFCRfTrimSet ROM_RFCRfTrimSet
381  #endif
382 #endif
383 
384 //*****************************************************************************
385 //
386 // Mark the end of the C bindings section for C++ compilers.
387 //
388 //*****************************************************************************
389 #ifdef __cplusplus
390 }
391 #endif
392 
393 #endif // __RFC_H__
394 
395 //*****************************************************************************
396 //
399 //
400 //*****************************************************************************
uint32_t configSynth
Definition: rfc.h:73
static void RFCHwIntDisable(uint32_t ui32Mask)
Disable HW interrupt.
Definition: rfc.h:257
static void RFCCpe1IntEnable(uint32_t ui32Mask)
Enable CPE1 interrupt.
Definition: rfc.h:193
static void RFCCpeIntDisable(uint32_t ui32Mask)
Disable CPE interrupt.
Definition: rfc.h:242
static void RFCCpeIntClear(uint32_t ui32Mask)
Clear interrupt flags.
Definition: rfc.h:280
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:165
void RFCRfTrimSet(rfTrim_t *rfTrim)
Write preloaded RF trim values to CM0.
Definition: rfc.c:196
static void RFCAckIntClear(void)
Clear interrupt flags.
Definition: rfc.h:313
Definition: rfc.h:70
uint32_t RFCCpeIntGetAndClear(void)
Get and clear CPE interrupt flags.
Definition: rfc.c:56
uint32_t configMiscAdc
Definition: rfc.h:74
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:151
uint32_t RFCDoorbellSendTo(uint32_t pOp)
Send command to doorbell and wait for ack.
Definition: rfc.c:74
static void RFCHwIntEnable(uint32_t ui32Mask)
Definition: rfc.h:222
static void RFCHwIntClear(uint32_t ui32Mask)
Clear interrupt flags.
Definition: rfc.h:298
void RFCRfTrimRead(rfc_radioOp_t *pOpSetup, rfTrim_t *rfTrim)
Read RF trim from flash using CM3.
Definition: rfc.c:116
static void RFCClockEnable(void)
Enable the RF core clocks.
Definition: rfc.h:116
void RFCSynthPowerDown(void)
Turn off synth, NOTE: Radio will no longer respond to commands!
Definition: rfc.c:95