TI-RTOS Drivers  tidrivers_cc13xx_cc26xx_2_21_00_04
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  */
206 #ifndef ti_drivers_rf__include
207 #define ti_drivers_rf__include
208 
209 #ifdef __cplusplus
210 extern "C" {
211 #endif
212 
213 #include <stdint.h>
214 #include <stdbool.h>
215 #include <ti/sysbios/BIOS.h>
216 #include <ti/sysbios/knl/Clock.h>
217 #include <ti/sysbios/knl/Semaphore.h>
218 #include <driverlib/rf_common_cmd.h>
219 #include <driverlib/rf_prop_cmd.h>
220 
237 #define RF_EventCmdDone (1<<0)
238 #define RF_EventLastCmdDone (1<<1)
239 #define RF_EventTxDone (1<<4)
240 #define RF_EventTXAck (1<<5)
241 #define RF_EventTxCtrl (1<<6)
242 #define RF_EventTxCtrlAck (1<<7)
243 #define RF_EventTxCtrlAckAck (1<<8)
244 #define RF_EventTxRetrans (1<<9)
245 #define RF_EventTxEntryDone (1<<10)
246 #define RF_EventTxBufferChange (1<<11)
247 #define RF_EventRxOk (1<<16)
248 #define RF_EventRxNOk (1<<17)
249 #define RF_EventRxIgnored (1<<18)
250 #define RF_EventRxEmpty (1<<19)
251 #define RF_EventRxCtrl (1<<20)
252 #define RF_EventRxCtrlAck (1<<21)
253 #define RF_EventRxBufFull (1<<22)
254 #define RF_EventRxEntryDone (1<<23)
255 #define RF_EventDataWritten (1<<24)
256 #define RF_EventNDataWritten (1<<25)
257 #define RF_EventRxAborted (1<<26)
258 #define RF_EventRxCollisionDetected (1<<27)
259 #define RF_EventModulesUnlocked (1<<29)
260 #define RF_EventInternalError (uint32_t)(1<<31)
261 #define RF_EventMdmSoft 0x0000002000000000
262 
269 #define RF_EventCmdCancelled 0x1000000000000000
270 #define RF_EventCmdAborted 0x2000000000000000
271 #define RF_EventCmdStopped 0x4000000000000000
272 #define RF_EventCmdError 0x8000000000000000
273 #define RF_EventRatCh 0x0800000000000000
274 #define RF_EventPowerUp 0x0400000000000000
275 
276 #define RF_EventError 0x0200000000000000
277 #define RF_EventCmdPreempted 0x0100000000000000
278 #define RF_EventRadioFree 0x0080000000000000
279 
299 #define RF_CTRL_SET_INACTIVITY_TIMEOUT 0
300 
309 #define RF_CTRL_UPDATE_SETUP_CMD 1
310 
315 #define RF_CTRL_SET_POWERUP_DURATION_MARGIN 2
316 
323 // Other defines
324 #define RF_GET_RSSI_ERROR_VAL (-128)
325 #define RF_CMDHANDLE_FLUSH_ALL (-1)
326 #define RF_ALLOC_ERROR (-2)
327 #define RF_ERROR_INVALID_RFMODE (-256)
328 #define RF_ERROR_CMDFS_SYNTH_PROG (-257)
329 
331 typedef rfc_radioOp_t RF_Op;
333 
334 
336 typedef struct {
337  uint8_t rfMode;
338  void (*cpePatchFxn)(void);
339  void (*mcePatchFxn)(void);
340  void (*rfePatchFxn)(void);
341 } RF_Mode;
342 
343 
345 typedef enum {
349 } RF_Priority;
350 
352 typedef enum {
356  RF_StatError = 0x80,
361 } RF_Stat;
362 
364 typedef uint64_t RF_EventMask;
365 
367 typedef union {
368  rfc_command_t commandId;
369  rfc_CMD_RADIO_SETUP_t common;
370  rfc_CMD_PROP_RADIO_SETUP_t prop;
371  rfc_CMD_PROP_RADIO_DIV_SETUP_t prop_div;
372 } RF_RadioSetup;
373 
374 
377 typedef int16_t RF_CmdHandle;
378 
382 typedef struct RFCC26XX_HWAttrs {
383  uint8_t hwiCpe0Priority;
384  uint8_t hwiHwPriority;
385  uint8_t swiCpe0Priority;
386  uint8_t swiHwPriority;
388 
396 typedef struct {
398  struct {
402  uint32_t nPowerUpDuration;
406  void* pPowerCb;
407  void* pErrCb;
408  } clientConfig;
410  struct {
411  struct {
412  rfc_CMD_FS_t cmdFs;
413  } mode_state;
414  Semaphore_Struct semSync;
415  RF_EventMask volatile eventSync;
416  void* pCbSync;
417  RF_EventMask unpendCause;
418  Clock_Struct clkInactivity;
419  Clock_Struct clkReqAccess;
420  RF_CmdHandle volatile chLastPosted;
421  bool bYielded;
422  } state;
423 } RF_Object;
424 
425 
429 
431 typedef enum {
435 } RF_InfoType;
436 
438 typedef union {
439  RF_CmdHandle ch;
440  uint16_t availRatCh;
441  bool bRadioState;
442 } RF_InfoVal;
443 
452 typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
453 
454 
457 typedef struct {
459  uint32_t nPowerUpDuration;
464 } RF_Params;
465 
468 typedef struct {
469  uint32_t endTime;
472 
475 typedef struct {
476  uint32_t duration;
477  uint32_t startTime;
480 
502 extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params);
503 
504 
515 extern void RF_close(RF_Handle h);
516 
517 
528 extern uint32_t RF_getCurrentTime(void);
529 
530 
563 extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
564 
590 extern RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
591 
614 extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent);
615 
616 
635 extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
636 
652 extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
653 
654 
670 extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
671 
685 extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t* pCmdStruct);
686 
700 extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd);
701 
713 extern void RF_yield(RF_Handle h);
714 
726 extern void RF_Params_init(RF_Params *params);
727 
738 extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue);
739 
748 extern int8_t RF_getRssi(RF_Handle h);
749 
759 extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd);
760 
773 extern int8_t RF_ratCompare(RF_Handle h, rfc_CMD_SET_RAT_CMP_t* pCmdStruct, \
774  uint32_t compareTime, RF_Callback pRatCb);
775 
787 extern int8_t RF_ratCapture(RF_Handle h, uint16_t config, RF_Callback pRatCb);
788 
799 extern RF_Stat RF_ratHwOutput(RF_Handle h, uint16_t config);
800 
810 extern RF_Stat RF_ratDisableChannel(RF_Handle h, int8_t ratChannelNum);
811 
822 extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args);
823 
841 extern RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams);
842 
843 // Do not interfere with the app if they include the family Hwi module
844 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
845 
846 #ifdef __cplusplus
847 }
848 #endif
849 
850 #endif /* ti_drivers_rf__include */
RF_CmdHandle ch
cmd handle
Definition: RF.h:439
Cmd not executed as radio is inactive.
Definition: RF.h:358
RF parameter struct RF parameters are used with the RF_open() and RF_Params_init() call...
Definition: RF.h:457
uint32_t startTime
Start time window in RAT Time for radio access.
Definition: RF.h:477
RF_InfoType
RF_getParamsType contains the options available for using the RF_getParams()
Definition: RF.h:431
uint16_t nPowerUpDurationMargin
Powerup duration margin in us.
Definition: RF.h:463
void * pPowerCb
Power up callback.
Definition: RF.h:406
RF_Stat
RF Stat reported as return value for RF_ratCmd(), RF_getRssi(). RF_setTxPwr(), RF_cancelCmd() ...
Definition: RF.h:352
uint8_t rfMode
Variable for device operation mode; must be set to RF_MODE_MULTIPLE for dual mode operation...
Definition: RF.h:337
RF_Priority priority
Intra client priority.
Definition: RF.h:470
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:452
uint8_t swiHwPriority
Priority for HW SWI. Used for all RAT channel callbacks.
Definition: RF.h:386
RF_Mode * pRfMode
Mode of operation.
Definition: RF.h:400
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:402
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:354
struct RFCC26XX_HWAttrs RFCC26XX_HWAttrs
RF Hardware attributes.
Cmd not executed as RF driver is busy.
Definition: RF.h:357
Highest, use sparingly.
Definition: RF.h:346
bool bUpdateSetup
Setup command update.
Definition: RF.h:404
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:364
bool bYielded
Client has indicated that there are no more commands.
Definition: RF.h:421
uint32_t nPowerUpDuration
Measured poweruptime in us or specified startup time (if left default it will measure) ...
Definition: RF.h:459
Cmd scheduled for execution.
Definition: RF.h:355
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:383
RF_Stat RF_ratDisableChannel(RF_Handle h, int8_t ratChannelNum)
Disable a RAT channel.
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:371
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:438
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:428
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...
void * pCbSync
Internal storage for user callback.
Definition: RF.h:416
RF Hardware attributes.
Definition: RF.h:382
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) Allows a (chain of) operation(s) to be posted to the ...
rfc_radioOp_t RF_Op
Alias for the data type of the header common to all radio operations.
Definition: RF.h:332
Normal, usually best choice.
Definition: RF.h:348
void * pErrCb
Error callback.
Definition: RF.h:407
int8_t RF_getRssi(RF_Handle h)
Get rssi value.
bool bRadioState
Radio state.
Definition: RF.h:441
Clock_Struct clkReqAccess
Clock used for request access timeouts.
Definition: RF.h:419
RF_RadioSetup * pOpSetup
Radio setup radio operation, only ram right now.
Definition: RF.h:401
uint32_t duration
Radio access duration in RAT Ticks requested by the client.
Definition: RF.h:476
RF_EventMask unpendCause
Return value for RF_pendCmd()
Definition: RF.h:417
void RF_yield(RF_Handle h)
Signal that radio client is not going to issue more commands in a while.
uint32_t endTime
End time in RAT Ticks for the radio command.
Definition: RF.h:469
uint32_t nInactivityTimeout
Inactivity timeout in us.
Definition: RF.h:399
Get bitmap for the avail RAT channel.
Definition: RF.h:433
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:468
RF_Callback pPowerCb
Power up callback.
Definition: RF.h:460
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:377
uint16_t availRatCh
RAT channels available.
Definition: RF.h:440
RF_CmdHandle volatile chLastPosted
Command handle of most recently posted command.
Definition: RF.h:420
uint8_t swiCpe0Priority
Priority for CPE_0 SWI.
Definition: RF.h:385
RF_Op * RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd)
Get command structure pointer.
General error specifier.
Definition: RF.h:356
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:462
rfc_CMD_RADIO_SETUP_t common
Common mode setup (BLE, IEEE modes)
Definition: RF.h:369
RF request access parameter struct RF request access command parameters are used with the RF_requestA...
Definition: RF.h:475
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:359
RF_Priority
Priority of RF commands.
Definition: RF.h:345
uint16_t nPowerUpDurationMargin
Powerup duration margin in us.
Definition: RF.h:405
Invalid API parameters.
Definition: RF.h:360
High, time-critical commands in synchronous protocols.
Definition: RF.h:347
Union of the different flavors of RADIO_SETUP commands.
Definition: RF.h:367
Clock_Struct clkInactivity
Clock used for inactivity timeouts.
Definition: RF.h:418
uint32_t nInactivityTimeout
Inactivity timeout in us, default is infinite.
Definition: RF.h:458
rfc_CMD_FS_t cmdFs
FS command encapsulating FS state.
Definition: RF.h:412
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:415
Get RF_CmdHandle for current cmd.
Definition: RF.h:432
Struct defining operating mode of RF driver.
Definition: RF.h:336
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:403
rfc_command_t commandId
Can be used simply to get RF operation ID.
Definition: RF.h:368
rfc_CMD_PROP_RADIO_SETUP_t prop
Radio setup for PROP mode.
Definition: RF.h:370
API ran successfully.
Definition: RF.h:353
RF_Callback pErrCb
Error callback.
Definition: RF.h:461
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:384
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:396
Semaphore_Struct semSync
Semaphore used by runCmd(), pendCmd() and powerdown sequence.
Definition: RF.h:414
Get Radio state 0: Radio OFF, 1: Radio ON.
Definition: RF.h:434
RF_Priority priority
Access priority.
Definition: RF.h:478
Copyright 2016, Texas Instruments Incorporated