RF core driver for the CC13xx/CC26xx device family.
To use the RF driver, ensure that the correct driver library for your device is linked in and include this header file as follows:
The RF driver provides access to the radio core on the CC13xx/CC26xx device family. It offers a high-level interface for command execution and to the radio timer (RAT). The RF driver ensures the lowest possible power consumption by providing automatic power management that is fully transparent for the application.
This document describes the features and usage of the RF driver API. For a detailed explanation of the RF core, please refer to the Technical Reference Manual or the Proprietary RF user's guide. Key features are:
The RF driver can be configured at 4 different places:
The RF driver comes in two versions: single-client and multi-client. The single-client version allows only one driver instance to access the RF core at a time. The multi-client driver version allows concurrent access to the RF core with different RF settings. The multi-client driver has a slightly larger footprint and is not needed for many proprietary applications. The driver version can be selected in the build configuration by linking either against a RFCC26XX_singleMode or RFCC26XX_multiMode prebuilt library. When using the single-client driver, RF_SINGLEMODE
has to be defined globally in the build configuration. The multi-client driver is the default configuration in the SimpleLink SDKs.
The RF driver handles RF core hardware interrupts and uses software interrupts for its internal state machine. For managing the interrupt priorities, it expects the existance of a global RFCC26XX_HWAttrs object. This is usually defined in the board support file, for example CC1310_LAUNCHXL.c
, but when developing on custom boards, it might be kept anywhere in the application. By default, the priorities are set to the lowest possible value:
When initiating an RF driver instance, the function RF_open() accepts a pointer to a RF_Params object which might set several driver parameters. In addition, it expects an RF_Mode object and a setup command which is usually generated by SmartRF Studio:
The function RF_open() returns a driver handle that is used for accessing the correct driver instance. Please note that the first RF operation command before an RX or TX operation command must be a CMD_FS
to set the synthesizer frequency. The RF driver caches both, the pointer to the setup command and the physical CMD_FS
for automatic power management.
While a driver instance is opened, it can be re-configured with the function RF_control(). Various configuration parameters RF_CTRL are available. Example:
The RF core supports 3 different kinds of commands:
Direct and immediate commands are dispatched via RF_runDirectCmd() and RF_runImmediateCmd() respectively. These functions block until the command has completed and return a status code of the type RF_Stat when done.
Radio operation commands are potentially long-running commands and support different triggers as well as conditional execution. Only one command can be executed at a time, but the RF driver provides an internal queue that stores commands until the RF core is free. Two interfaces are provided for radio operation commands:
The asynchronous function RF_postCmd() posts a radio operation into the driver's internal command queue and returns a command handle of the type RF_CmdHandle which is an index in the command queue. The command is dispatched as soon as the RF core has completed any previous radio operation command.
Command execution happens in background. The calling task may proceed with other work or execute direct and immediate commands to interact with the posted radio operation. But beware that the posted command might not have started, yet. By calling the function RF_pendCmd() and subscribing events of the type RF_EventMask, it is possible to re-synchronize to a posted command:
The function RF_runCmd() is a combination of both, RF_postCmd() and RF_pendCmd() and allows synchronous execution.
A pending or already running command might be aborted at any time by calling the function RF_cancelCmd() or RF_flushCmd(). These functions take command handles as parameters, but can also just abort anything in the RF driver's queue:
When aborting a command, the return value of RF_runCmd() or RF_pendCmd() will contain the termination reason in form of event flags. If the command is in the RF driver queue, but has not yet start, the RF_EventCmdCancelled event is raised.
The RF core generates multiple interrupts during command execution. The RF driver maps these interrupts 1:1 to callback events of the type RF_EventMask. Hence, it is unnecessary to implement own interrupt handlers. Callback events are divided into 3 groups:
CMD_PROP_RX
.See also RF_Core_Events, RF_Driver_Events.
How callback events are subscribed was shown in the previous section. The following snippet shows a typical event handler callback for a proprietary RX operation:
In addition, the RF driver can generate error and power-up events that do not relate directly to the execution of a radio command. Such events can be subscribed by specifying the callback function pointers RF_Params::pErrCb and RF_Params::pPowerCb.
All callback functions run in software interrupt (SWI) context. Therefore, only a minimum amount of code should be executed. When using absolute timed commands with tight timing constraints, then it is recommended to set the RF driver SWIs to a high priority. See Setup and configuration for more details.
The RF core is a hardware peripheral and can be switched on and off. The RF driver handles that automatically and provides the following power optimization features:
The RF core optimizes the power consumption by enabling the RF core as late as possible. For instance does RF_open() not power up the RF core immediately. Instead, it waits until the first radio operation command is dispatched by RF_postCmd() or RF_runCmd().
The function RF_open() takes a radio setup command as parameter and expects a CMD_FS
command to follow. The pointer to the radio setup command and the whole CMD_FS
command are cached internally in the RF driver. They will be used for every proceeding power-up procedure. Whenever the client re-runs a setup command or a CMD_FS
command, the driver updates its internal cache with the new settings.
By default, the RF driver measures the time that it needs for the power-up procedure and uses that as an estimate for the next power cycle. On the CC13x0/CC26x0 devices, power-up takes usually 1.6 ms. Automatic measurement can be suppressed by specifying a custom power-up time with RF_Params::nPowerUpDuration. In addition, the client might set RF_Params::nPowerUpDurationMargin to cover any uncertainity when doing automatic measurements. This is necessary in applications with a high hardware interrupt load which can delay the RF driver's internal state machine execution.
Whenever a radio operation completes and there is no other radio operation in the queue, the RF core might be powered down. There are two options in the RF driver:
During the power-down procedure the RF driver stops the radio timer and saves a synchronization timestamp for the next power-up. This keeps the radio timer virtually in sync with the RTC even though it is not running all the time. The synchronization is done in hardware.
When dispatching a radio operation command with an absolute start trigger that is ahead in the future, the RF driver defers the execution and powers the RF core down until the command is due. It does that only, when:
cmd.startTrigger.triggerType
is set to TRIG_ABSTIME
cmd.startTime
is at not more than 3/4 of a full RAT cycle. Otherwise the driver assumes that cmd.startTime
is in the past.cmd.startTime
is due. That includes:If one of the conditions are not fullfilled, the RF core is kept up and running and the command is dispatched immediately. This ensures, that the command will execute on-time and not miss the configured start trigger.
Schedule BLE and proprietary radio commands.
Get dual mode schedule map including timing and priority information for access requests and commands.
The RF driver simplifies often needed tasks and provides additional functions. For instance, it can read the RSSI while the RF core is in RX mode using the function :tidrivers_api:RF_getRssi
:
For defining absolute triggers in radio operation commands, one often needs to know the current time. This can be achieved with the function RF_getCurrentTime(). When the RF core is not up and running and the radio timer is disabled, this function can still return a previse value:
#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/dpl/ClockP.h>
#include <ti/drivers/dpl/SemaphoreP.h>
#include <ti/devices/DeviceFamily.h>
Go to the source code of this file.
Data Structures | |
struct | RF_Mode |
Specifies a RF core firmware configuration. More... | |
union | RF_RadioSetup |
A unified type for radio setup commands of different PHYs. More... | |
struct | RFCC26XX_HWAttrs |
RF Hardware attributes. More... | |
union | RF_InfoVal |
Stores output parameters for RF_getInfo(). More... | |
struct | RF_ScheduleMapElement |
RF schedule map entry structure. More... | |
struct | RF_ScheduleMap |
RF schedule map structure. More... | |
struct | RF_Params |
RF driver configuration parameters. More... | |
struct | RF_ScheduleCmdParams |
RF schedule command parameter struct RF schedule command parameters are used with the RF_scheduleCmd() call. More... | |
struct | RF_AccessParams |
RF request access parameter struct RF request access command parameters are used with the RF_requestAccess() call. More... | |
Macros | |
RF Core Events | |
Events originating on the RF core and caused during command execution. They are aliases for the corresponding interrupt flags. RF Core Events are command-specific and are explained in the Technical Reference Manual.
| |
#define | RF_EventCmdDone (1<<0) |
A radio operation command in a chain finished. More... | |
#define | RF_EventLastCmdDone (1<<1) |
A stand-alone radio operation command or the last radio operation command in a chain finished. More... | |
#define | RF_EventFGCmdDone (1<<2) |
A IEEE-mode radio operation command in a chain finished. More... | |
#define | RF_EventLastFGCmdDone (1<<3) |
A stand-alone IEEE-mode radio operation command or the last 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 (uint32_t)(1<<31) |
Internal error observed. More... | |
#define | RF_EventMdmSoft 0x0000002000000000 |
Synchronization word detected (MDMSOFT interrupt flag) More... | |
RF Driver Events | |
#define | RF_EventCmdCancelled 0x1000000000000000 |
Command cancelled before it was started. More... | |
#define | RF_EventCmdAborted 0x2000000000000000 |
Aprubt command termination caused by RF_cancelCmd() or RF_flushCmd(). More... | |
#define | RF_EventCmdStopped 0x4000000000000000 |
Graceful command termination caused by RF_cancelCmd() or RF_flushCmd(). More... | |
#define | RF_EventRatCh 0x0800000000000000 |
A user-programmable RAT channel triggered an event. More... | |
#define | RF_EventPowerUp 0x0400000000000000 |
RF power up event. More... | |
#define | RF_EventError 0x0200000000000000 |
Event flag used for error callback functions to indicate an error. See RF_Params::pErrCb. More... | |
#define | RF_EventCmdPreempted 0x0100000000000000 |
Command preempted by another command with higher priority. Applies only to multi-client applications. More... | |
#define | RF_EventRadioFree 0x0080000000000000 |
Radio available to use. More... | |
Control codes for driver configuration | |
Control codes are used in RF_control(). | |
#define | RF_CTRL_SET_INACTIVITY_TIMEOUT 0 |
Control code used by RF_control to set inactivity timeout. More... | |
#define | RF_CTRL_UPDATE_SETUP_CMD 1 |
Control code used by RF_control to update setup command. More... | |
#define | RF_CTRL_SET_POWERUP_DURATION_MARGIN 2 |
Control code used by RF_control to set powerup duration margin. More... | |
#define | RF_CTRL_SET_RAT_RTC_ERR_TOL_VAL 3 |
Control code used by RF_control to set max error tolerence for RAT/RTC. More... | |
#define | RF_CTRL_SET_POWER_MGMT 4 |
Control code used by RF_control to set power management. More... | |
#define | RF_CTRL_SET_HWI_PRIORITY 5 |
Control code used by RF_control to set the hardware interrupt priority level of the RF driver. More... | |
#define | RF_CTRL_SET_SWI_PRIORITY 6 |
Control code used by RF_control to set the software interrupt priority level of the RF driver. More... | |
Other defines | |
#define | RF_GET_RSSI_ERROR_VAL (-128) |
Error return value for 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_SCHEDULE_CMD_ERROR (-3) |
RF command schedule error. More... | |
#define | RF_ERROR_INVALID_RFMODE (-256) |
Invalid RF_Mode. Used in error callback. More... | |
#define | RF_ERROR_CMDFS_SYNTH_PROG (-257) |
Synthesizer error with CMD_FS. Used in error callback. If this error occurred in error callback, user needs to resend CMD_Fs to recover. See errata SWRA521. More... | |
#define | RF_NUM_SCHEDULE_MAP_ENTRIES 5 |
Number of schedule map entries. This is the sum of access request and scheduled command entries. More... | |
#define | RF_NUM_SCHEDULE_ACCESS_ENTRIES 2 |
Number of access request entries. More... | |
#define | RF_NUM_SCHEDULE_COMMAND_ENTRIES (RF_NUM_SCHEDULE_MAP_ENTRIES - RF_NUM_SCHEDULE_ACCESS_ENTRIES) |
Number of scheduled command entries. More... | |
#define | RF_SCH_CMD_EXECUTION_TIME_UNKNOWN 0 |
For unknown execution time for RF scheduler. More... | |
Typedefs | |
typedef rfc_radioOp_t | RF_Op |
Base type for all radio operation commands. More... | |
typedef uint64_t | RF_EventMask |
Data type for events during command execution. More... | |
typedef uint32_t | RF_ClientEventMask |
Event mask for combining RF_ClientEvent event flags in RF_Params::nClientEventMask. More... | |
typedef int16_t | RF_CmdHandle |
Command handle that is returned by RF_postCmd(). More... | |
typedef RF_Object * | RF_Handle |
A handle that is returned by to RF_open(). More... | |
typedef void(* | RF_Callback) (RF_Handle h, RF_CmdHandle ch, RF_EventMask e) |
Handles events related to RF command execution. More... | |
typedef void(* | RF_ClientCallback) (RF_Handle h, RF_ClientEvent event, void *arg) |
Handles events related to a driver instance. More... | |
Enumerations | |
enum | RF_Priority { RF_PriorityHighest = 2, RF_PriorityHigh = 1, RF_PriorityNormal = 0 } |
Scheduling priority of RF operation commands. More... | |
enum | RF_Stat { RF_StatBusyError, RF_StatRadioInactiveError, RF_StatCmdDoneError, RF_StatInvalidParamsError, RF_StatCmdEnded, RF_StatError = 0x80, RF_StatCmdDoneSuccess, RF_StatCmdSch, RF_StatSuccess } |
Status codes for various RF driver functions. More... | |
enum | RF_ClientEvent { RF_ClientEventPowerUpFinished = 0x00000001, RF_ClientEventRadioFree = 0x00000002, RF_ClientEventSwitchClientEntered = 0x00000004 } |
Client-related RF driver events. More... | |
enum | RF_InfoType { RF_GET_CURR_CMD, RF_GET_AVAIL_RAT_CH, RF_GET_RADIO_STATE, RF_GET_SCHEDULE_MAP } |
Selects the entry of interest in RF_getInfo(). More... | |
Functions | |
RF_Handle | RF_open (RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pOpSetup, RF_Params *params) |
Creates a a new client instance of the 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) |
Appends RF operation commands to the driver's command queue and returns a command handle. More... | |
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. More... | |
RF_EventMask | RF_pendCmd (RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent) |
Synchronizes the calling task to an RF operation command ch and returns accumulated event flags. More... | |
RF_EventMask | RF_runCmd (RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent) |
Runs synchronously an RF operation command or a chain of commands and returns the termination reason. More... | |
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. More... | |
RF_Stat | RF_cancelCmd (RF_Handle h, RF_CmdHandle ch, uint8_t mode) |
Abort/stop/cancel single command in command queue. 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. 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. Note radio needs to be on for RAT to operate. If radio is off, this API returns RF_ALLOC_ERROR. More... | |
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 operate. If radio is off, this API returns RF_ALLOC_ERROR. More... | |
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. More... | |
RF_Stat | RF_ratDisableChannel (RF_Handle h, int8_t ratChannelNum) |
Disable a RAT channel. More... | |
RF_Stat | RF_control (RF_Handle h, int8_t ctrl, void *args) |
Set RF control parameters. More... | |
RF_Stat | RF_requestAccess (RF_Handle h, RF_AccessParams *pParams) |
Request radio access. More... | |
#define RF_EventCmdDone (1<<0) |
A radio operation command in a chain finished.
#define RF_EventLastCmdDone (1<<1) |
A stand-alone radio operation command or the last radio operation command in a chain finished.
#define RF_EventFGCmdDone (1<<2) |
A IEEE-mode radio operation command in a chain finished.
#define RF_EventLastFGCmdDone (1<<3) |
A stand-alone IEEE-mode radio operation command or the last 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 (uint32_t)(1<<31) |
Internal error observed.
#define RF_EventMdmSoft 0x0000002000000000 |
Synchronization word detected (MDMSOFT interrupt flag)
#define RF_EventCmdCancelled 0x1000000000000000 |
Command cancelled before it was started.
#define RF_EventCmdAborted 0x2000000000000000 |
Aprubt command termination caused by RF_cancelCmd() or RF_flushCmd().
#define RF_EventCmdStopped 0x4000000000000000 |
Graceful command termination caused by RF_cancelCmd() or RF_flushCmd().
#define RF_EventRatCh 0x0800000000000000 |
A user-programmable RAT channel triggered an event.
#define RF_EventPowerUp 0x0400000000000000 |
RF power up event.
#define RF_EventError 0x0200000000000000 |
Event flag used for error callback functions to indicate an error. See RF_Params::pErrCb.
#define RF_EventCmdPreempted 0x0100000000000000 |
Command preempted by another command with higher priority. Applies only to multi-client applications.
#define RF_EventRadioFree 0x0080000000000000 |
Radio available to use.
#define RF_CTRL_SET_INACTIVITY_TIMEOUT 0 |
Control code used by RF_control to set inactivity timeout.
Setting this control allows RF to power down the radio upon completion of a radio command after a specified timeout period (in us) With this control code arg is a pointer to the timeout variable and returns RF_StatSuccess.
#define RF_CTRL_UPDATE_SETUP_CMD 1 |
Control code used by RF_control to update setup command.
Setting this control notifies RF that the setup command is to be updated, so that RF will take proper actions when executing the next setup command. Note the updated setup command will take effect in the next power up cycle when RF executes the setup command. Prior to updating the setup command, user should make sure all pending commands have completed.
#define RF_CTRL_SET_POWERUP_DURATION_MARGIN 2 |
Control code used by RF_control to set powerup duration margin.
Setting this control updates the powerup duration margin. Default is RF_DEFAULT_POWER_UP_MARGIN.
#define RF_CTRL_SET_RAT_RTC_ERR_TOL_VAL 3 |
Control code used by RF_control to set max error tolerence for RAT/RTC.
Setting this control updates the error tol for how frequently the CMD_RAT_SYNC_STOP is sent. Default is RF_DEFAULT_RAT_RTC_ERR_TOL_IN_US (5 us) Client is recommeneded to change this setting before sending any commands.
#define RF_CTRL_SET_POWER_MGMT 4 |
Control code used by RF_control to set power management.
Setting this control configures RF driver to enable or disable power management. By default power management is enabled. If disabled, once RF core wakes up, RF driver will not go to standby and will not power down RF core. To configure power management, use this control to pass a parameter value of 0 to disable power management, and pass a parameter value of 1 to re-enable power management. This control is valid for dual-mode code only. Setting this control when using single-mode code has no effect (power management always enabled).
#define RF_CTRL_SET_HWI_PRIORITY 5 |
Control code used by RF_control to set the hardware interrupt priority level of the RF driver.
This control code sets the hardware interrupt priority level that is used by the RF driver. Valid values are INT_PRI_LEVEL1 (highest) until INT_PRI_LEVEL7 (lowest). The default interrupt priority is set in the board support file. The default value is -1 which means "lowest possible priority".
When using the TI-RTOS kernel, INT_PRI_LEVEL0 is reserved for zero-latency interrupts and must not be used.
Execute this control code only while the RF core is powered down and the RF driver command queue is empty. This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver is active will result in RF_StatBusyError being returned.
Example:
#define RF_CTRL_SET_SWI_PRIORITY 6 |
Control code used by RF_control to set the software interrupt priority level of the RF driver.
This control code sets the software interrupt priority level that is used by the RF driver. Valid values are integers starting at 0 (lowest) until Swi_numPriorities - 1
(highest). The default interrupt priority is set in the board support file. The default value is 0 which means means "lowest possible priority".
Execute this control code only while the RF core is powered down and the RF driver command queue is empty. This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver is active will result in RF_StatBusyError being returned.
Example:
#define RF_GET_RSSI_ERROR_VAL (-128) |
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_SCHEDULE_CMD_ERROR (-3) |
RF command schedule error.
#define RF_ERROR_INVALID_RFMODE (-256) |
Invalid RF_Mode. Used in error callback.
#define RF_ERROR_CMDFS_SYNTH_PROG (-257) |
Synthesizer error with CMD_FS. Used in error callback. If this error occurred in error callback, user needs to resend CMD_Fs to recover. See errata SWRA521.
#define RF_NUM_SCHEDULE_MAP_ENTRIES 5 |
Number of schedule map entries. This is the sum of access request and scheduled command entries.
#define RF_NUM_SCHEDULE_ACCESS_ENTRIES 2 |
Number of access request entries.
#define RF_NUM_SCHEDULE_COMMAND_ENTRIES (RF_NUM_SCHEDULE_MAP_ENTRIES - RF_NUM_SCHEDULE_ACCESS_ENTRIES) |
Number of scheduled command entries.
#define RF_SCH_CMD_EXECUTION_TIME_UNKNOWN 0 |
For unknown execution time for RF scheduler.
typedef rfc_radioOp_t RF_Op |
Base type for all radio operation commands.
All radio operation commands share a common part. That includes the command id, a status field, chaining properties and a start trigger. Whenever an RF operation command is used with the RF driver, it needs to be casted to an RF_Op.
More information about RF operation commands can be found in the Proprietary RF User's Guide.
typedef uint64_t RF_EventMask |
Data type for events during command execution.
Possible event flags are listed in RF_Core_Events and RF_Driver_Events.
typedef uint32_t RF_ClientEventMask |
Event mask for combining RF_ClientEvent event flags in RF_Params::nClientEventMask.
typedef int16_t RF_CmdHandle |
Command handle that is returned by RF_postCmd().
A command handle is an integer number greater equals zero and identifies a command container in the RF driver's internal command queue. A client can dispatch a command with RF_postCmd() and use the command handle later on to make the RF driver interact with the command.
A negative value has either a special meaning or indicates an error.
A handle that is returned by to RF_open().
RF_Handle is used for further RF client interaction with the RF driver. An invalid handle has the value NULL.
typedef void(* RF_Callback) (RF_Handle h, RF_CmdHandle ch, RF_EventMask e) |
Handles events related to RF command execution.
RF command callbacks notify the application of any events happening during RF command execution. Events may either refer to RF core interrupts (RF_Core_Events) or may be generated by the RF driver (RF_Driver_Events).
RF command callbacks are set up as parameter to RF_postCmd() or RF_runCmd() and provide:
RF command callbacks are executed in Software Interrupt (SWI) context and must not perform any blocking operation. The priority is configurable via RFCC26XX_HWAttrs in the board file or RF_CTRL_SET_SWI_PRIORITY in RF_control().
The RF_Callback function type is also used for signalling power events and errors. These are set in RF_Params::pPowerCb and RF_Params::pErrCb respectively. In case of a power event, ch can be ignored and e has RF_EventPowerUp set. In case of an error callback, ch contains an error code instead of a command handle and e has the RF_EventError flag set.
typedef void(* RF_ClientCallback) (RF_Handle h, RF_ClientEvent event, void *arg) |
Handles events related to a driver instance.
The RF driver produces additional events that are not directly related to the execution of a certain command, but happen during general RF driver operations. This includes power-up events, client switching events and others.
A client callback provides the following arguments:
RF client callbacks are executed in Software Interrupt (SWI) context and must not perform any blocking operation. The priority is configurable via RFCC26XX_HWAttrs in the board file or RF_CTRL_SET_SWI_PRIORITY in RF_control().
enum RF_Priority |
Scheduling priority of RF operation commands.
When multiple RF driver instances are used at the same time, commands from different clients may overlap. If an RF operation with a higher priority than the currently running operation is scheduled by RF_scheduleCmd(), then the running operation is interrupted.
In single-client applications, RF_PriorityNormal should be used.
enum RF_Stat |
Status codes for various RF driver functions.
RF_Stat is reported as return value for RF driver functions which execute direct and immediate commands. Such commands are executed by RF_runDirectCmd() and RF_runImmediateCmd() in the first place, but also by some convenience functions like RF_cancelCmd(), RF_flushCmd(), RF_getInfo() and others.
enum RF_ClientEvent |
Client-related RF driver events.
Events originating in the RF driver but not directly related to a specific radio command, are called client events. Clients may subscribe to these events by specifying a callback function RF_Params::pClientEventCb. Events are activated by specifying a bitmask RF_Params::nClientEventMask. The callback is called separately for every event providing an optional argument.
enum RF_InfoType |
Selects the entry of interest in RF_getInfo().
RF_Handle RF_open | ( | RF_Object * | pObj, |
RF_Mode * | pRfMode, | ||
RF_RadioSetup * | pOpSetup, | ||
RF_Params * | params | ||
) |
Creates a a new client instance of the RF driver.
This function initializes an RF driver client instance using pObj as storage. It does not power up the RF core. Once the client starts the first RF opweration command later in the application, the RF core is powered up and set into a PHY mode specified by pRfMode. The chosen PHY is then configured by a radio setup command pOpSetup. Whenever the RF core is powered up, the RF driver re-executes the radio setup command pOpSetup. Additional driver behaviour may be set by an optional params.
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 PHY information |
pOpSetup | Pointer to the radio setup command used for this client. This is re-executed by the RF Driver on each power-up. |
params | Pointer to an RF_Params object with the desired driver configuration. A NULL pointer results in the default configuration being loaded. |
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 | ||
) |
Appends RF operation commands to the driver's command queue and returns a command handle.
The RF operation pOp may either represent a single operation or may be the first operation in a chain. If the command queue is empty, the pCmd is dispatched immediately. If there are other operations pending, then pCmd is processed after all other commands have been finished. The RF operation command must be compatible to the RF_Mode selected by RF_open(), e.g. proprietary commands can only be used when the RF core is configured for proprietary mode.
The returned command handle is an identifier that can be used to control command execution later on, for instance with RF_pendCmd() or RF_cancelCmd(). It is a 16 Bit signed integer value, incremented on every new command. If the RF driver runs out of command containers, RF_ALLOC_ERROR is returned.
The priority ePri is only relevant in multi-client applications where commands of distinct clients may interrupt each other. Only commands started by RF_scheduleCmd() can preempt running commands. RF_postCmd() or RF_runCmd() do never interrupt a running command. In single-client applications, ePri is ignored and should be set to RF_PriorityNormal.
A callback function pCb might be specified to get notified about events during command execution. Events are subscribed by the bit mask bmEvent. Valid event flags are specified in RF_Core_Events and RF_Driver_Events. If no callback is set, RF_pendCmd() can be used to synchronize the current task to command execution. For this it is necessary to subscribe all relevant events. The termination events RF_EventLastCmdDone, RF_EventCmdCancelled, RF_EventCmdAborted and RF_EventCmdStopped are always implicitly subscribed.
The following limitations apply to the execution of command chains:
h | Driver handle previously returned by RF_open() |
pOp | Pointer to the RF operation command. |
ePri | Priority of this RF command (used for arbitration in multi-client systems) |
pCb | Callback function called during command execution and upon completion. If RF_postCmd() fails, no callback is made. |
bmEvent | Bitmask of events that will trigger the callback or that can be pended on. |
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 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 |
pSchParams | Pointer to the schdule command parameter structure |
pCb | Callback function called upon command completion (and some other events). If RF_scheduleCmd() 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 | ||
) |
Synchronizes the calling task to an RF operation command ch and returns accumulated event flags.
After having dispatched an RF operation represented by ch with RF_postCmd(), the command is running in parallel on the RF core. Thus, it might be desirable to synchronize the calling task to the execution of the command. With RF_pendCmd(), the application can block until one of the events specified in bmEvent occurs or until the command finishes. The function consumes and returns all accumulated event flags that occured during execution if they have been previously subscribed by RF_postCmd(). Possible events are specified in RF_Core_Events and RF_Driver_Events. The termination events RF_EventLastCmdDone, RF_EventCmdCancelled, RF_EventCmdAborted and RF_EventCmdStopped are always implicitly subscribed and can not be masked.
RF_pendCmd() may be called multiple times for the same command.
If RF_pendCmd() is called for a command handle representing a finished command, then only the RF_EventLastCmdDone flag is returned, regardless of how the command finished.
If the command has also a callback set, the callback is executed before RF_pendCmd() returns.
Example:
h | Driver handle previously returned by RF_open() |
ch | Command handle previously returned by RF_postCmd(). |
bmEvent | Bitmask of events that make RF_pendCmd() return. Termination events are always implicitly subscribed. |
RF_EventMask RF_runCmd | ( | RF_Handle | h, |
RF_Op * | pOp, | ||
RF_Priority | ePri, | ||
RF_Callback | pCb, | ||
RF_EventMask | bmEvent | ||
) |
Runs synchronously an RF operation command or a chain of commands and returns the termination reason.
This function appends an RF operation command or a chain of commands to the RF driver's command queue and then waits for it to complete. A command is completed if one of the termination events RF_EventLastCmdDone, RF_EventCmdCancelled, RF_EventCmdAborted, RF_EventCmdStopped occured.
This function is a combination of RF_postCmd() and RF_pendCmd(). All options and limitations for RF_postCmd() apply here as well.
An application should always ensure that the command completed in the expected way and with an expected status code.
h | Driver handle previously returned by RF_open() |
pOp | Pointer to the RF operation command. |
ePri | Priority of this RF command (used for arbitration in multi-client systems) |
pCb | Callback function called during command execution and upon completion. If RF_runCmd() fails, no callback is made. |
bmEvent | Bitmask of events that will trigger the callback or that can be pended on. |
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(s) to be scheduled to the command queue and then waits for it to complete.
A command is completed if one of the RF_EventLastCmdDone, RF_EventCmdCancelled, RF_EventCmdAborted, RF_EventCmdStopped occured.
h | Handle previously returned by RF_open() |
pOp | Pointer to the RF_Op. Must normally be in persistent and writeable memory |
pSchParams | Pointer to the schdule command parameter structure |
pCb | Callback function called upon command completion (and some other events). If RF_runScheduleCmd() 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.
If RF_cancelCmd is called from a Swi context with same or higher priority than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed until the next power-up cycle.
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.
If RF_flushCmd is called from a Swi context with same or higher priority than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed until the next power-up cycle.
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. Note radio needs to be on for RAT to operate. If radio is off, this API returns RF_ALLOC_ERROR.
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. Note radio needs to be on for RAT to operate. If radio is off, this API returns RF_ALLOC_ERROR.
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. Note radio needs to be on for RAT to operate. If radio is off, this API returns RF_ALLOC_ERROR.
h | Handle previously returned by RF_open() |
config | Config field of RAT HW output command structure |
Disable a RAT channel.
h | Handle previously returned by RF_open() |
ratChannelNum | RAT channel number to be disabled |
Set RF control parameters.
h | Handle previously returned by RF_open() |
ctrl | Control codes |
args | Pointer to control arguments |
RF_Stat RF_requestAccess | ( | RF_Handle | h, |
RF_AccessParams * | pParams | ||
) |
Request radio access.
Scope:
h | Handle previously returned by RF_open() |
pParams | Pointer to RF_AccessRequest parameters |