TI-RTOS Drivers
tidrivers_cc13xx_cc26xx_2_16_01_13
|
RF driver for the CC26/13xx family.
============================================================================
The RF header file should be included in an application as follows:
The RF driver allows clients (applications or other drivers) to control the radio of the device. The radio interface can either be blocking or non-blocking. Furthermore, the RF driver manages the rf powerdomain and tries to power down when the radio is no longer needed. It also allows clients to setup callbacks for when radio operations are completed and as such allows for fully interrupt based radio software.
The RF driver sets power constraints during operation to keep the device out of standby. When the operation has finished, power constraints are released.
Generic API function | Description |
---|---|
RF_open() | Open client connection to RF driver |
RF_close() | Close client connection to RF driver |
RF_getCurrentTime() | Return current radio timer value |
RF_postCmd() | Post an RF operation (chain) to the command queue |
RF_pendCmd() | Wait for posted command to complete |
RF_runCmd() | Runs synchronously a (chain of) RF operation(s) |
RF_flushCmd() | Abort previously submitted command, clear queue |
RF_yield() | Signal that the radio will not be used for a while |
RF_cancelCmd() | Abort/stop/cancel single cmd in command queue |
RF_getRssi() | Get rssi value |
RF_runImmediateCmd() | Send any immediate command |
RF_runDirectCmd() | Send any direct command |
RF_getInfo() | Get value for some RF driver parameters |
RF_ratCapture() | Run RAT capture command |
RF_ratCompare() | Run RAT compare command |
RF_ratHwOutput() | Run RAT HW Output command |
RF_ratDisableChannel() | Disable RAT channel |
#include <stdint.h>
#include <stdbool.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <driverlib/rf_common_cmd.h>
#include <driverlib/rf_prop_cmd.h>
Go to the source code of this file.
Data Structures | |
struct | RF_Mode |
Struct defining operating mode of RF driver. More... | |
union | RF_RadioSetup |
Union of the different flavors of RADIO_SETUP commands. More... | |
struct | RF_Params |
RF parameter struct RF parameters are used with the RF_open() and RF_Params_init() call. More... | |
struct | RFCC26XX_HWAttrs |
RF Hardware attributes. More... | |
struct | RF_Object |
Struct used to store RF client state and configuration Pointer to an RF_Object is used as handles (RF_Handle) in interactions with the RF driver. More... | |
union | RF_InfoVal |
RF_getParamsVal used to input and return RF driver paramters with RF_getParams() More... | |
Macros | |
#define | RF_GET_RSSI_ERROR_VAL (-128) |
default error values or RF_getRssi() More... | |
#define | RF_CMDHANDLE_FLUSH_ALL (-1) |
RF command handle to flush all RF commands. More... | |
#define | RF_ALLOC_ERROR (-2) |
RF command or RAT channel allocation error. More... | |
#define | RF_EventCmdDone (1<<0) |
RF Events reported to callback functions or from RF_runCmd(), RF_pendCmd() More... | |
#define | RF_EventLastCmdDone (1<<1) |
Last radio operation command in a chain finished. More... | |
#define | RF_EventTxDone (1<<4) |
Packet transmitted. More... | |
#define | RF_EventTXAck (1<<5) |
ACK packet transmitted. More... | |
#define | RF_EventTxCtrl (1<<6) |
Control packet transmitted. More... | |
#define | RF_EventTxCtrlAck (1<<7) |
Acknowledgement received on a transmitted control packet. More... | |
#define | RF_EventTxCtrlAckAck (1<<8) |
Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet. More... | |
#define | RF_EventTxRetrans (1<<9) |
Packet retransmitted. More... | |
#define | RF_EventTxEntryDone (1<<10) |
Tx queue data entry state changed to Finished. More... | |
#define | RF_EventTxBufferChange (1<<11) |
A buffer change is complete. More... | |
#define | RF_EventRxOk (1<<16) |
Packet received with CRC OK, payload, and not to be ignored. More... | |
#define | RF_EventRxNOk (1<<17) |
Packet received with CRC error. More... | |
#define | RF_EventRxIgnored (1<<18) |
Packet received with CRC OK, but to be ignored. More... | |
#define | RF_EventRxEmpty (1<<19) |
Packet received with CRC OK, not to be ignored, no payload. More... | |
#define | RF_EventRxCtrl (1<<20) |
Control packet received with CRC OK, not to be ignored. More... | |
#define | RF_EventRxCtrlAck (1<<21) |
Control packet received with CRC OK, not to be ignored, then ACK sent. More... | |
#define | RF_EventRxBufFull (1<<22) |
Packet received that did not fit in the Rx queue. More... | |
#define | RF_EventRxEntryDone (1<<23) |
Rx queue data entry changing state to Finished. More... | |
#define | RF_EventDataWritten (1<<24) |
Data written to partial read Rx buffer. More... | |
#define | RF_EventNDataWritten (1<<25) |
Specified number of bytes written to partial read Rx buffer. More... | |
#define | RF_EventRxAborted (1<<26) |
Packet reception stopped before packet was done. More... | |
#define | RF_EventRxCollisionDetected (1<<27) |
A collision was indicated during packet reception. More... | |
#define | RF_EventModulesUnlocked (1<<29) |
As part of the boot process, the CM0 has opened access to RF core modules and memories. More... | |
#define | RF_EventInternalError (1<<31) |
Internal error observed. More... | |
#define | RF_EventMdmSoft 0x0000002000000000 |
Modem Sync detected (MDMSOFT IFG) More... | |
#define | RF_EventCmdCancelled 0x1000000000000000 |
RF Events generated by RF Driver. Should not be used as input to RF_postCmd() More... | |
#define | RF_EventCmdAborted 0x2000000000000000 |
Command aborted : RF driver event. More... | |
#define | RF_EventCmdStopped 0x4000000000000000 |
Command stopped : RF driver event. More... | |
#define | RF_EventCmdError 0x8000000000000000 |
Command error : RF driver event. More... | |
#define | RF_EventRatCh 0x0800000000000000 |
RAT Channel interrupt : RF driver event. More... | |
Typedefs | |
typedef rfc_radioOp_t | RF_Op |
Alias for the data type of the header common to all radio operations. More... | |
typedef uint64_t | RF_EventMask |
Event mask type (construct mask with combinations of RF_EventMask) More... | |
typedef 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. More... | |
typedef struct RFCC26XX_HWAttrs | RFCC26XX_HWAttrs |
RF Hardware attributes. More... | |
typedef RF_Object * | RF_Handle |
A handle that is returned from a RF_open() call Used for further RF client interaction with the RF driver. More... | |
typedef 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 (chain). The callback is called from SWI context and provides the relevant RF_Handle, pointer to the relevant radio operation as well as an RF_EventMask that indicates what has occurred. More... | |
Enumerations | |
enum | RF_Priority { RF_PriorityHighest = 3, RF_PriorityHigh = 2, RF_PriorityNormal = 1, RF_PriorityLow = 0 } |
Priority of RF commands. More... | |
enum | RF_Stat { RF_StatBusyError, RF_StatRadioInactiveError, RF_StatCmdDoneError, RF_StatInvalidParamsError, RF_StatError = 0x80, RF_StatCmdDoneSuccess, RF_StatCmdSch, RF_StatSuccess } |
RF Stat reported as return value for RF_ratCmd(), RF_getRssi(). RF_setTxPwr(), RF_cancelCmd() More... | |
enum | RF_InfoType { RF_GET_CURR_CMD, RF_GET_AVAIL_RAT_CH, RF_GET_RADIO_STATE } |
RF_getParamsType contains the options available for using the RF_getParams() More... | |
Functions | |
RF_Handle | RF_open (RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params) |
Open client connection to RF driver. More... | |
void | RF_close (RF_Handle h) |
Close client connection to RF driver. More... | |
uint32_t | RF_getCurrentTime (void) |
Return current radio timer value. More... | |
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 with handle h. The command can be the first in a chain of RF operations or a standalone RF operation. If a chain of operations are posted they are treated atomically, i.e. either all or none of the chained operations are run. All operations must be posted in strictly increasing chronological order. Function returns immediately. More... | |
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 client identified by handle h to complete. Some RF operations (or chains of operations) post additional events during execution which, if enabled in event mask bmEvent, will make RF_pendCmd() return early. In this case, multiple calls to RF_pendCmd() for a single command can be made. If RF_pendCmd() is called for a command that registered a callback function it will take precedence and the callback function will never be called. More... | |
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 command queue and then waits for it to complete. More... | |
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 callback for the aborted/stopped command. If command has not yet run, cancels it it and posts callback for the cancelled command. If command has already run or been aborted/stopped/cancelled, has no effect. More... | |
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, aborts/stops it and then cancels all later commands in queue. If command has not yet run, cancels it and all later commands in queue. If command has already run or been aborted/stopped/cancelled, has no effect. More... | |
RF_Stat | RF_runImmediateCmd (RF_Handle h, uint32_t *pCmdStruct) |
Send any Immediate command. More... | |
RF_Stat | RF_runDirectCmd (RF_Handle h, uint32_t cmd) |
Send any Direct command. More... | |
void | RF_yield (RF_Handle h) |
Signal that radio client is not going to issue more commands in a while. More... | |
void | RF_Params_init (RF_Params *params) |
Function to initialize the RF_Params struct to its defaults. More... | |
RF_Stat | RF_getInfo (RF_Handle h, RF_InfoType type, RF_InfoVal *pValue) |
Get value for some RF driver parameters. More... | |
int8_t | RF_getRssi (RF_Handle h) |
Get rssi value. More... | |
RF_Op * | RF_getCmdOp (RF_Handle h, RF_CmdHandle cmdHnd) |
Get command structure pointer. More... | |
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. More... | |
int8_t | RF_ratCapture (RF_Handle h, uint16_t config, RF_Callback pRatCb) |
Setup RAT capture, and callback when capture event happens. More... | |
RF_Stat | RF_ratHwOutput (RF_Handle h, uint16_t config) |
Setup RAT HW output. More... | |
RF_Stat | RF_ratDisableChannel (RF_Handle h, int8_t ratChannelNum) |
Disable a RAT channel. More... | |
#define RF_GET_RSSI_ERROR_VAL (-128) |
default error values or RF_getRssi()
Error return value for RF_getRssi()
#define RF_CMDHANDLE_FLUSH_ALL (-1) |
RF command handle to flush all RF commands.
#define RF_ALLOC_ERROR (-2) |
RF command or RAT channel allocation error.
#define RF_EventCmdDone (1<<0) |
RF Events reported to callback functions or from RF_runCmd(), RF_pendCmd()
Radio operation command finished
#define RF_EventLastCmdDone (1<<1) |
Last radio operation command in a chain finished.
#define RF_EventTxDone (1<<4) |
Packet transmitted.
#define RF_EventTXAck (1<<5) |
ACK packet transmitted.
#define RF_EventTxCtrl (1<<6) |
Control packet transmitted.
#define RF_EventTxCtrlAck (1<<7) |
Acknowledgement received on a transmitted control packet.
#define RF_EventTxCtrlAckAck (1<<8) |
Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet.
#define RF_EventTxRetrans (1<<9) |
Packet retransmitted.
#define RF_EventTxEntryDone (1<<10) |
Tx queue data entry state changed to Finished.
#define RF_EventTxBufferChange (1<<11) |
A buffer change is complete.
#define RF_EventRxOk (1<<16) |
Packet received with CRC OK, payload, and not to be ignored.
#define RF_EventRxNOk (1<<17) |
Packet received with CRC error.
#define RF_EventRxIgnored (1<<18) |
Packet received with CRC OK, but to be ignored.
#define RF_EventRxEmpty (1<<19) |
Packet received with CRC OK, not to be ignored, no payload.
#define RF_EventRxCtrl (1<<20) |
Control packet received with CRC OK, not to be ignored.
#define RF_EventRxCtrlAck (1<<21) |
Control packet received with CRC OK, not to be ignored, then ACK sent.
#define RF_EventRxBufFull (1<<22) |
Packet received that did not fit in the Rx queue.
#define RF_EventRxEntryDone (1<<23) |
Rx queue data entry changing state to Finished.
#define RF_EventDataWritten (1<<24) |
Data written to partial read Rx buffer.
#define RF_EventNDataWritten (1<<25) |
Specified number of bytes written to partial read Rx buffer.
#define RF_EventRxAborted (1<<26) |
Packet reception stopped before packet was done.
#define RF_EventRxCollisionDetected (1<<27) |
A collision was indicated during packet reception.
#define RF_EventModulesUnlocked (1<<29) |
As part of the boot process, the CM0 has opened access to RF core modules and memories.
#define RF_EventInternalError (1<<31) |
Internal error observed.
#define RF_EventMdmSoft 0x0000002000000000 |
Modem Sync detected (MDMSOFT IFG)
#define RF_EventCmdCancelled 0x1000000000000000 |
RF Events generated by RF Driver. Should not be used as input to RF_postCmd()
Command cancelled : RF driver event
#define RF_EventCmdAborted 0x2000000000000000 |
Command aborted : RF driver event.
#define RF_EventCmdStopped 0x4000000000000000 |
Command stopped : RF driver event.
#define RF_EventCmdError 0x8000000000000000 |
Command error : RF driver event.
#define RF_EventRatCh 0x0800000000000000 |
RAT Channel interrupt : RF driver event.
typedef rfc_radioOp_t RF_Op |
Alias for the data type of the header common to all radio operations.
typedef uint64_t RF_EventMask |
Event mask type (construct mask with combinations of RF_EventMask)
typedef 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.
typedef struct RFCC26XX_HWAttrs RFCC26XX_HWAttrs |
RF Hardware attributes.
A handle that is returned from a RF_open() call Used for further RF client interaction with the RF driver.
typedef 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 (chain). The callback is called from SWI context and provides the relevant RF_Handle, pointer to the relevant radio operation as well as an RF_EventMask that indicates what has occurred.
enum RF_Priority |
enum RF_Stat |
RF Stat reported as return value for RF_ratCmd(), RF_getRssi(). RF_setTxPwr(), RF_cancelCmd()
enum RF_InfoType |
RF_Handle RF_open | ( | RF_Object * | pObj, |
RF_Mode * | pRfMode, | ||
RF_RadioSetup * | pOpSetup, | ||
RF_Params * | params | ||
) |
Open client connection to RF driver.
Allows a RF client (high-level driver or application) to request access to RF hardware.
pObj | Pointer to a RF_Object that will hold the state for this RF client. The object must be in persistent and writeable memory |
pRfMode | Pointer to a RF_Mode struct holding patch information |
pOpSetup | Pointer to the setup command used in this RF configuration. This is used by RF Driver during power-up so the user should allocated setup command in persistent memory. |
params | Pointer to an RF_Params object that is initialized with desired RF parameters. Can be set to NULL for defaults |
void RF_close | ( | RF_Handle | h | ) |
Close client connection to RF driver.
Allows a RF client (high-level driver or application) to close its connection to the RF driver.
h | Handle previously returned by RF_open() |
uint32_t RF_getCurrentTime | ( | void | ) |
Return current radio timer value.
If the radio is powered returns the current radio timer value, if not returns a conservative estimate of the current radio timer value
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 with handle h.
The command can be the first in a chain of RF operations or a standalone RF operation. If a chain of operations are posted they are treated atomically, i.e. either all or none of the chained operations are run.
All operations must be posted in strictly increasing chronological order. Function returns immediately.
Limitations apply to the operations posted:
h | Handle previously returned by RF_open() |
pOp | Pointer to the RF_Op. Must normally be in persistent and writeable memory |
ePri | Priority of this RF command (used for arbitration in multi-client systems) |
pCb | Callback function called upon command completion (and some other events). If RF_postCmd() fails no callback is made |
bmEvent | Bitmask of events that will trigger the callback. |
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 client identified by handle h to complete.
Some RF operations (or chains of operations) post additional events during execution which, if enabled in event mask bmEvent, will make RF_pendCmd() return early. In this case, multiple calls to RF_pendCmd() for a single command can be made.
If RF_pendCmd() is called for a command that registered a callback function it will take precedence and the callback function will never be called.
h | Handle previously returned by RF_open() |
ch | Command handle previously returned by RF_postCmd(). |
bmEvent | Bitmask of events that make RF_pendCmd() return. The command done event can not be masked away. |
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 command queue and then waits for it to complete.
h | Handle previously returned by RF_open() |
pOp | Pointer to the RF_Op. Must normally be in persistent and writeable memory |
ePri | Priority of this RF command (used for arbitration in multi-client systems) |
pCb | Callback function called upon command completion (and some other events). If RF_runCmd() fails no callback is made |
bmEvent | Bitmask of events that will trigger the callback. |
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 callback for the aborted/stopped command.
If command has not yet run, cancels it it and posts callback for the cancelled command.
If command has already run or been aborted/stopped/cancelled, has no effect.
h | Handle previously returned by RF_open() |
ch | Command handle previously returned by RF_postCmd(). |
mode | 1: Stop gracefully, 0: abort abruptly |
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, aborts/stops it and then cancels all later commands in queue.
If command has not yet run, cancels it and all later commands in queue.
If command has already run or been aborted/stopped/cancelled, has no effect.
The callbacks for all cancelled commands are issued in chronological order.
h | Handle previously returned by RF_open() |
ch | Command handle previously returned by RF_postCmd(). |
mode | 1: Stop gracefully, 0: abort abruptly |
Send any Immediate command.
Immediate Comamnd is send to RDBELL, if radio is active and the RF_Handle points to the current client.
In other appropriate RF_Stat values are returned.
h | Handle previously returned by RF_open() |
pCmdStruct | Pointer to the immediate command structure |
Send any Direct command.
Direct Comamnd value is send to RDBELL immediately, if radio is active and the RF_Handle point to the current client.
In other appropriate RF_Stat values are returned.
h | Handle previously returned by RF_open() |
cmd | Direct command value. |
void RF_yield | ( | RF_Handle | h | ) |
Signal that radio client is not going to issue more commands in a while.
Hint to RF driver that, irrespective of inactivity timeout, no new further commands will be issued for a while and thus the radio can be powered down at the earliest convenience.
h | Handle previously returned by RF_open() |
void RF_Params_init | ( | RF_Params * | params | ) |
RF_Stat RF_getInfo | ( | RF_Handle | h, |
RF_InfoType | type, | ||
RF_InfoVal * | pValue | ||
) |
Get value for some RF driver parameters.
h | Handle previously returned by RF_open() |
type | Request value paramter defined by RF_InfoType |
pValue | Pointer to return parameter values specified by RF_InfoVal |
int8_t RF_getRssi | ( | RF_Handle | h | ) |
Get rssi value.
h | Handle previously returned by RF_open() |
RF_Op* RF_getCmdOp | ( | RF_Handle | h, |
RF_CmdHandle | cmdHnd | ||
) |
Get command structure pointer.
h | Handle previously returned by RF_open() |
cmdHnd | Command handle returned by RF_postCmd() |
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.
h | Handle previously returned by RF_open() |
pCmdStruct | Pointer to the RAT compare command structure. |
compareTime | Compare time in RAT ticks |
pRatCb | Callback function when capture event happens |
int8_t RF_ratCapture | ( | RF_Handle | h, |
uint16_t | config, | ||
RF_Callback | pRatCb | ||
) |
Setup RAT capture, and callback when capture event happens.
h | Handle previously returned by RF_open() |
config | Config field of RAT capture command structure |
pRatCb | Callback function when capture event happens |
Setup RAT HW output.
h | Handle previously returned by RF_open() |
config | Config field of RAT HW output command structure |