TI-RTOS Drivers  tidrivers_full_2_20_00_08
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  */
210 #ifndef ti_drivers_rf__include
211 #define ti_drivers_rf__include
212 
213 #ifdef __cplusplus
214 extern "C" {
215 #endif
216 
217 #include <stdint.h>
218 #include <stdbool.h>
219 #include <ti/sysbios/BIOS.h>
220 #include <ti/sysbios/knl/Clock.h>
221 #include <ti/sysbios/knl/Semaphore.h>
222 #include <driverlib/rf_common_cmd.h>
223 #include <driverlib/rf_prop_cmd.h>
224 
241 #define RF_EventCmdDone (1<<0)
242 #define RF_EventLastCmdDone (1<<1)
243 #define RF_EventTxDone (1<<4)
244 #define RF_EventTXAck (1<<5)
245 #define RF_EventTxCtrl (1<<6)
246 #define RF_EventTxCtrlAck (1<<7)
247 #define RF_EventTxCtrlAckAck (1<<8)
248 #define RF_EventTxRetrans (1<<9)
249 #define RF_EventTxEntryDone (1<<10)
250 #define RF_EventTxBufferChange (1<<11)
251 #define RF_EventRxOk (1<<16)
252 #define RF_EventRxNOk (1<<17)
253 #define RF_EventRxIgnored (1<<18)
254 #define RF_EventRxEmpty (1<<19)
255 #define RF_EventRxCtrl (1<<20)
256 #define RF_EventRxCtrlAck (1<<21)
257 #define RF_EventRxBufFull (1<<22)
258 #define RF_EventRxEntryDone (1<<23)
259 #define RF_EventDataWritten (1<<24)
260 #define RF_EventNDataWritten (1<<25)
261 #define RF_EventRxAborted (1<<26)
262 #define RF_EventRxCollisionDetected (1<<27)
263 #define RF_EventModulesUnlocked (1<<29)
264 #define RF_EventInternalError (uint32_t)(1<<31)
265 #define RF_EventMdmSoft 0x0000002000000000
266 
273 #define RF_EventCmdCancelled 0x1000000000000000
274 #define RF_EventCmdAborted 0x2000000000000000
275 #define RF_EventCmdStopped 0x4000000000000000
276 #define RF_EventCmdError 0x8000000000000000
277 #define RF_EventRatCh 0x0800000000000000
278 #define RF_EventPowerUp 0x0400000000000000
279 
280 #define RF_EventError 0x0200000000000000
281 
301 #define RF_CTRL_SET_INACTIVITY_TIMEOUT 0
302 
309 // Other defines
310 #define RF_GET_RSSI_ERROR_VAL (-128)
311 #define RF_CMDHANDLE_FLUSH_ALL (-1)
312 #define RF_ALLOC_ERROR (-2)
313 #define RF_ERROR_INVALID_RFMODE (-256)
314 #define RF_ERROR_CMDFS_SYNTH_PROG (-257)
315 
317 typedef rfc_radioOp_t RF_Op;
319 
320 
322 typedef struct {
323  uint8_t rfMode;
324  void (*cpePatchFxn)(void);
325  void (*mcePatchFxn)(void);
326  void (*rfePatchFxn)(void);
327 } RF_Mode;
328 
329 
331 typedef enum {
336 } RF_Priority;
337 
339 typedef enum {
344  RF_StatError = 0x80,
348 } RF_Stat;
349 
351 typedef uint64_t RF_EventMask;
352 
354 typedef union {
355  rfc_command_t commandId;
356  rfc_CMD_RADIO_SETUP_t common;
357  rfc_CMD_PROP_RADIO_SETUP_t prop;
358 } RF_RadioSetup;
359 
360 
363 typedef int16_t RF_CmdHandle;
364 
368 typedef struct RFCC26XX_HWAttrs {
369  uint8_t hwiCpe0Priority;
370  uint8_t hwiHwPriority;
371  uint8_t swiCpe0Priority;
372  uint8_t swiHwPriority;
374 
382 typedef struct {
384  struct {
388  uint32_t nPowerUpDuration;
390  void* pPowerCb;
391  void* pErrCb;
392  } clientConfig;
394  struct {
395  struct {
396  rfc_CMD_FS_t cmdFs;
397  } mode_state;
398  Semaphore_Struct semSync;
399  RF_EventMask volatile eventSync;
400  void* pCbSync;
401  RF_EventMask unpendCause;
402  Clock_Struct clkInactivity;
403  RF_CmdHandle volatile chLastPosted;
404  bool bYielded;
405  } state;
406 } RF_Object;
407 
408 
412 
414 typedef enum {
418 } RF_InfoType;
419 
421 typedef union {
422  RF_CmdHandle ch;
423  uint16_t availRatCh;
424  bool bRadioState;
425 } RF_InfoVal;
426 
435 typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
436 
437 
440 typedef struct {
442  uint32_t nPowerUpDuration;
446 } RF_Params;
447 
450 typedef struct {
452  uint32_t endTime;
454 
457 typedef struct {
458  uint32_t duration;
459  uint32_t startTime;
460  uint32_t endTime;
463 
485 extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params);
486 
487 
498 extern void RF_close(RF_Handle h);
499 
500 
511 extern uint32_t RF_getCurrentTime(void);
512 
513 
542 extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
543 
569 extern RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
570 
593 extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent);
594 
595 
613 extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
614 
630 extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
631 
632 
648 extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
649 
663 extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t* pCmdStruct);
664 
678 extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd);
679 
691 extern void RF_yield(RF_Handle h);
692 
704 extern void RF_Params_init(RF_Params *params);
705 
716 extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue);
717 
726 extern int8_t RF_getRssi(RF_Handle h);
727 
737 extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd);
738 
751 extern int8_t RF_ratCompare(RF_Handle h, rfc_CMD_SET_RAT_CMP_t* pCmdStruct, \
752  uint32_t compareTime, RF_Callback pRatCb);
753 
765 extern int8_t RF_ratCapture(RF_Handle h, uint16_t config, RF_Callback pRatCb);
766 
777 extern RF_Stat RF_ratHwOutput(RF_Handle h, uint16_t config);
778 
788 extern RF_Stat RF_ratDisableChannel(RF_Handle h, int8_t ratChannelNum);
789 
800 extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args);
801 
811 extern RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams);
812 
813 // Do not interfere with the app if they include the family Hwi module
814 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
815 
816 #ifdef __cplusplus
817 }
818 #endif
819 
820 #endif /* ti_drivers_rf__include */
RF_CmdHandle ch
cmd handle
Definition: RF.h:422
Cmd not executed as radio is inactive.
Definition: RF.h:341
RF parameter struct RF parameters are used with the RF_open() and RF_Params_init() call...
Definition: RF.h:440
uint32_t startTime
Start time window in us (from current time) for radio access.
Definition: RF.h:459
RF_InfoType
RF_getParamsType contains the options available for using the RF_getParams()
Definition: RF.h:414
void * pPowerCb
Power up callback.
Definition: RF.h:390
RF_Stat
RF Stat reported as return value for RF_ratCmd(), RF_getRssi(). RF_setTxPwr(), RF_cancelCmd() ...
Definition: RF.h:339
uint8_t rfMode
Variable for device operation mode; must be set to RF_MODE_MULTIPLE for dual mode operation...
Definition: RF.h:323
RF_Priority priority
Intra client priority.
Definition: RF.h:451
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:435
uint8_t swiHwPriority
Priority for HW SWI. Used for all RAT channel callbacks.
Definition: RF.h:372
RF_Mode * pRfMode
Mode of operation.
Definition: RF.h:386
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:388
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:345
struct RFCC26XX_HWAttrs RFCC26XX_HWAttrs
RF Hardware attributes.
Cmd not executed as RF driver is busy.
Definition: RF.h:340
Highest, use sparingly.
Definition: RF.h:332
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:351
bool bYielded
Client has indicated that there are no more commands.
Definition: RF.h:404
uint32_t nPowerUpDuration
Measured poweruptime in us or specified startup time (if left default it will measure) ...
Definition: RF.h:442
Cmd scheduled for execution.
Definition: RF.h:346
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:369
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.
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:421
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:411
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:400
RF Hardware attributes.
Definition: RF.h:368
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:318
Normal, usually best choice.
Definition: RF.h:334
void * pErrCb
Error callback.
Definition: RF.h:391
int8_t RF_getRssi(RF_Handle h)
Get rssi value.
Low, use for infinite or background commands.
Definition: RF.h:335
bool bRadioState
Radio state.
Definition: RF.h:424
RF_RadioSetup * pOpSetup
Radio setup radio operation, only ram right now.
Definition: RF.h:387
uint32_t endTime
End time window in us (from current time) for radio access.
Definition: RF.h:460
uint32_t duration
Radio access duration requested by the client.
Definition: RF.h:458
RF_EventMask unpendCause
Return value for RF_pendCmd()
Definition: RF.h:401
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 us for the radio command.
Definition: RF.h:452
uint32_t nInactivityTimeout
Inactivity timeout in us.
Definition: RF.h:385
Get bitmap for the avail RAT channel.
Definition: RF.h:416
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:450
RF_Callback pPowerCb
Power up callback.
Definition: RF.h:444
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:363
uint16_t availRatCh
RAT channels available.
Definition: RF.h:423
RF_CmdHandle volatile chLastPosted
Command handle of most recently posted command.
Definition: RF.h:403
uint8_t swiCpe0Priority
Priority for CPE_0 SWI.
Definition: RF.h:371
RF_Op * RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd)
Get command structure pointer.
General error specifier.
Definition: RF.h:344
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:443
rfc_CMD_RADIO_SETUP_t common
Common mode setup (BLE, IEEE modes)
Definition: RF.h:356
RF request access parameter struct RF request access command parameters are used with the RF_requestA...
Definition: RF.h:457
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:342
RF_Priority
Priority of RF commands.
Definition: RF.h:331
Invalid API parameters.
Definition: RF.h:343
High, time-critical commands in synchronous protocols.
Definition: RF.h:333
Union of the different flavors of RADIO_SETUP commands.
Definition: RF.h:354
Clock_Struct clkInactivity
Clock used for inactivity timeouts.
Definition: RF.h:402
uint32_t nInactivityTimeout
Inactivity timeout in us, default is infinite.
Definition: RF.h:441
rfc_CMD_FS_t cmdFs
FS command encapsulating FS state.
Definition: RF.h:396
RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams)
Request radio access.
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:399
Get RF_CmdHandle for current cmd.
Definition: RF.h:415
Struct defining operating mode of RF driver.
Definition: RF.h:322
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:389
rfc_command_t commandId
Can be used simply to get RF operation ID.
Definition: RF.h:355
rfc_CMD_PROP_RADIO_SETUP_t prop
Radio setup for PROP mode.
Definition: RF.h:357
API ran successfully.
Definition: RF.h:347
RF_Callback pErrCb
Error callback.
Definition: RF.h:445
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:370
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:382
Semaphore_Struct semSync
Semaphore used by runCmd(), pendCmd() and powerdown sequence.
Definition: RF.h:398
Get Radio state 0: Radio OFF, 1: Radio ON.
Definition: RF.h:417
RF_Priority priority
Access priority.
Definition: RF.h:461
Copyright 2016, Texas Instruments Incorporated