TI-RTOS Drivers  tidrivers_cc13xx_cc26xx_2_16_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  */
78 #ifndef ti_drivers_rf__include
79 #define ti_drivers_rf__include
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 #include <stdint.h>
86 #include <stdbool.h>
87 #include <ti/sysbios/BIOS.h>
88 #include <ti/sysbios/knl/Clock.h>
89 #include <ti/sysbios/knl/Semaphore.h>
90 #include <driverlib/rf_common_cmd.h>
91 #include <driverlib/rf_prop_cmd.h>
92 
94 #define RF_GET_RSSI_ERROR_VAL (-128)
95 #define RF_CMDHANDLE_FLUSH_ALL (-1)
96 #define RF_ALLOC_ERROR (-2)
97 
98 #define RF_EventCmdDone (1<<0)
100 #define RF_EventLastCmdDone (1<<1)
101 #define RF_EventTxDone (1<<4)
102 #define RF_EventTXAck (1<<5)
103 #define RF_EventTxCtrl (1<<6)
104 #define RF_EventTxCtrlAck (1<<7)
105 #define RF_EventTxCtrlAckAck (1<<8)
106 #define RF_EventTxRetrans (1<<9)
107 #define RF_EventTxEntryDone (1<<10)
108 #define RF_EventTxBufferChange (1<<11)
109 #define RF_EventRxOk (1<<16)
110 #define RF_EventRxNOk (1<<17)
111 #define RF_EventRxIgnored (1<<18)
112 #define RF_EventRxEmpty (1<<19)
113 #define RF_EventRxCtrl (1<<20)
114 #define RF_EventRxCtrlAck (1<<21)
115 #define RF_EventRxBufFull (1<<22)
116 #define RF_EventRxEntryDone (1<<23)
117 #define RF_EventDataWritten (1<<24)
118 #define RF_EventNDataWritten (1<<25)
119 #define RF_EventRxAborted (1<<26)
120 #define RF_EventRxCollisionDetected (1<<27)
121 #define RF_EventModulesUnlocked (1<<29)
122 #define RF_EventInternalError (1<<31)
123 #define RF_EventMdmSoft 0x0000002000000000
124 
125 #define RF_EventCmdCancelled 0x1000000000000000
127 #define RF_EventCmdAborted 0x2000000000000000
128 #define RF_EventCmdStopped 0x4000000000000000
129 #define RF_EventCmdError 0x8000000000000000
130 #define RF_EventRatCh 0x0800000000000000
131 
132 typedef rfc_radioOp_t RF_Op;
134 
135 
137 typedef struct {
138  uint8_t rfMode;
139  void (*cpePatchFxn)(void);
140  void (*mcePatchFxn)(void);
141  void (*rfePatchFxn)(void);
142 } RF_Mode;
143 
144 
146 typedef enum {
151 } RF_Priority;
152 
154 typedef enum {
159  RF_StatError = 0x80,
163 } RF_Stat;
164 
166 typedef uint64_t RF_EventMask;
167 
169 typedef union {
170  rfc_command_t commandId;
171  rfc_CMD_RADIO_SETUP_t common;
172  rfc_CMD_PROP_RADIO_SETUP_t prop;
173 } RF_RadioSetup;
174 
175 
178 typedef int16_t RF_CmdHandle;
179 
180 
183 typedef struct {
185  uint32_t nPowerUpDuration;
187 } RF_Params;
188 
192 typedef struct RFCC26XX_HWAttrs {
193  uint8_t hwiCpe0Priority;
194  uint8_t hwiHwPriority;
195  uint8_t swiCpe0Priority;
196  uint8_t swiHwPriority;
198 
206 typedef struct {
208  struct {
212  uint32_t nPowerUpDuration;
214  } clientConfig;
216  struct {
217  struct {
218  rfc_CMD_FS_t cmdFs;
219  } mode_state;
220  Semaphore_Struct semSync;
221  RF_EventMask volatile eventSync;
222  void* pCbSync;
223  RF_EventMask unpendCause;
224  Clock_Struct clkInactivity;
225  RF_CmdHandle volatile chLastPosted;
226  bool bYielded;
227  } state;
228 } RF_Object;
229 
230 
234 
236 typedef enum {
240 } RF_InfoType;
241 
243 typedef union {
244  RF_CmdHandle ch;
245  uint16_t availRatCh;
246  bool bRadioState;
247 } RF_InfoVal;
248 
256 typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
257 
258 
278 extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params);
279 
280 
291 extern void RF_close(RF_Handle h);
292 
293 
304 extern uint32_t RF_getCurrentTime(void);
305 
306 
335 extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
336 
337 
360 extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent);
361 
362 
380 extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
381 
397 extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
398 
399 
415 extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
416 
430 extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t* pCmdStruct);
431 
445 extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd);
446 
458 extern void RF_yield(RF_Handle h);
459 
469 extern void RF_Params_init(RF_Params *params);
470 
481 extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue);
482 
491 extern int8_t RF_getRssi(RF_Handle h);
492 
502 extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd);
503 
515 extern int8_t RF_ratCompare(RF_Handle h, rfc_CMD_SET_RAT_CMP_t* pCmdStruct, \
516  uint32_t compareTime, RF_Callback pRatCb);
517 
528 extern int8_t RF_ratCapture(RF_Handle h, uint16_t config, RF_Callback pRatCb);
529 
539 extern RF_Stat RF_ratHwOutput(RF_Handle h, uint16_t config);
540 
550 extern RF_Stat RF_ratDisableChannel(RF_Handle h, int8_t ratChannelNum);
551 
552 // Do not interfere with the app if they include the family Hwi module
553 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
554 
555 #ifdef __cplusplus
556 }
557 #endif
558 
559 #endif /* ti_drivers_rf__include */
RF_CmdHandle ch
cmd handle
Definition: RF.h:244
Cmd not executed as radio is inactive.
Definition: RF.h:156
RF parameter struct RF parameters are used with the RF_open() and RF_Params_init() call...
Definition: RF.h:183
RF_InfoType
RF_getParamsType contains the options available for using the RF_getParams()
Definition: RF.h:236
RF_Stat
RF Stat reported as return value for RF_ratCmd(), RF_getRssi(). RF_setTxPwr(), RF_cancelCmd() ...
Definition: RF.h:154
uint8_t rfMode
Variable for tracking operation mode.
Definition: RF.h:138
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:256
uint8_t swiHwPriority
Priority for HW SWI. Used for all RAT channel callbacks.
Definition: RF.h:196
RF_Mode * pRfMode
Mode of operation.
Definition: RF.h:210
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:212
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:160
struct RFCC26XX_HWAttrs RFCC26XX_HWAttrs
RF Hardware attributes.
Cmd not executed as RF driver is busy.
Definition: RF.h:155
Highest, use sparingly.
Definition: RF.h:147
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:166
bool bYielded
Client has indicated that there are no more commands.
Definition: RF.h:226
uint32_t nPowerUpDuration
Measured poweruptime in us or specified startup time (if left default it will measure) ...
Definition: RF.h:185
Cmd scheduled for execution.
Definition: RF.h:161
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.
uint8_t hwiCpe0Priority
Priority for INT_RFC_CPE_0 interrupt.
Definition: RF.h:193
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.
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:243
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:233
int8_t RF_ratCapture(RF_Handle h, uint16_t config, RF_Callback pRatCb)
Setup RAT capture, and callback when capture event happens.
void * pCbSync
Internal storage for user callback.
Definition: RF.h:222
RF Hardware attributes.
Definition: RF.h:192
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:133
Normal, usually best choice.
Definition: RF.h:149
int8_t RF_getRssi(RF_Handle h)
Get rssi value.
Low, use for infinite or background commands.
Definition: RF.h:150
bool bRadioState
Radio state.
Definition: RF.h:246
RF_RadioSetup * pOpSetup
Radio setup radio operation, only ram right now.
Definition: RF.h:211
RF_EventMask unpendCause
Return value for RF_pendCmd()
Definition: RF.h:223
void RF_yield(RF_Handle h)
Signal that radio client is not going to issue more commands in a while.
uint32_t nInactivityTimeout
Inactivity timeout in us.
Definition: RF.h:209
Get bitmap for the avail RAT channel.
Definition: RF.h:238
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...
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:178
uint16_t availRatCh
RAT channels available.
Definition: RF.h:245
RF_CmdHandle volatile chLastPosted
Command handle of most recently posted command.
Definition: RF.h:225
uint8_t swiCpe0Priority
Priority for CPE_0 SWI.
Definition: RF.h:195
RF_Op * RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd)
Get command structure pointer.
General error specifier.
Definition: RF.h:159
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:186
rfc_CMD_RADIO_SETUP_t common
Common mode setup (BLE, IEEE modes)
Definition: RF.h:171
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:157
RF_Priority
Priority of RF commands.
Definition: RF.h:146
Invalid API parameters.
Definition: RF.h:158
High, time-critical commands in synchronous protocols.
Definition: RF.h:148
Union of the different flavors of RADIO_SETUP commands.
Definition: RF.h:169
Clock_Struct clkInactivity
Clock used for inactivity timeouts.
Definition: RF.h:224
uint32_t nInactivityTimeout
Inactivity timeout in us, default is infinite.
Definition: RF.h:184
rfc_CMD_FS_t cmdFs
FS command encapsulating FS state.
Definition: RF.h:218
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:221
Get RF_CmdHandle for current cmd.
Definition: RF.h:237
Struct defining operating mode of RF driver.
Definition: RF.h:137
bool bPowerUpXOSC
Allways enable XOSC_HF at chip wakeup.
Definition: RF.h:213
rfc_command_t commandId
Can be used simply to get RF operation ID.
Definition: RF.h:170
rfc_CMD_PROP_RADIO_SETUP_t prop
Radio setup for PROP mode.
Definition: RF.h:172
API ran successfully.
Definition: RF.h:162
uint8_t hwiHwPriority
Priority for INT_RFC_HW_COMB interrupt.
Definition: RF.h:194
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:206
Semaphore_Struct semSync
Semaphore used by runCmd(), pendCmd() and powerdown sequence.
Definition: RF.h:220
Get Radio state 0: Radio OFF, 1: Radio ON.
Definition: RF.h:239
Copyright 2016, Texas Instruments Incorporated