EasyLink API reference¶
EasyLink RF API for CC13xx/CC26xx family.
Overview
The EasyLink API should be used in application code. The EasyLink API is intended to abstract the RF Driver in order to give a simple API for customers to use as is or extend to suit their application use cases.
General Behavior
Before using the EasyLink API:
- The EasyLink Layer is initialized by calling EasyLink_init(). This initialises and opens the RF driver and configuring a modulation scheme passed to EasyLink_init().
- The RX and TX can operate independently of each other.
The following is true for receive operation:
- RX is enabled by calling EasyLink_receive() or EasyLink_receiveAsync().
- Entering RX can be immediate or scheduled.
- EasyLink_receive() is blocking and EasyLink_receiveAsync() is nonblocking.
- the EasyLink API does not queue messages so calling another API function while in EasyLink_receiveAsync() will return EasyLink_Status_Busy_Error
- an Async operation can be cancelled with EasyLink_abort()
The following apply for transmit operation:
- TX is enabled by calling EasyLink_transmit() or EasyLink_transmitAsync().
- TX can be immediate or scheduled.
- EasyLink_transmit() is blocking and EasyLink_transmitAsync() is nonblocking
- EasyLink_transmit() for a scheduled command, or if TX can not start
- the EasyLink API does not queue messages so calling another API function while in EasyLink_transmitAsync() will return EasyLink_Status_Busy_Error
- an Async operation can be cancelled with EasyLink_abort()
Error handling
The EasyLink API will return EasyLink_Status containing success or error code. The EasyLink_Status code are:
- EasyLink_Status_Success
- EasyLink_Status_Config_Error
- EasyLink_Status_Param_Error
- EasyLink_Status_Mem_Error
- EasyLink_Status_Cmd_Error
- EasyLink_Status_Tx_Error
- EasyLink_Status_Rx_Error
- EasyLink_Status_Rx_Timeout
- EasyLink_Status_Busy_Error
- EasyLink_Status_Aborted
Power Management
The TI-RTOS power management framework will try to put the device into the most power efficient mode whenever possible. Please see the technical reference manual for further details on each power mode.
The EasyLink Layer uses the power management offered by the RF driver Refer to the RF drive documentation for more details.
Frame Structure
The EasyLink implements a basic header for transmitting and receiving data. This header supports addressing for a star or point-to-point network with acknowledgements.
Packet structure:
_________________________________________________________
| | | |
| 1B Length | 1-64b Dst Address | Payload |
|___________|___________________|_________________________|
Defines
-
EASYLINK_API_VERSION
¶ EasyLink API Version.
-
EASYLINK_MAX_DATA_LENGTH
¶ defines the largest Tx/Rx payload that the interface can support
-
EASYLINK_MAX_ADDR_SIZE
¶ defines the Tx/Rx Max Address Size
-
EASYLINK_MAX_ADDR_FILTERS
¶ defines the Max number of Rx Address filters
-
EASYLINK_MIN_CCA_BACKOFF_WINDOW
¶ Minimum CCA back-off window in units of EASYLINK_CCA_BACKOFF_TIMEUNITS, as a power of 2.
-
EASYLINK_MAX_CCA_BACKOFF_WINDOW
¶ Maximum CCA back-off window in units of EASYLINK_CCA_BACKOFF_TIMEUNITS, as a power of 2.
-
EASYLINK_CCA_BACKOFF_TIMEUNITS
¶ The back-off time units in microseconds.
-
EASYLINK_CS_RSSI_THRESHOLD_DBM
¶ RSSI threshold for Clear Channel Assesment (CCA)
-
EasyLink_RadioTime_To_ms
(radioTime)¶ macro to convert from Radio Time Ticks to ms
-
EasyLink_ms_To_RadioTime
(ms)¶ macro to convert from ms to Radio Time Ticks
-
EasyLink_us_To_RadioTime
(us)¶ macro to convert from us to Radio Time Ticks
Typedefs
-
typedef void
(* EasyLink_ReceiveCb)
(EasyLink_RxPacket *rxPacket, EasyLink_Status status)¶ EasyLink Callback function type for Received packet, registered with EasyLink_ReceiveAsync()
-
typedef void
(* EasyLink_TxDoneCb)
(EasyLink_Status status)¶ EasyLink Callback function type for Tx Done registered with EasyLink_TransmitAsync()
-
typedef uint32_t
(* EasyLink_GetRandomNumber)
(void)¶ EasyLink 32-bit Random number generator function type used in the clear channel assessment algorithm.
Enums
-
enum
EasyLink_Status
¶ EasyLink Status and error codes.
Values:
-
EasyLink_Status_Success
= 0¶ Success.
-
EasyLink_Status_Config_Error
= 1¶ Configuration error.
-
EasyLink_Status_Param_Error
= 2¶ Param error.
-
EasyLink_Status_Mem_Error
= 3¶ Memory Error.
-
EasyLink_Status_Cmd_Error
= 4¶ Memory Error.
-
EasyLink_Status_Tx_Error
= 5¶ Tx Error.
-
EasyLink_Status_Rx_Error
= 6¶ Rx Error.
-
EasyLink_Status_Rx_Timeout
= 7¶ Rx Error.
-
EasyLink_Status_Rx_Buffer_Error
= 8¶ Rx Buffer Error.
-
EasyLink_Status_Busy_Error
= 9¶ Busy Error.
-
EasyLink_Status_Aborted
= 10¶ Command stopped or aborted.
-
-
enum
EasyLink_PhyType
¶ Phy Type passed to EasyLink_init()
Values:
-
EasyLink_Phy_Custom
= 0¶ Customer Phy specific settings exported from SmartRF Studio.
-
EasyLink_Phy_50kbps2gfsk
= 1¶ Phy settings for Sub1G 50kbps data rate, IEEE 802.15.4g GFSK.
-
EasyLink_Phy_625bpsLrm
= 2¶ Phy settings for Sub1G 625bps data rate, Long Range Mode.
-
EasyLink_Phy_2_4_200kbps2gfsk
= 3¶ Phy settings for 2.4Ghz 200kbps data rate, IEEE 802.15.4g GFSK.
-
EasyLink_Phy_5kbpsSlLr
= 4¶ SimpleLink Long Range (5 kbps)
-
-
enum
EasyLink_CtrlOption
¶ Advance configuration options.
Values:
-
EasyLink_Ctrl_AddSize
= 0¶ Set the number of bytes in Addr for both Addr Filter and Tx/Rx operations
-
EasyLink_Ctrl_Idle_TimeOut
= 1¶ Set the time for Radio to return to idle after. Must be set before calling EasyLink_init().
-
EasyLink_Ctrl_MultiClient_Mode
= 2¶ Set Multiclient mode for application that will use multiple RF clients. Must be set before calling EasyLink_init().
-
EasyLink_Ctrl_AsyncRx_TimeOut
= 3¶ Relative time in ticks from Async Rx start to TimeOut. A value of 0 means no timeout
-
EasyLink_Ctrl_Test_Tone
= 4¶ Enable/Disable Test mode for Tone.
-
EasyLink_Ctrl_Test_Signal
= 5¶ Enable/Disable Test mode for Signal.
-
Functions
-
void
EasyLink_Params_init
(EasyLink_Params * params)¶ Function to initialize the EasyLink_Params struct to its defaults.
Default values are: ui32ModType = EasyLink_Phy_50kbps2gfsk RF_ClientCallback = NULL RF_ClientEventMask = NULL
- Parameters
params
: A pointer to EasyLink_Params structure for initialization
-
EasyLink_Status
EasyLink_init
(EasyLink_PhyType ui32ModType)¶ Initializes the radio with specified Phy settings.
This function configures the radio phy settings. If the ui32ModType is EasyLink_Phy_Custom then the configuration is taken from srf_settings.h. If a specific phy configuration is required (and not supported by any of the defined Phy types in EasyLink_PhyType then you can cut and past the RF setting from the SmartRF Studio code export tool. This will copy and use the RF_prop, RF_cmdPropRadioDivSetup and RF_cmdFs commands, as well as the Sync word from the RF_cmdPropTx and RF_cmdPropRx commands.
- Return
- EasyLink_Status
- Parameters
ui32ModType
: is a set to:
-
EasyLink_Status
EasyLink_init_multimode
(EasyLink_Params * params)¶ Initializes the radio with specified Phy settings and RF client events.
This function configures the radio phy settings. If the ui32ModType is EasyLink_Phy_Custom then the configuration is taken from srf_settings.h. If a specific phy configuration is required (and not supported by any of the defined Phy types in EasyLink_PhyType then you can cut and past the RF setting from the SmartRF Studio code export tool. This will copy and use the RF_prop, RF_cmdPropRadioDivSetup and RF_cmdFs commands, as well as the Sync word from the RF_cmdPropTx and RF_cmdPropRx commands. The function configures the callback for client events. The client events that trigger the callback are set using the nClientEventMask type in EasyLink_Params. A pointer to the desired callback should be provided to the pClientEventCb type of the EasyLink_Params structure.
- Return
- EasyLink_Status
- Parameters
params
: The descriptor for the Phy mode and event callback settings
-
uint32_t
EasyLink_getAbsTime
(void)¶ Gets the absolute radio time.
This function returns the absolute radio time and can be used for monitoring or Tx/Rx events using the EasyLink_TxPacket and EasyLink_RxPacket::absTime field.
- Return
- absolute time
-
EasyLink_Status
EasyLink_transmit
(EasyLink_TxPacket * txPacket)¶ Sends a Packet with blocking call.
This function is a blocking call to send a packet. If the Tx is successfully scheduled then the function will block until the Tx is complete.
- Return
- EasyLink_Status
- Parameters
txPacket
: The descriptor for the packet to be Tx’ed.
-
EasyLink_Status
EasyLink_transmitAsync
(EasyLink_TxPacket * txPacket, EasyLink_TxDoneCb cb)¶ Sends a Packet with non blocking call.
This function is a non blocking call to send a packet. If the Tx is successfully scheduled then the callback will be call once the Tx is complete.
- Return
- EasyLink_Status
- Parameters
txPacket
: The descriptor for the packet to be Tx’ed.cb
: The tx done function pointer.
-
EasyLink_Status
EasyLink_transmitCCAAsync
(EasyLink_TxPacket * txPacket, EasyLink_TxDoneCb cb, EasyLink_GetRandomNumber grn)¶ Sends a Packet with non blocking call if the channel is idle.
This function is a non blocking call to send a packet. It will check for a clear channel prior to transmission. If the channel is busy it will backoff for a random period, in time units of EASYLINK_CCA_BACKOFF_TIMEUNITS, before reassessing. It does this a certain number (EASYLINK_MAX_CCA_BACKOFF_WINDOW - EASYLINK_MIN_CCA_BACKOFF_WINDOW) of times before quitting unsuccessfully and running to the callback. If the Tx is successfully scheduled then the callback will be called once the Tx is complete.
- Return
- EasyLink_Status
- Parameters
txPacket
: The descriptor for the packet to be Tx’ed.cb
: The tx done function pointer.grn
: The random number generator function pointer
-
EasyLink_Status
EasyLink_receive
(EasyLink_RxPacket * rxPacket)¶ Blocking call that waits for an Rx Packet.
This function is a blocking call to wait for an Rx packet.
- Return
- EasyLink_Status
- Parameters
rxPacket
: The descriptor for the packet to be Rx’ed.
-
EasyLink_Status
EasyLink_receiveAsync
(EasyLink_ReceiveCb cb, uint32_t absTime)¶ Enables Asynchronous Packet Rx with non blocking call.
This function is a non blocking call to Rx a packet. The Rx is turned on and the Callback is called once a packet is received. The Rx will timeout if EasyLink_Ctrl_AsyncRx_TimeOut ctrl message is used to set the timeout to something other than 0.
- Return
- EasyLink_Status
- Parameters
cb
: The rx function pointer.absTime
: Start time of Rx (0: now !0: absolute radio time to start Rx)
-
EasyLink_Status
EasyLink_abort
(void)¶ Abort a previously call Async Tx/Rx.
This function is a blocking call to abort a previous Async Tx/Rx
- Return
- EasyLink_Status
-
EasyLink_Status
EasyLink_setFrequency
(uint32_t ui16Freq)¶ Sets the Frequency.
This function set the radio to the specified frequency. Note that this will be rounded to the nearest frequency supported by the Frequency Synthesizer.
- Return
- EasyLink_Status
- Parameters
ui16Freq
: Frequency in units of kHz
-
uint32_t
EasyLink_getFrequency
(void)¶ Gets the Frequency.
This function gets Frequency in units of kHz. This function will return the value set in the Frequency Synthesizer, and may not be the same as set using EasyLink_setFrequency(). Note that this value does not include any offsets for deviations due to factors such as temperature and hence this API should not be used to get an accurate measure of frequency.
- Return
- Frequency in units of kHz
-
EasyLink_Status
EasyLink_enableRxAddrFilter
(uint8_t * pui8AddrFilterTable, uint8_t ui8AddrSize, uint8_t ui8NumAddrs)¶ Enables the address filter.
This function enables the address filter to filter out address that are not in the address table provided.
- Return
- EasyLink_Status
- Parameters
pui8AddrFilterTable
: A uint8 pointer to a variable size 2d array containing the addresses to filter on.ui8AddrSize
: The size of the address elementsui8NumAddrs
: The number of address elements
-
EasyLink_Status
EasyLink_getIeeeAddr
(uint8_t * ieeeAddr)¶ Gets the IEEE address.
This function gets the IEEE address
- Return
- EasyLink_Status
- Parameters
ieeeAddr
: pointer to an 8 element byte array to write the IEEE address to.
-
EasyLink_Status
EasyLink_setRfPwr
(int8_t i8Power)¶ Sets the TX Power.
This function sets the Tx Power
- Return
- EasyLink_Status
- Parameters
i8Power
: the tx power in dBm’s to be set. integers of -10 and between 0-14 dBm are accepted. Values above 14 are rounded to 14 and below 0 are rounded to -10
-
int8_t
EasyLink_getRfPwr
(void)¶ Gets the TX Power.
This function gets the Tx Power in dBm, values ranging from -10 to 14 dBm should be expect
- Return
- power in dBm
-
EasyLink_Status
EasyLink_setCtrl
(EasyLink_CtrlOption Ctrl, uint32_t ui32Value)¶ Sets advanced configuration options.
This function allows setting some of the advanced configuration options
- Return
- EasyLink_Status
- Parameters
Ctrl
: The control option to be setui32Value
: The value to set the control option to
-
EasyLink_Status
EasyLink_getCtrl
(EasyLink_CtrlOption Ctrl, uint32_t * pui32Value)¶ Gets advanced configuration options.
This function allows getting some of the advanced configuration options
- Return
- EasyLink_Status
- Parameters
Ctrl
: The control option to getpui32Value
: Pointer to return the control option value
-
struct
EasyLink_Params
¶ - #include <EasyLink.h>
Structure for EasyLink_init_multimode() and EasyLink_Params_init()
Public Members
-
EasyLink_PhyType
ui32ModType
¶ PHY type.
-
RF_ClientCallback
pClientEventCb
¶ Client event callback function.
-
RF_ClientEventMask
nClientEventMask
¶ Client event mask.
-
EasyLink_PhyType
-
struct
EasyLink_TxPacket
¶ - #include <EasyLink.h>
Structure for the TX Packet.
-
struct
EasyLink_RxPacket
¶ - #include <EasyLink.h>
Structure for the RX’ed Packet.
Public Members
-
uint8_t EasyLink_RxPacket::dstAddr[8]
Dst Address of RX’ed packet.
-
int8_t
rssi
¶ rssi of RX’ed packet
-
uint32_t
absTime
¶ Absolute time to turn on Rx when passed (0 for immediate), Or Absolute time that packet was Rx when returned.
-
uint32_t
rxTimeout
¶ Relative time in ticks from Rx start to Rx TimeOut a value of 0 means no timeout
-
uint8_t
len
¶ length of RX’ed packet
-
uint8_t EasyLink_RxPacket::payload[EASYLINK_MAX_DATA_LENGTH]
payload of RX’ed packet
-