CC13xx Driver Library
RF Core

Data Structures

struct  rfTrim_t
 

Functions

static void RFCClockEnable (void)
 Enable the RF core clocks. More...
 
static void RFCClockDisable (void)
 Disable the RF core clocks. More...
 
static void RFCClockSet (uint32_t ui32Mask)
 Enable some of the RF core clocks. More...
 
static void RFCClockClear (uint32_t ui32Mask)
 Disable some of the RF core clocks. More...
 
static void RFCCpe0IntEnable (uint32_t ui32Mask)
 Enable CPE0 interrupt. More...
 
static void RFCCpe1IntEnable (uint32_t ui32Mask)
 Enable CPE1 interrupt. More...
 
static void RFCHwIntEnable (uint32_t ui32Mask)
 
static void RFCCpeIntDisable (uint32_t ui32Mask)
 Disable CPE interrupt. More...
 
static void RFCHwIntDisable (uint32_t ui32Mask)
 Disable HW interrupt. More...
 
uint32_t RFCCpeIntGetAndClear (void)
 Get and clear CPE interrupt flags. More...
 
static void RFCCpeIntClear (uint32_t ui32Mask)
 Clear interrupt flags. More...
 
static void RFCHwIntClear (uint32_t ui32Mask)
 Clear interrupt flags. More...
 
static void RFCAckIntClear (void)
 Clear interrupt flags. More...
 
uint32_t RFCDoorbellSendTo (uint32_t pOp)
 Send command to doorbell and wait for ack. More...
 
void RFCSynthPowerDown (void)
 Turn off synth, NOTE: Radio will no longer respond to commands! More...
 
void RFCRfTrimRead (rfc_radioOp_t *pOpSetup, rfTrim_t *rfTrim)
 Read RF trim from flash using CM3. More...
 
void RFCRfTrimSet (rfTrim_t *rfTrim)
 Write preloaded RF trim values to CM0. More...
 
void RFCRTrim (rfc_radioOp_t *pOpSetup)
 Check Override RTrim vs FCFG RTrim. More...
 
void RFCCPEPatchReset (void)
 Reset previously patched CPE RAM to a state where it can be patched again. More...
 
void RFCAdi3VcoLdoVoltageMode (bool bEnable)
 Function to set VCOLDO reference to voltage mode. More...
 

Detailed Description

Function Documentation

static void RFCAckIntClear ( void  )
inlinestatic

Clear interrupt flags.

Referenced by RFCDoorbellSendTo().

335 {
336  // Clear any pending interrupts.
337  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG) = 0x0;
338 }
void RFCAdi3VcoLdoVoltageMode ( bool  bEnable)

Function to set VCOLDO reference to voltage mode.

408 {
409  if (bEnable)
410  {
411  // First make sure the REFSYSCTL0 mux output is not further muxed out
412  HWREGB(0x40086200) = 0x0;
413  // Set the REFSYSCTL0 mux as desired for VCOLDO voltage mode
415  }
416  else
417  {
418  // Revert the mux override
420  }
421 }
static void RFCClockClear ( uint32_t  ui32Mask)
inlinestatic

Disable some of the RF core clocks.

As soon as the RF core is started it will handle clock control autonomously. No check should be performed to check the clocks. Instead the radio can be ping'ed through the command interface.

When disabling clocks it is the programmers responsibility that the RF core clocks can be safely gated. I.e. the RF core should be safely 'parked'.

Returns
None
197 {
198  //
199  // Disable clocks
200  //
201  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) &= ~ui32Mask;
202 }
static void RFCClockDisable ( void  )
inlinestatic

Disable the RF core clocks.

As soon as the RF core is started it will handle clock control autonomously. No check should be performed to check the clocks. Instead the radio can be ping'ed through the command interface.

When disabling clocks it is the programmers responsibility that the RF core clocks can be safely gated. I.e. the RF core should be safely 'parked'.

Returns
None
155 {
156  // Disable all clocks
157  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x0;
158 }
static void RFCClockEnable ( void  )
inlinestatic

Enable the RF core clocks.

As soon as the RF core is started it will handle clock control autonomously. No check should be performed to check the clocks. Instead the radio can be ping'ed through the command interface.

Returns
None
122 {
123  // Enable all clocks
124  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) =
136 }
static void RFCClockSet ( uint32_t  ui32Mask)
inlinestatic

Enable some of the RF core clocks.

As soon as the RF core is started it will handle clock control autonomously. No check should be performed to check the clocks. Instead the radio can be ping'ed through the command interface.

Returns
None
173 {
174  //
175  // Enable clocks
176  //
177  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) |= ui32Mask;
178 }
static void RFCCpe0IntEnable ( uint32_t  ui32Mask)
inlinestatic

Enable CPE0 interrupt.

211 {
212  // Multiplex RF Core interrupts to CPE0 IRQ.
213  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) &= ~ui32Mask;
214 
215  do
216  {
217  // Clear any pending interrupts.
218  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
219  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
220 
221  // Enable the masked interrupts
222  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
223 }
static void RFCCpe1IntEnable ( uint32_t  ui32Mask)
inlinestatic

Enable CPE1 interrupt.

233 {
234  // Multiplex RF Core interrupts to CPE1 IRQ.
235  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEISL) |= ui32Mask;
236 
237  do
238  {
239  // Clear any pending interrupts.
240  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) = 0x0;
241  }while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIFG) != 0x0);
242 
243  // Enable the masked interrupts
244  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN) |= ui32Mask;
245 }
static void RFCCpeIntClear ( uint32_t  ui32Mask)
inlinestatic

Clear interrupt flags.

306 {
307  do
308  {
309  // Clear interrupts that may now be pending
310  HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) = ~ui32Mask;
311  }while (HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) & ui32Mask);
312 }
static void RFCCpeIntDisable ( uint32_t  ui32Mask)
inlinestatic

Disable CPE interrupt.

272 {
273  // Disable the masked interrupts
274  HWREG( RFC_DBELL_BASE + RFC_DBELL_O_RFCPEIEN ) &= ~ui32Mask;
275 }
uint32_t RFCCpeIntGetAndClear ( void  )

Get and clear CPE interrupt flags.

105 {
106  uint32_t ui32Ifg = HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG);
107 
108  do {
109  HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) = ~ui32Ifg;
110  } while (HWREG(RFC_DBELL_BASE+RFC_DBELL_O_RFCPEIFG) & ui32Ifg);
111 
112  return (ui32Ifg);
113 }
void RFCCPEPatchReset ( void  )

Reset previously patched CPE RAM to a state where it can be patched again.

388 {
389  uint8_t *pPatchTab = (uint8_t *) (_CPERAM_START + _PARSER_PATCH_TAB_OFFSET);
390  uint32_t *pIrqPatch = (uint32_t *) (_CPERAM_START + _IRQPATCH_OFFSET);
391 
392  memset(pPatchTab, 0xFF, _IRQPATCH_OFFSET - _PARSER_PATCH_TAB_OFFSET);
393 
394  int i;
395  for (i = 0; i < sizeof(rfc_defaultIrqAddr)/sizeof(rfc_defaultIrqAddr[0]); i++)
396  {
397  pIrqPatch[i * 2 + 1] = rfc_defaultIrqAddr[i];
398  }
399 }
static const uint16_t rfc_defaultIrqAddr[]
Definition: rfc.c:82
#define _IRQPATCH_OFFSET
Definition: rfc.c:79
#define _CPERAM_START
Definition: rfc.c:76
#define _PARSER_PATCH_TAB_OFFSET
Definition: rfc.c:77
uint32_t RFCDoorbellSendTo ( uint32_t  pOp)

Send command to doorbell and wait for ack.

123 {
124  while(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_CMDR) != 0);
125 
126  RFCAckIntClear();
127 
128  HWREG(RFC_DBELL_BASE+RFC_DBELL_O_CMDR) = pOp;
129 
130  while(!HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFACKIFG));
131  RFCAckIntClear();
132 
133  return(HWREG(RFC_DBELL_BASE + RFC_DBELL_O_CMDSTA));
134 }
static void RFCAckIntClear(void)
Clear interrupt flags.
Definition: rfc.h:334

Here is the call graph for this function:

static void RFCHwIntClear ( uint32_t  ui32Mask)
inlinestatic

Clear interrupt flags.

322 {
323  // Clear pending interrupts.
324  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = ~ui32Mask;
325 }
static void RFCHwIntDisable ( uint32_t  ui32Mask)
inlinestatic

Disable HW interrupt.

285 {
286  // Disable the masked interrupts
287  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) &= ~ui32Mask;
288 }
static void RFCHwIntEnable ( uint32_t  ui32Mask)
inlinestatic

This function is used to map only HW interrupts, and clears/unmasks them. These interrupts are then enabled.

256 {
257  // Clear any pending interrupts.
258  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIFG) = 0x0;
259 
260  // Enable the masked interrupts
261  HWREG(RFC_DBELL_BASE + RFC_DBELL_O_RFHWIEN) |= ui32Mask;
262 }
void RFCRfTrimRead ( rfc_radioOp_t pOpSetup,
rfTrim_t rfTrim 
)

Read RF trim from flash using CM3.

166 {
167  int divider;
168  // Check which setup command is used
169  switch (pOpSetup->commandNo)
170  {
171  case CMD_RADIO_SETUP:
172  divider = ((rfc_CMD_RADIO_SETUP_t *)pOpSetup)->loDivider;
173  break;
175  divider = ((rfc_CMD_PROP_RADIO_DIV_SETUP_t *)pOpSetup)->loDivider;
176  break;
177  default:
178  divider = 0; // Use 2.4 GHz
179  break;
180  }
181 
182  // Read trim from FCFG1
183  pRfTrim->configIfAdc = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_IF_ADC);
184  switch (divider)
185  {
186  case 5:
187  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND_DIV5);
188  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH_DIV5);
189  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV5)
191  break;
192 
193  case 6:
194  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND_DIV6);
195  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH_DIV6);
196  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV6)
198  break;
199 
200  case 10:
201  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND_DIV10);
202  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH_DIV10);
203  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV10)
205  break;
206 
207  case 12:
208  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND_DIV12);
209  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH_DIV12);
210  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV12)
212  break;
213 
214  case 15:
215  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND_DIV15);
216  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH_DIV15);
217  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV15)
219  break;
220 
221  case 30:
222  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND_DIV30);
223  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH_DIV30);
224  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV30)
226  break;
227 
228  default:
229  pRfTrim->configRfFrontend = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_RF_FRONTEND);
230  pRfTrim->configSynth = HWREG(FCFG1_BASE + FCFG1_O_CONFIG_SYNTH);
231  // Make sure configMiscAdc is not 0 by setting an unused bit to 1
232  pRfTrim->configMiscAdc = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC)
234  break;
235  }
236 }
struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_s rfc_CMD_PROP_RADIO_DIV_SETUP_t
Definition: rf_prop_cmd.h:67
struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_s rfc_CMD_RADIO_SETUP_t
Definition: rf_common_cmd.h:62
#define CMD_PROP_RADIO_DIV_SETUP
Definition: rf_prop_cmd.h:541
#define CONFIG_MISC_ADC_DIVIDER_BM
Definition: rfc.c:74
#define CONFIG_MISC_ADC_DIVIDER
Definition: rfc.c:73
#define CMD_RADIO_SETUP
Definition: rf_common_cmd.h:163
void RFCRfTrimSet ( rfTrim_t rfTrim)

Write preloaded RF trim values to CM0.

377 {
378  memcpy((void*)&HWREG(0x21000018), (void*)pRfTrim, sizeof(rfTrim_t));
379 }
Definition: rfc.h:72
void RFCRTrim ( rfc_radioOp_t pOpSetup)

Check Override RTrim vs FCFG RTrim.

245 {
246  int32_t divider;
247  uint32_t fcfg1_rtrim;
248  uint32_t *pOverride;
249  int32_t override_index;
250  uint32_t override_value;
251  uint32_t override_rtrim = 0;
252 
253  // Check which setup command is used
254  switch (pOpSetup->commandNo)
255  {
256  case CMD_RADIO_SETUP:
257  divider = ((rfc_CMD_RADIO_SETUP_t *)pOpSetup)->loDivider;
258  pOverride = ((rfc_CMD_RADIO_SETUP_t *)pOpSetup)->pRegOverride;
259  break;
261  divider = 2;
262  pOverride = ((rfc_CMD_PROP_RADIO_SETUP_t *)pOpSetup)->pRegOverride;
263  break;
265  divider = ((rfc_CMD_PROP_RADIO_DIV_SETUP_t *)pOpSetup)->loDivider;
266  pOverride = ((rfc_CMD_PROP_RADIO_DIV_SETUP_t *)pOpSetup)->pRegOverride;
267  break;
268  default:
269  return;
270  }
271 
272  if (pOverride == 0)
273  {
274  // Did not find override, return
275  return;
276  }
277 
278 
279  // Search top 5 overrides for RTRIM
280  for(override_index = 0; override_index < 5; override_index++)
281  {
282  override_value = pOverride[override_index];
283  if((override_value & 0xFFFF) == 0x4038)
284  {
285  override_rtrim = (override_value & 0xF0000) >> 16;
286  break;
287  }
288  }
289 
290  if (override_rtrim == 0)
291  {
292  // Did not find override, return
293  return;
294  }
295 
296  // Read trim from FCFG1
297  switch (divider)
298  {
299  case 2:
300  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC)
302  break;
303  case 5:
304  // Legacy
305  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_MISC_OTP_DATA)
307  break;
308  case 6:
309  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV6)
311  break;
312  case 10:
313  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV10)
315  break;
316  case 12:
317  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV12)
319  break;
320  case 15:
321  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV15)
323  break;
324  case 30:
325  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC_DIV30)
327  break;
328  default:
329  fcfg1_rtrim = (HWREG(FCFG1_BASE + FCFG1_O_CONFIG_MISC_ADC)
331  break;
332  }
333 
334  // Check for early samples
335  if(fcfg1_rtrim == 0xF)
336  {
337  // set default
338  switch (divider)
339  {
340  case 5:
341  case 10:
342  case 15:
343  case 30:
344  pOverride[override_index] = (override_value & 0xFFF0FFFF) | (0x7 << 16);
345  break;
346  case 2:
347  case 6:
348  case 12:
349  default:
350  pOverride[override_index] = (override_value & 0xFFF0FFFF) | (0x4 << 16);
351  break;
352  }
353  }
354  else
355  {
356  // Test Override vs FCFG1 limit.
357  if(override_rtrim >= fcfg1_rtrim)
358  {
359  // Do nothing
360  ;
361  }
362  else
363  {
364  // Set override to FCFG1 limit value
365  pOverride[override_index] = (override_value & 0xFFF0FFFF) | (fcfg1_rtrim << 16);
366  }
367  }
368 }
#define CMD_PROP_RADIO_SETUP
Definition: rf_prop_cmd.h:447
struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_s rfc_CMD_PROP_RADIO_DIV_SETUP_t
Definition: rf_prop_cmd.h:67
struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_s rfc_CMD_RADIO_SETUP_t
Definition: rf_common_cmd.h:62
#define CMD_PROP_RADIO_DIV_SETUP
Definition: rf_prop_cmd.h:541
struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_s rfc_CMD_PROP_RADIO_SETUP_t
Definition: rf_prop_cmd.h:66
#define CMD_RADIO_SETUP
Definition: rf_common_cmd.h:163
void RFCSynthPowerDown ( void  )

Turn off synth, NOTE: Radio will no longer respond to commands!

144 {
145  // Disable CPE clock, enable FSCA clock. NOTE: Radio will no longer respond to commands!
146  HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = (HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) & ~RFC_PWR_PWMCLKEN_CPE_M) | RFC_PWR_PWMCLKEN_FSCA_M;
147 
148  HWREG(RFC_RESERVED0) = 3;
149  HWREG(RFC_RESERVED1) = 0x1030;
150  HWREG(RFC_RESERVED2) = 1;
151  HWREG(RFC_RESERVED1) = 0x50;
152  HWREG(RFC_RESERVED2) = 1;
153  HWREG(RFC_RESERVED1) = 0x650;
154  HWREG(RFC_RESERVED2) = 1;
155  HWREG(RFC_RESERVED3) = 1;
156 
157 }
#define RFC_RESERVED0
Definition: rfc.c:67
#define RFC_RESERVED3
Definition: rfc.c:70
#define RFC_RESERVED2
Definition: rfc.c:69
#define RFC_RESERVED1
Definition: rfc.c:68