SimpleLink MCU SDK Driver APIs  tidrivers_cc13xx_cc26xx_3_01_01_03
RF.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
223 #ifndef ti_drivers_rf__include
224 #define ti_drivers_rf__include
225 
226 #ifdef __cplusplus
227 extern "C" {
228 #endif
229 
230 #include <stdint.h>
231 #include <stdbool.h>
232 #include <ti/sysbios/BIOS.h>
233 #include <ti/sysbios/knl/Clock.h>
234 #include <ti/sysbios/knl/Semaphore.h>
235 
236 #ifdef DEVICE_FAMILY
237  #undef DEVICE_FAMILY_PATH
238  #define DEVICE_FAMILY_PATH(x) <ti/devices/DEVICE_FAMILY/x>
239 #else
240  #error "You must define DEVICE_FAMILY at the project level as one of cc26x0, cc26x0r2, cc13x0, etc."
241 #endif
242 
243 #include DEVICE_FAMILY_PATH(driverlib/rf_common_cmd.h)
244 #include DEVICE_FAMILY_PATH(driverlib/rf_prop_cmd.h)
245 
262 #define RF_EventCmdDone (1<<0)
263 #define RF_EventLastCmdDone (1<<1)
264 #define RF_EventTxDone (1<<4)
265 #define RF_EventTXAck (1<<5)
266 #define RF_EventTxCtrl (1<<6)
267 #define RF_EventTxCtrlAck (1<<7)
268 #define RF_EventTxCtrlAckAck (1<<8)
269 #define RF_EventTxRetrans (1<<9)
270 #define RF_EventTxEntryDone (1<<10)
271 #define RF_EventTxBufferChange (1<<11)
272 #define RF_EventRxOk (1<<16)
273 #define RF_EventRxNOk (1<<17)
274 #define RF_EventRxIgnored (1<<18)
275 #define RF_EventRxEmpty (1<<19)
276 #define RF_EventRxCtrl (1<<20)
277 #define RF_EventRxCtrlAck (1<<21)
278 #define RF_EventRxBufFull (1<<22)
279 #define RF_EventRxEntryDone (1<<23)
280 #define RF_EventDataWritten (1<<24)
281 #define RF_EventNDataWritten (1<<25)
282 #define RF_EventRxAborted (1<<26)
283 #define RF_EventRxCollisionDetected (1<<27)
284 #define RF_EventModulesUnlocked (1<<29)
285 #define RF_EventInternalError (uint32_t)(1<<31)
286 #define RF_EventMdmSoft 0x0000002000000000
287 
294 #define RF_EventCmdCancelled 0x1000000000000000
295 #define RF_EventCmdAborted 0x2000000000000000
296 #define RF_EventCmdStopped 0x4000000000000000
297 #define RF_EventCmdError 0x8000000000000000
298 #define RF_EventRatCh 0x0800000000000000
299 #define RF_EventPowerUp 0x0400000000000000
300 
301 #define RF_EventError 0x0200000000000000
302 #define RF_EventCmdPreempted 0x0100000000000000
303 #define RF_EventRadioFree 0x0080000000000000
304 
324 #define RF_CTRL_SET_INACTIVITY_TIMEOUT 0
325 
334 #define RF_CTRL_UPDATE_SETUP_CMD 1
335 
340 #define RF_CTRL_SET_POWERUP_DURATION_MARGIN 2
341 
348 #define RF_CTRL_SET_RAT_RTC_ERR_TOL_VAL 3
349 
354 // Other defines
355 #define RF_GET_RSSI_ERROR_VAL (-128)
356 #define RF_CMDHANDLE_FLUSH_ALL (-1)
357 #define RF_ALLOC_ERROR (-2)
358 #define RF_ERROR_INVALID_RFMODE (-256)
359 #define RF_ERROR_CMDFS_SYNTH_PROG (-257)
360 
361 #define RF_NUM_SCHEDULE_MAP_ENTRIES 5
362 #define RF_NUM_SCHEDULE_ACCESS_ENTRIES 2
363 #define RF_NUM_SCHEDULE_COMMAND_ENTRIES (RF_NUM_SCHEDULE_MAP_ENTRIES - RF_NUM_SCHEDULE_ACCESS_ENTRIES)
364 
365 #define RF_SCH_CMD_EXECUTION_TIME_UNKNOWN 0
366 
367 
369 typedef rfc_radioOp_t RF_Op;
371 
372 
374 typedef struct {
375  uint8_t rfMode;
376  void (*cpePatchFxn)(void);
377  void (*mcePatchFxn)(void);
378  void (*rfePatchFxn)(void);
379 } RF_Mode;
380 
381 
383 typedef enum {
387 } RF_Priority;
388 
390 typedef enum {
395  RF_StatError = 0x80,
399 } RF_Stat;
400 
402 typedef uint64_t RF_EventMask;
403 
405 typedef union {
406  rfc_command_t commandId;
407  rfc_CMD_RADIO_SETUP_t common;
408  rfc_CMD_PROP_RADIO_SETUP_t prop;
409  rfc_CMD_PROP_RADIO_DIV_SETUP_t prop_div;
410 } RF_RadioSetup;
411 
412 
415 typedef int16_t RF_CmdHandle;
416 
420 typedef struct RFCC26XX_HWAttrs {
421  uint8_t hwiCpe0Priority;
422  uint8_t hwiHwPriority;
423  uint8_t swiCpe0Priority;
424  uint8_t swiHwPriority;
426 
434 typedef struct {
436  struct {
440  uint32_t nPowerUpDuration;
444  void* pPowerCb;
445  void* pErrCb;
446  } clientConfig;
448  struct {
449  struct {
450  rfc_CMD_FS_t cmdFs;
451  } mode_state;
452  Semaphore_Struct semSync;
453  RF_EventMask volatile eventSync;
454  void* pCbSync;
455  RF_EventMask unpendCause;
456  Clock_Struct clkInactivity;
457  Clock_Struct clkReqAccess;
458  RF_CmdHandle volatile chLastPosted;
459  bool bYielded;
460  } state;
461 } RF_Object;
462 
463 
467 
469 typedef enum {
474 } RF_InfoType;
475 
477 typedef struct {
479  uint32_t startTime;
480  uint32_t endTime;
483 
485 typedef struct {
489 
491 typedef union {
492  RF_CmdHandle ch;
493  uint16_t availRatCh;
494  bool bRadioState;
495  void *pScheduleMap;
496 } RF_InfoVal;
497 
506 typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
507 
508 
511 typedef struct {
513  uint32_t nPowerUpDuration;
518 } RF_Params;
519 
522 typedef struct {
523  uint32_t endTime;
526 
529 typedef struct {
530  uint32_t duration;
531  uint32_t startTime;
534 
556 extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params);
557 
558 
569 extern void RF_close(RF_Handle h);
570 
571 
582 extern uint32_t RF_getCurrentTime(void);
583 
584 
617 extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
618 
644 extern RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
645 
668 extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent);
669 
670 
689 extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
690 
709 extern RF_EventMask RF_runScheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
710 
729 extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
730 
731 
749 extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
750 
764 extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t* pCmdStruct);
765 
779 extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd);
780 
792 extern void RF_yield(RF_Handle h);
793 
805 extern void RF_Params_init(RF_Params *params);
806 
817 extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue);
818 
827 extern int8_t RF_getRssi(RF_Handle h);
828 
838 extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd);
839 
852 extern int8_t RF_ratCompare(RF_Handle h, rfc_CMD_SET_RAT_CMP_t* pCmdStruct, \
853  uint32_t compareTime, RF_Callback pRatCb);
854 
866 extern int8_t RF_ratCapture(RF_Handle h, uint16_t config, RF_Callback pRatCb);
867 
878 extern RF_Stat RF_ratHwOutput(RF_Handle h, uint16_t config);
879 
889 extern RF_Stat RF_ratDisableChannel(RF_Handle h, int8_t ratChannelNum);
890 
901 extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args);
902 
920 extern RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams);
921 
922 // Do not interfere with the app if they include the family Hwi module
923 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
924 
925 #ifdef __cplusplus
926 }
927 #endif
928 
929 #endif /* ti_drivers_rf__include */
RF_CmdHandle ch
cmd handle
Definition: RF.h:492
Cmd not executed as radio is inactive.
Definition: RF.h:392
RF parameter struct RF parameters are used with the RF_open() and RF_Params_init() call...
Definition: RF.h:511
uint32_t startTime
Start time window in RAT Time for radio access.
Definition: RF.h:531
RF_InfoType
RF_getParamsType contains the options available for using the RF_getParams()
Definition: RF.h:469
uint16_t nPowerUpDurationMargin
Powerup duration margin in us.
Definition: RF.h:517
void * pPowerCb
Power up callback.
Definition: RF.h:444
RF_Stat
RF Stat reported as return value for RF_ratCmd(), RF_getRssi(). RF_setTxPwr(), RF_cancelCmd() ...
Definition: RF.h:390
uint8_t rfMode
Variable for device operation mode; must be set to RF_MODE_MULTIPLE for dual mode operation...
Definition: RF.h:375
RF_Priority priority
Intra client priority.
Definition: RF.h:524
void(* RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
RF callback function pointer type RF callbacks can occur at the completion of posted RF operation (ch...
Definition: RF.h:506
uint8_t swiHwPriority
Priority for HW SWI. Used for all RAT channel callbacks.
Definition: RF.h:424
RF_Mode * pRfMode
Mode of operation.
Definition: RF.h:438
RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent)
Wait for posted command to complete Wait until completion of RF command identified by handle ch for c...
uint32_t nPowerUpDuration
Measured poweruptime in us or specified startup time (if left default it will measure) ...
Definition: RF.h:440
RF schedule map entry structure.
Definition: RF.h:477
RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent)
Post an RF operation (chain) to the command queue Post an RF_Op to the RF command queue of the client...
Cmd done and Successful.
Definition: RF.h:396
struct RFCC26XX_HWAttrs RFCC26XX_HWAttrs
RF Hardware attributes.
RF_EventMask RF_runScheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent)
Runs synchronously a (chain of) RF operation(s) for dual or single mode Allows a (chain of) operation...
Cmd not executed as RF driver is busy.
Definition: RF.h:391
Highest, use sparingly.
Definition: RF.h:384
bool bUpdateSetup
Setup command update.
Definition: RF.h:442
RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t *pCmdStruct)
Send any Immediate command.
uint64_t RF_EventMask
Event mask type (construct mask with combinations of RF_EventMask)
Definition: RF.h:402
bool bYielded
Client has indicated that there are no more commands.
Definition: RF.h:459
uint32_t nPowerUpDuration
Measured poweruptime in us or specified startup time (if left default it will measure) ...
Definition: RF.h:513
Cmd scheduled for execution.
Definition: RF.h:397
void RF_close(RF_Handle h)
Close client connection to RF driver.
int8_t RF_ratCompare(RF_Handle h, rfc_CMD_SET_RAT_CMP_t *pCmdStruct, uint32_t compareTime, RF_Callback pRatCb)
Setup RAT compare, and callback when compare matches. Note radio needs to be on for RAT to operate...
uint8_t hwiCpe0Priority
Priority for INT_RFC_CPE_0 interrupt.
Definition: RF.h:421
RF_Stat RF_ratDisableChannel(RF_Handle h, int8_t ratChannelNum)
Disable a RAT channel.
RF_Object * pClient
Pointer to client object.
Definition: RF.h:478
RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params)
Open client connection to RF driver.
rfc_CMD_PROP_RADIO_DIV_SETUP_t prop_div
Radio div setup for PROP mode.
Definition: RF.h:409
RF_Stat RF_ratHwOutput(RF_Handle h, uint16_t config)
Setup RAT HW output. Note radio needs to be on for RAT to operate. If radio is off, this API returns RF_ALLOC_ERROR.
uint32_t RF_getCurrentTime(void)
Return current radio timer value.
RF_getParamsVal used to input and return RF driver paramters with RF_getParams()
Definition: RF.h:491
RF_Object * RF_Handle
A handle that is returned from a RF_open() call Used for further RF client interaction with the RF dr...
Definition: RF.h:466
int8_t RF_ratCapture(RF_Handle h, uint16_t config, RF_Callback pRatCb)
Setup RAT capture, and callback when capture event happens. Note radio needs to be on for RAT to oper...
#define RF_NUM_SCHEDULE_ACCESS_ENTRIES
Number of access request entries.
Definition: RF.h:362
void * pCbSync
Internal storage for user callback.
Definition: RF.h:454
RF Hardware attributes.
Definition: RF.h:420
RF_EventMask RF_runCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent)
Runs synchronously a (chain of) RF operation(s) for single mode Allows a (chain of) operation(s) to b...
RF_Priority priority
Priority of the command or access request.
Definition: RF.h:481
rfc_radioOp_t RF_Op
Alias for the data type of the header common to all radio operations.
Definition: RF.h:370
Normal, usually best choice.
Definition: RF.h:386
void * pErrCb
Error callback.
Definition: RF.h:445
int8_t RF_getRssi(RF_Handle h)
Get rssi value.
bool bRadioState
Radio state.
Definition: RF.h:494
Clock_Struct clkReqAccess
Clock used for request access timeouts.
Definition: RF.h:457
RF_RadioSetup * pOpSetup
Radio setup radio operation, only ram right now.
Definition: RF.h:439
uint32_t duration
Radio access duration in RAT Ticks requested by the client.
Definition: RF.h:530
RF_EventMask unpendCause
Return value for RF_pendCmd()
Definition: RF.h:455
void RF_yield(RF_Handle h)
Signal that radio client is not going to issue more commands in a while.
#define RF_NUM_SCHEDULE_COMMAND_ENTRIES
Number of scheduled command entries.
Definition: RF.h:363
uint32_t startTime
Start time (in RAT tick) of the command or access request.
Definition: RF.h:479
uint32_t endTime
End time in RAT Ticks for the radio command.
Definition: RF.h:523
uint32_t nInactivityTimeout
Inactivity timeout in us.
Definition: RF.h:437
Get bitmap for the avail RAT channel.
Definition: RF.h:471
RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode)
Abort/stop/cancel command and any subsequent commands in command queue If command is running...
RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode)
Abort/stop/cancel single command in command queue If command is running, aborts/stops it and posts ca...
RF schedule command parameter struct RF schedule command parameters are used with the RF_scheduleCmd(...
Definition: RF.h:522
RF_Callback pPowerCb
Power up callback.
Definition: RF.h:514
int16_t RF_CmdHandle
A command handle that is returned from RF_postCmd() Used by RF_pendCmd() and RF_flushCmd(). A negative value indicates an error.
Definition: RF.h:415
uint16_t availRatCh
RAT channels available.
Definition: RF.h:493
RF_CmdHandle volatile chLastPosted
Command handle of most recently posted command.
Definition: RF.h:458
uint8_t swiCpe0Priority
Priority for CPE_0 SWI.
Definition: RF.h:423
RF_Op * RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd)
Get command structure pointer.
General error specifier.
Definition: RF.h:395
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:516
uint32_t endTime
End time (in RAT tick) of the command or access request.
Definition: RF.h:480
rfc_CMD_RADIO_SETUP_t common
Common mode setup (BLE, IEEE modes)
Definition: RF.h:407
RF request access parameter struct RF request access command parameters are used with the RF_requestA...
Definition: RF.h:529
RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue)
Get value for some RF driver parameters.
Cmd done but with error in CMDSTA.
Definition: RF.h:393
Get schedule timing map.
Definition: RF.h:473
RF_Priority
Priority of RF commands.
Definition: RF.h:383
uint16_t nPowerUpDurationMargin
Powerup duration margin in us.
Definition: RF.h:443
Invalid API parameters.
Definition: RF.h:394
High, time-critical commands in synchronous protocols.
Definition: RF.h:385
Union of the different flavors of RADIO_SETUP commands.
Definition: RF.h:405
Clock_Struct clkInactivity
Clock used for inactivity timeouts.
Definition: RF.h:456
uint32_t nInactivityTimeout
Inactivity timeout in us, default is infinite.
Definition: RF.h:512
RF schedule map structure.
Definition: RF.h:485
rfc_CMD_FS_t cmdFs
FS command encapsulating FS state.
Definition: RF.h:450
RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams)
Request radio access Scope:
RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd)
Send any Direct command.
RF_EventMask volatile eventSync
Event mask/value used by runCmd() and waitCmd()
Definition: RF.h:453
Get RF_CmdHandle for current cmd.
Definition: RF.h:470
Struct defining operating mode of RF driver.
Definition: RF.h:374
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:441
rfc_command_t commandId
Can be used simply to get RF operation ID.
Definition: RF.h:406
rfc_CMD_PROP_RADIO_SETUP_t prop
Radio setup for PROP mode.
Definition: RF.h:408
API ran successfully.
Definition: RF.h:398
RF_Callback pErrCb
Error callback.
Definition: RF.h:515
RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent)
Schedule an RF operation (chain) to the command queue Schedule an RF_Op to the RF command queue of th...
RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args)
Set RF control parameters.
uint8_t hwiHwPriority
Priority for INT_RFC_HW_COMB interrupt.
Definition: RF.h:422
void RF_Params_init(RF_Params *params)
Function to initialize the RF_Params struct to its defaults.
Struct used to store RF client state and configuration Pointer to an RF_Object is used as handles (RF...
Definition: RF.h:434
Semaphore_Struct semSync
Semaphore used by runCmd(), pendCmd() and powerdown sequence.
Definition: RF.h:452
Get Radio state 0: Radio OFF, 1: Radio ON.
Definition: RF.h:472
RF_Priority priority
Access priority.
Definition: RF.h:532
void * pScheduleMap
Pointer to RF schedule map.
Definition: RF.h:495
Copyright 2016, Texas Instruments Incorporated