Merge pull request #6701 from SiliconLabs/feature/update-rail

Update to EFR32 15.4 driver
pull/6715/merge
Martin Kojtal 2018-04-25 13:17:33 +01:00 committed by GitHub
commit 5ee2658dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 2214 additions and 1379 deletions

View File

@ -46,6 +46,13 @@
#define RF_QUEUE_SIZE 8
#endif
/* 802.15.4 maximum size of a single packet including PHY byte is 128 bytes */
#define MAC_PACKET_MAX_LENGTH 128
/* Offsets of prepended data in packet buffer */
#define MAC_PACKET_OFFSET_RSSI 0
#define MAC_PACKET_OFFSET_LQI 1
/* This driver prepends RSSI and LQI */
#define MAC_PACKET_INFO_LENGTH 2
/* RFThreadSignal used to signal from interrupts to the adaptor thread */
enum RFThreadSignal {
@ -68,12 +75,12 @@ enum RFThreadSignal {
/* Adaptor thread definitions */
static void rf_thread_loop(const void *arg);
static osThreadDef(rf_thread_loop, osPriorityRealtime, RF_THREAD_STACK_SIZE);
static osThreadId rf_thread_id;
static osThreadId rf_thread_id = 0;
/* Queue for passing messages from interrupt to adaptor thread */
static volatile void* rx_queue[8];
static volatile size_t rx_queue_head;
static volatile size_t rx_queue_tail;
static volatile uint8_t rx_queue[RF_QUEUE_SIZE][MAC_PACKET_MAX_LENGTH + MAC_PACKET_INFO_LENGTH];
static volatile size_t rx_queue_head = 0;
static volatile size_t rx_queue_tail = 0;
/* Silicon Labs headers */
extern "C" {
@ -123,7 +130,7 @@ static const RAIL_CsmaConfig_t csma_config = RAIL_CSMA_CONFIG_802_15_4_2003_2p4_
#error "Not a valid target."
#endif
#ifdef MBED_CONF_SL_RAIL_HAS_SUBGIG
#if MBED_CONF_SL_RAIL_HAS_SUBGIG
static RAIL_ChannelConfigEntryAttr_t entry_868;
static RAIL_ChannelConfigEntryAttr_t entry_915;
static const RAIL_ChannelConfigEntry_t entry[] = {
@ -151,7 +158,7 @@ static const RAIL_ChannelConfigEntry_t entry[] = {
#endif
#if MBED_CONF_SL_RAIL_BAND == 868
#ifndef MBED_CONF_SL_RAIL_HAS_SUBGIG
#if !MBED_CONF_SL_RAIL_HAS_SUBGIG
#error "Sub-Gigahertz band is not supported on this target."
#endif
static const RAIL_ChannelConfig_t channels = {
@ -161,7 +168,7 @@ static const RAIL_ChannelConfig_t channels = {
1
};
#elif MBED_CONF_SL_RAIL_BAND == 915
#ifndef MBED_CONF_SL_RAIL_HAS_SUBGIG
#if !MBED_CONF_SL_RAIL_HAS_SUBGIG
#error "Sub-Gigahertz band is not supported on this target."
#endif
static const RAIL_ChannelConfig_t channels = {
@ -187,7 +194,7 @@ static const RAIL_TxPowerConfig_t paInit2p4 = {
};
#endif
#if defined (MBED_CONF_SL_RAIL_HAS_SUBGIG)
#if MBED_CONF_SL_RAIL_HAS_SUBGIG
// Set up the PA for sub-GHz operation
static const RAIL_TxPowerConfig_t paInitSubGhz = {
.mode = RAIL_TX_POWER_MODE_SUBGIG,
@ -210,9 +217,9 @@ static const RAIL_StateTiming_t timings = {
static const RAIL_IEEE802154_Config_t config = {
.addresses = NULL,
.ackConfig = {
.enable = true,
.ackTimeout = 1200,
.rxTransitions = {
.enable = true,
.ackTimeout = 1200,
.rxTransitions = {
.success = RAIL_RF_STATE_RX,
.error = RAIL_RF_STATE_RX // ignored
},
@ -270,16 +277,13 @@ static void rf_thread_loop(const void *arg)
if (event.value.signals & SL_RX_DONE) {
while(rx_queue_tail != rx_queue_head) {
uint8_t* packet = (uint8_t*) rx_queue[rx_queue_tail];
SL_DEBUG_PRINT("rPKT %d\n", packet[2] - 2);
SL_DEBUG_PRINT("rPKT %d\n", packet[MAC_PACKET_INFO_LENGTH] - 2);
device_driver.phy_rx_cb(
&packet[3], /* Data payload for Nanostack starts at FCS */
packet[2] - 2, /* Payload length is part of frame, but need to subtract CRC bytes */
packet[1], /* LQI in second byte */
packet[0], /* RSSI in first byte */
&packet[MAC_PACKET_INFO_LENGTH + 1], /* Data payload for Nanostack starts at FCS */
packet[MAC_PACKET_INFO_LENGTH] - 2, /* Payload length is part of frame, but need to subtract CRC bytes */
packet[MAC_PACKET_OFFSET_LQI], /* LQI in second byte */
packet[MAC_PACKET_OFFSET_RSSI], /* RSSI in first byte */
rf_radio_driver_id);
free(packet);
rx_queue[rx_queue_tail] = NULL;
rx_queue_tail = (rx_queue_tail + 1) % RF_QUEUE_SIZE;
}
@ -887,6 +891,12 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
if (railHandle != gRailHandle)
return;
#ifdef MBED_CONF_RTOS_PRESENT
if(rf_thread_id == 0) {
return;
}
#endif
size_t index = 0;
do {
if (events & 1ull) {
@ -956,43 +966,20 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
/* Only process the packet if it had a correct CRC */
if(rxPacketInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS) {
/* Get RSSI and LQI information about this packet */
RAIL_RxPacketDetails_t rxPacketDetails;
rxPacketDetails.timeReceived.timePosition = RAIL_PACKET_TIME_DEFAULT;
rxPacketDetails.timeReceived.totalPacketBytes = 0;
RAIL_GetRxPacketDetails(gRailHandle, rxHandle, &rxPacketDetails);
uint8_t header[4];
RAIL_PeekRxPacket(gRailHandle, rxHandle, header, 4, 0);
/* Allocate a contiguous buffer for this packet's payload */
uint8_t* packetBuffer = (uint8_t*) malloc(rxPacketInfo.packetBytes + 2);
if(packetBuffer == NULL) {
SL_DEBUG_PRINT("Out of memory\n");
break;
}
/* First two bytes are RSSI and LQI, respecitvely */
packetBuffer[0] = (uint8_t)rxPacketDetails.rssi;
packetBuffer[1] = (uint8_t)rxPacketDetails.lqi;
/* Copy packet payload from circular FIFO into contiguous memory */
memcpy(&packetBuffer[2], rxPacketInfo.firstPortionData, rxPacketInfo.firstPortionBytes);
if (rxPacketInfo.firstPortionBytes < rxPacketInfo.packetBytes) {
memcpy(&packetBuffer[2+rxPacketInfo.firstPortionBytes],
rxPacketInfo.lastPortionData,
rxPacketInfo.packetBytes - rxPacketInfo.firstPortionBytes);
}
/* Release RAIL resources early */
RAIL_ReleaseRxPacket(gRailHandle, rxHandle);
/* If this is an ACK, deal with it */
if( packetBuffer[2] == 5 &&
packetBuffer[2+3] == (current_tx_sequence) &&
/* If this is an ACK, deal with it early */
if( (header[0] == 5) &&
(header[3] == current_tx_sequence) &&
waiting_for_ack) {
/* Tell the radio to not ACK an ACK */
RAIL_CancelAutoAck(gRailHandle);
waiting_for_ack = false;
/* Save the pending bit */
last_ack_pending_bit = (packetBuffer[2+1] & (1 << 4)) != 0;
last_ack_pending_bit = (header[1] & (1 << 4)) != 0;
/* Release packet */
RAIL_ReleaseRxPacket(gRailHandle, rxHandle);
/* Tell the stack we got an ACK */
#ifdef MBED_CONF_RTOS_PRESENT
osSignalSet(rf_thread_id, SL_ACK_RECV | (last_ack_pending_bit ? SL_ACK_PEND : 0));
@ -1004,8 +991,37 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1,
1);
#endif
free(packetBuffer);
} else {
/* Get RSSI and LQI information about this packet */
RAIL_RxPacketDetails_t rxPacketDetails;
rxPacketDetails.timeReceived.timePosition = RAIL_PACKET_TIME_DEFAULT;
rxPacketDetails.timeReceived.totalPacketBytes = 0;
RAIL_GetRxPacketDetails(gRailHandle, rxHandle, &rxPacketDetails);
#ifdef MBED_CONF_RTOS_PRESENT
/* Drop this packet if we're out of space */
if (((rx_queue_head + 1) % RF_QUEUE_SIZE) == rx_queue_tail) {
osSignalSet(rf_thread_id, SL_QUEUE_FULL);
RAIL_ReleaseRxPacket(gRailHandle, rxHandle);
break;
}
/* Copy into queue */
uint8_t* packetBuffer = (uint8_t*)rx_queue[rx_queue_head];
#else
/* Packet going temporarily onto stack for bare-metal apps */
uint8_t packetBuffer[MAC_PACKET_MAX_LENGTH + MAC_PACKET_INFO_LENGTH];
#endif
/* First two bytes are RSSI and LQI, respecitvely */
packetBuffer[MAC_PACKET_OFFSET_RSSI] = (uint8_t)rxPacketDetails.rssi;
packetBuffer[MAC_PACKET_OFFSET_LQI] = (uint8_t)rxPacketDetails.lqi;
/* Copy packet payload from circular FIFO into contiguous memory */
RAIL_CopyRxPacket(&packetBuffer[MAC_PACKET_INFO_LENGTH], &rxPacketInfo);
/* Release RAIL resources early */
RAIL_ReleaseRxPacket(gRailHandle, rxHandle);
/* Figure out whether we want to not ACK this packet */
/*
@ -1015,27 +1031,20 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
* [1] => b[0:2] frame type, b[3] = security enabled, b[4] = frame pending, b[5] = ACKreq, b[6] = intrapan
* [2] => b[2:3] destmode, b[4:5] version, b[6:7] srcmode
*/
if( (packetBuffer[2+1] & (1 << 5)) == 0 ) {
if( (packetBuffer[MAC_PACKET_INFO_LENGTH + 1] & (1 << 5)) == 0 ) {
/* Cancel the ACK if the sender did not request one */
RAIL_CancelAutoAck(gRailHandle);
}
#ifdef MBED_CONF_RTOS_PRESENT
if (((rx_queue_head + 1) % RF_QUEUE_SIZE) != rx_queue_tail) {
rx_queue[rx_queue_head] = (void*)packetBuffer;
rx_queue_head = (rx_queue_head + 1) % RF_QUEUE_SIZE;
osSignalSet(rf_thread_id, SL_RX_DONE);
} else {
free(packetBuffer);
osSignalSet(rf_thread_id, SL_QUEUE_FULL);
}
rx_queue_head = (rx_queue_head + 1) % RF_QUEUE_SIZE;
osSignalSet(rf_thread_id, SL_RX_DONE);
#else
SL_DEBUG_PRINT("rPKT %d\n", rxPacket[2] - 2);
device_driver.phy_rx_cb(&rxPacket[3], /* Data payload for Nanostack starts at FCS */
rxPacket[2] - 2, /* Payload length is part of frame, but need to subtract CRC bytes */
rxPacket[1], /* LQI in second byte */
rxPacket[0], /* RSSI in first byte */
SL_DEBUG_PRINT("rPKT %d\n", packetBuffer[MAC_PACKET_INFO_LENGTH] - 2);
device_driver.phy_rx_cb(&packetBuffer[MAC_PACKET_INFO_LENGTH + 1], /* Data payload for Nanostack starts at FCS */
packetBuffer[MAC_PACKET_INFO_LENGTH] - 2, /* Payload length is part of frame, but need to subtract CRC bytes */
packetBuffer[MAC_PACKET_OFFSET_LQI], /* LQI in second byte */
packetBuffer[MAC_PACKET_OFFSET_RSSI], /* RSSI in first byte */
rf_radio_driver_id);
free(packetBuffer);
#endif
}
}
@ -1265,4 +1274,4 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
index += 1;
}
while (events != 0);
}
}

View File

@ -1,7 +1,7 @@
/***************************************************************************//**
* @file rail_ble.h
* @brief The BLE specific header file for the RAIL library.
* @copyright Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
* @copyright Copyright 2016 Silicon Laboratories, Inc. www.silabs.com
******************************************************************************/
#ifndef __RAIL_BLE_H__
@ -14,48 +14,65 @@
// Get the RAIL specific structures and types
#include "rail_types.h"
/**
* @addtogroup BLE
* @ingroup Protocol_Specific
* Accelerator routines for Bluetooth Low Energy (BLE).
*
* The APIs in this module help take care of configuring the radio for BLE
* operation and provide some additional helper routines necessary for
* normal BLE send/receive that aren't available directly in RAIL. To initialize
* the radio you will still have to call RAIL_Init(). However
* RAIL_ConfigChannels(), and RAIL_ConfigRadio() will be taken care of for you.
*
* To implement a standard BLE link layer you will also need to handle tight
* turnaround times and send packets at specific instants. This can all be
* managed through general RAIL functions like RAIL_ScheduleTx(),
* RAIL_ScheduleRx(), and RAIL_SetStateTiming(). See the full RAIL API for more
* useful functions.
*
* A simple example of how to setup your application to be in BLE mode is shown
* below. Note that this will put the radio on the first advertising channel
* with the advertising Access Address. In any full featured BLE application you
* will need to use the RAIL_BLE_ConfigChannelRadioParams() function to change
* the sync word and other parameters as needed based on your connection.
*
* @code{.c}
*
* // Put the radio into receive on the first BLE advertising channel
* int bleAdvertiseEnable(void)
* {
* // Call the BLE initialization function to load the right radio config
* RAIL_BLE_Init();
*
* // Configure us for the first advertising channel (Physical: 0, Logical: 37)
* // The CRC init value and Access Address come from the BLE specification.
* RAIL_BLE_ConfigChannelRadioParams(0x555555, 0x8E89BED6, 37, false);
*
* // Start receiving on this channel (Physical: 0, Logical: 37)
* RAIL_StartRx(0);
* }
* @endcode
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/// @addtogroup BLE
/// @ingroup Protocol_Specific
/// Accelerator routines for Bluetooth Low Energy (BLE).
///
/// The APIs in this module help take care of configuring the radio for BLE
/// operation and provide some additional helper routines necessary for
/// normal BLE send/receive that aren't available directly in RAIL. All normal
/// RAIL APIs should be used to setup the application; however,
/// RAIL_ConfigChannels() and RAIL_ConfigRadio() should not be called to setup
/// the PHY. Instead, the RAIL_BLE_Config* APIs should be used to setup the
/// 1Mbps, 2Mbps, or Coded PHY configuration needed by the application. These
/// APIs will configure the hardware and also configure the set of valid BLE
/// channels.
///
/// To implement a standard BLE link layer you will also need to handle tight
/// turnaround times and send packets at specific instants. This can all be
/// managed through general RAIL functions like RAIL_ScheduleTx(),
/// RAIL_ScheduleRx(), and RAIL_SetStateTiming(). See the full RAIL API for more
/// useful functions.
///
/// A simple example of how to setup your application to be in BLE mode is shown
/// below. Note that this will put the radio on the first advertising channel
/// with the advertising Access Address. In any full featured BLE application you
/// will need to use the RAIL_BLE_ConfigChannelRadioParams() function to change
/// the sync word and other parameters as needed based on your connection.
///
/// @code{.c}
///
/// // RAIL Handle set at init time
/// static RAIL_Handle_t railHandle = NULL;
///
/// // Put the radio into receive on the first BLE advertising channel
/// int bleAdvertiseEnable(void)
/// {
/// // Call the BLE initialization function to load the right radio config
/// RAIL_BLE_Init(railHandle);
///
/// // Always choose the Viterbi PHY configuration if available on your chip
/// // for performance reasons.
/// RAIL_BLE_ConfigPhy1MbpsViterbi(railHandle);
///
/// // Configure us for the first advertising channel (Physical: 0, Logical: 37)
/// // The CRC init value and Access Address come from the BLE specification.
/// RAIL_BLE_ConfigChannelRadioParams(railHandle,
/// 0x555555,
/// 0x8E89BED6,
/// 37,
/// false);
///
/// // Start receiving on physical channel 0 (logical channel 37)
/// RAIL_StartRx(railHandle, 0, NULL);
/// }
/// @endcode
///
/// @{
/**
* @enum RAIL_BLE_Coding_t
@ -175,7 +192,7 @@ RAIL_Status_t RAIL_BLE_ConfigPhy2Mbps(RAIL_Handle_t railHandle);
* Switch to the BLE Coded PHY.
*
* @param[in] railHandle Handle for RAIL instance.
* @param[in] ble_coding The RAIL_BLE_Coding_t to use
* @param[in] bleCoding The RAIL_BLE_Coding_t to use
* @return Status code indicating success of the function call.
*
* You can use this function to switch back to BLE Coded PHY from the default
@ -188,7 +205,7 @@ RAIL_Status_t RAIL_BLE_ConfigPhy2Mbps(RAIL_Handle_t railHandle);
* manual to be sure that it does before trying this.
*/
RAIL_Status_t RAIL_BLE_ConfigPhyCoded(RAIL_Handle_t railHandle,
RAIL_BLE_Coding_t ble_coding);
RAIL_BLE_Coding_t bleCoding);
/**
* Helper function to change BLE radio parameters.
@ -215,4 +232,8 @@ RAIL_Status_t RAIL_BLE_ConfigChannelRadioParams(RAIL_Handle_t railHandle,
/** @} */ // end of BLE
#ifdef __cplusplus
}
#endif
#endif // __RAIL_BLE_H__

View File

@ -1,7 +1,7 @@
/***************************************************************************//**
* @file rail_ieee802154.h
* @brief The IEEE 802.15.4 specific header file for the RAIL library.
* @copyright Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
* @copyright Copyright 2016 Silicon Laboratories, Inc. www.silabs.com
******************************************************************************/
#ifndef __RAIL_IEEE802154_H__
@ -9,67 +9,142 @@
#include "rail_types.h"
/**
* @addtogroup IEEE802_15_4 IEEE 802.15.4
* @ingroup Protocol_Specific
* @brief IEEE 802.15.4 configuration routines
*
* The functions in this group configure RAIL IEEE 802.15.4 hardware
* acceleration. To configure 802.15.4 functionality, call
* RAIL_IEEE802154_Init(). Make note that this function calls many other RAIL
* functions; the application is advised to not reconfigure any of these
* functions. When using 802.15.4 functionality in the 2.4 GHz band, consider
* using RAIL_IEEE802154_Config2p4GHzRadio() instead of RAIL_ConfigRadio() and
* RAIL_ConfigChannels().
*
* @code{.c}
* RAIL_IEEE802154_Config_t config = { NULL, {100, 192, 894, RAIL_RF_STATE_RX},
* RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES,
* false, false };
* RAIL_IEEE802154_Config2p4GHzRadio();
* RAIL_IEEE802154_Init(&config);
* @endcode
*
* The application can configure the node's address by using
* RAIL_IEEE802154_SetAddresses(). Inidividual members can be changed with
* RAIL_IEEE802154_SetPanId(), RAIL_IEEE802154_SetShortAddress(),
* RAIL_IEEE802154_SetLongAddress(). RAIL only supports one set of addresses at
* a time. Beacon addresses are supported by default, without additional
* configuration.
*
* @code{.c}
* // PanID OTA value of 0x34 0x12
* // Short Address OTA byte order of 0x78 0x56
* // Long address with OTA byte order of 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
* RAIL_IEEE802154_AddrConfig_t nodeAddress = {
* { 0x1234, 0xFFFF },
* { 0x5678, 0xFFFF },
* { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 },
* { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
* };
*
* bool status = RAIL_IEEE802154_SetAddresses(&nodeAddress);
*
* // Alternative methods:
* status = RAIL_IEEE802154_SetPanId(nodeAddress.panId[0], 0);
* status = RAIL_IEEE802154_SetPanId(nodeAddress.panId[1], 1);
* status = RAIL_IEEE802154_SetShortAddress(nodeAddress.shortAddr[0], 0);
* status = RAIL_IEEE802154_SetShortAddress(nodeAddress.shortAddr[1], 1);
* status = RAIL_IEEE802154_SetLongAddress(nodeAddress.longAddr[0], 0);
* status = RAIL_IEEE802154_SetLongAddress(nodeAddress.longAddr[1], 1);
* @endcode
*
* Auto ack is initialized through RAIL_IEEE802154_Init(). It is not advised
* to call RAIL_ConfigAutoAck() while 802.15.4 hardware acceleration is
* enabled. The default IEEE 802.15.4 ack will have a 5 byte length. The frame
* type will be an ack. The frame pending bit will be set based on the
* RAIL_IEEE802154_SetFramePending() function. The sequence number will be set to
* match the packet being acknowledged. All other frame control fields will be
* set to 0, in compliance with IEEE Std 802.15.4-2011 section 5.2.2.3.
* However, the auto ack modification function can be used to control auto
* acking. Documentation for these functions can be found in \ref Auto_Ack.
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/// @addtogroup IEEE802_15_4 IEEE 802.15.4
/// @ingroup Protocol_Specific
/// @brief IEEE 802.15.4 configuration routines
///
/// The functions in this group configure RAIL IEEE 802.15.4 hardware
/// acceleration which includes IEEE 802.15.4 format filtering, address
/// filtering, acking, and filtering based on the frame type.
///
/// To configure IEEE 802.15.4 functionality, the application must first setup
/// a RAIL instance as normal with RAIL_Init() and other setup functions.
/// Instead of RAIL_ConfigChannels() and RAIL_ConfigRadio(), however, an
/// application may use RAIL_IEEE802154_Config2p4GHzRadio() to setup the
/// official IEEE 2.4GHz 802.15.4 PHY. This configuration is shown below.
///
/// @code{.c}
/// static RAIL_Handle_t railHandle = NULL; // Initialized somewhere else
///
/// static const RAIL_IEEE802154_Config_t rail154Config = {
/// .addresses = NULL,
/// .ackConfig = {
/// .enable = true, // Turn on auto ACK for IEEE 802.15.4
/// .ackTimeout = 864, // 54 symbols * 16 us/symbol = 864 us
/// .rxTransitions = {
/// .success = RAIL_RF_STATE_TX, // Go to Tx to send the ACK
/// .error = RAIL_RF_STATE_RX, // For an always on device stay in Rx
/// },
/// .txTransitions = {
/// .success = RAIL_RF_STATE_RX, // Go to Rx for receiving the ACK
/// .error = RAIL_RF_STATE_RX, // For an always on device stay in Rx
/// },
/// },
/// .timings = {
/// .idleToRx = 100,
/// .idleToTx = 100,
/// .rxToTx = 192, // 12 symbols * 16 us/symbol = 192 us
/// .txToRx = 192, // 12 symbols * 16 us/symbol = 192 us
/// .rxSearchTimeout = 0, // not used
/// .txToRxSearchTimeout = 0, // not used
/// },
/// .framesMask = RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES,
/// .promiscuousMode = false, // Enable format and address filtering
/// .isPanCoordinator = false,
/// };
///
/// void config154(void)
/// {
/// // Configure the radio and channels for 2.4GHz IEEE 802.15.4
/// RAIL_IEEE802154_Config2p4GHzRadio(railHandle);
/// // Initialize the IEEE 802.15.4 config using the static config above
/// RAIL_IEEE802154_Init(railHandle, &rail154Config);
/// }
/// @endcode
///
/// To configure address filtering the application can call
/// RAIL_IEEE802154_SetAddresses() with a structure containing all addresses or
/// can call the individual RAIL_IEEE802154_SetPanId(),
/// RAIL_IEEE802154_SetShortAddress(), and RAIL_IEEE802154_SetLongAddress()
/// APIs. RAIL supports \ref RAIL_IEEE802154_MAX_ADDRESSES number of address
/// pairs for situations where you want to receive packets from multiple IEEE
/// 802.15.4 networks at the same time. Broadcast addresses are supported by
/// default without any additional configuration so they do not consume one of
/// these slots. If the application does not require all address pairs be sure
/// to set unused ones to the proper disabled value for each type. These can
/// be found in the \ref RAIL_IEEE802154_AddrConfig_t documentation. Below is
/// an example of setting filtering for one set of addresses.
///
/// @code{.c}
/// // PanID OTA value of 0x34 0x12
/// // Short Address OTA byte order of 0x78 0x56
/// // Long address with OTA byte order of 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
///
/// // Setup all address simultaneously
/// RAIL_Status_t setup1(void)
/// {
/// RAIL_IEEE802154_AddrConfig_t nodeAddress = {
/// { 0x1234, 0xFFFF, 0xFFFF },
/// { 0x5678, 0xFFFF, 0xFFFF },
/// { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 },
/// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
/// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
/// };
/// return RAIL_IEEE802154_SetAddresses(railHandle, &nodeAddress);
/// }
///
/// // Alternatively the addresses can be setup individually as follows:
/// RAIL_Status_t setup2(void)
/// {
/// RAIL_Status_t status;
/// const uint8_t longAddress[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
///
/// status = RAIL_IEEE802154_SetPanId(railHandle, 0x1234, 0);
/// if (status != RAIL_STATUS_NO_ERROR) {
/// return status
/// }
/// status = RAIL_IEEE802154_SetShortAddress(railHandle, 0x5678, 0);
/// if (status != RAIL_STATUS_NO_ERROR) {
/// return status
/// }
/// status = RAIL_IEEE802154_SetLongAddress(railHandle, longAddress, 0);
/// if (status != RAIL_STATUS_NO_ERROR) {
/// return status
/// }
///
/// return RAIL_STATUS_NO_ERROR;
/// }
/// @endcode
///
/// Address filtering will be enabled except when in promiscuous mode which can
/// be set with RAIL_IEEE802154_SetPromiscuousMode(). The addresses may be
/// changed at runtime but if you are receiving a packet while reconfiguring the
/// address filters you may get undesired behavior so it's safest to do this
/// while not in receive.
///
/// Auto ACK is controlled by the ackConfig and timings fields passed to
/// RAIL_IEEE802154_Init(). After initialization though they may be controlled
/// using the normal \ref Auto_Ack and \ref State_Transitions APIs. When in IEEE
/// 802.15.4 mode the ACK will have a 5 byte length, the frame type will be set
/// to ack, and the frame pending bit will be set if
/// RAIL_IEEE802154_SetFramePending() is called when the \ref
/// RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND event is triggered. This event
/// must be turned on by the user and will fire whenever a data request is being
/// received so that the stack can determine whether there is pending data. Be
/// aware that the frame pending bit must be set quickly after receiving the
/// event or the ACK may already have been transmitted. Check the return code of
/// RAIL_IEEE802154_SetFramePending() to be sure that the bit was set in time.
///
/// Transmit and receive operations are all done using the standard RAIL APIs in
/// IEEE 802.15.4 mode. To send packets using the correct CSMA configuration
/// there is a \ref RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA define
/// that can initialize the csmaConfig structure passed to \ref
/// RAIL_StartCcaCsmaTx().
/// @{
/**
* @enum RAIL_IEEE802154_AddressLength_t
@ -176,7 +251,7 @@ typedef struct RAIL_IEEE802154_Config {
* Initialize RAIL for IEEE802.15.4 features
*
* @param[in] railHandle Handle of RAIL instance
* @param[in] config IEEE802154 configuration struct
* @param[in] fifteenFourConfig IEEE802154 configuration struct
* @return Status code indicating success of the function call.
*
* This function calls the following RAIL functions to configure the radio for
@ -196,7 +271,7 @@ typedef struct RAIL_IEEE802154_Config {
* - RAIL_EnableAddressFilter()
*/
RAIL_Status_t RAIL_IEEE802154_Init(RAIL_Handle_t railHandle,
const RAIL_IEEE802154_Config_t *config);
const RAIL_IEEE802154_Config_t *fifteenFourConfig);
/**
* Configures the radio for 2.4GHz 802.15.4 operation
@ -227,7 +302,7 @@ RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadio(RAIL_Handle_t railHandle);
RAIL_Status_t RAIL_IEEE802154_Deinit(RAIL_Handle_t railHandle);
/**
* Return whether IEEE802.15.4 hardware accelertion is currently enabled.
* Return whether IEEE802.15.4 hardware acceleration is currently enabled.
*
* @param[in] railHandle Handle of RAIL instance
* @return True if IEEE802.15.4 hardware acceleration was enabled to start with
@ -258,7 +333,7 @@ RAIL_Status_t RAIL_IEEE802154_SetAddresses(RAIL_Handle_t railHandle,
* @param[in] panId The 16-bit PAN ID information.
* This will be matched against the destination PAN ID of incoming messages.
* The PAN ID is sent little endian over the air meaning panId[7:0] is first in
* the payload followed by panId[15:8].
* the payload followed by panId[15:8]. Set to 0xFFFF to disable for this index.
* @param[in] index Which PAN ID to set. Must be below
* RAIL_IEEE802154_MAX_ADDRESSES.
* @return Status code indicating success of the function call.
@ -276,7 +351,7 @@ RAIL_Status_t RAIL_IEEE802154_SetPanId(RAIL_Handle_t railHandle,
* @param[in] shortAddr 16 bit short address value. This will be matched against the
* destination short address of incoming messages. The short address is sent
* little endian over the air meaning shortAddr[7:0] is first in the payload
* followed by shortAddr[15:8].
* followed by shortAddr[15:8]. Set to 0xFFFF to disable for this index.
* @param[in] index Which short address to set. Must be below
* RAIL_IEEE802154_MAX_ADDRESSES.
* @return Status code indicating success of the function call.
@ -294,7 +369,8 @@ RAIL_Status_t RAIL_IEEE802154_SetShortAddress(RAIL_Handle_t railHandle,
* @param[in] railHandle Handle of RAIL instance
* @param[in] longAddr Pointer to a 8 byte array containing the long address
* information. The long address must be in over the air byte order. This will
* be matched against the destination long address of incoming messages.
* be matched against the destination long address of incoming messages. Set to
* 0x00 00 00 00 00 00 00 00 to disable for this index.
* @param[in] index Which long address to set. Must be below
* RAIL_IEEE802154_MAX_ADDRESSES.
* @return Status code indicating success of the function call.
@ -316,7 +392,7 @@ RAIL_Status_t RAIL_IEEE802154_SetLongAddress(RAIL_Handle_t railHandle,
* If the device is a PAN Coordinator, then it will accept data and command
* frames with no destination address. This function will fail if 802.15.4
* hardware acceleration is not currently enabled. This setting may be changed
* at any time when 802.15.4 hardwarea acceleration is enabled.
* at any time when 802.15.4 hardware acceleration is enabled.
*/
RAIL_Status_t RAIL_IEEE802154_SetPanCoordinator(RAIL_Handle_t railHandle,
bool isPanCoordinator);
@ -404,4 +480,8 @@ RAIL_Status_t RAIL_IEEE802154_GetAddress(RAIL_Handle_t railHandle,
/** @} */ // end of IEEE802.15.4
#ifdef __cplusplus
}
#endif
#endif // __RAIL_IEEE802154_H__

View File

@ -3,7 +3,7 @@
* @brief RADIO PA API
*******************************************************************************
* @section License
* <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
* <b>(C) Copyright 2015 Silicon Labs, www.silabs.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
@ -81,13 +81,17 @@ extern "C" {
* @param[in] paConfig
* Pointer to a structure containing the desired PA configuration settings.
*
* @param[in] timings
* Pointer to a structure containing the current state transition timings.
*
* @return
* RAIL_Status_t indicating success
*
* @warning
* The radio should not be transmitting when this function is called!
*/
RAIL_Status_t PA_Config(const RAIL_TxPowerConfig_t *paConfig);
RAIL_Status_t PA_Config(const RAIL_TxPowerConfig_t *paConfig,
const StateTimings_t *timings);
/**
* @brief
@ -131,6 +135,9 @@ uint32_t PA_GetRampTime(void);
*
* @param[in] ramptime
* Desired ramp time in microseconds
* @param[in] timings
* Pointer to a structure containing the current state transition timings.
*
* @return
* The actual ramp time that was set in microseconds.
@ -138,7 +145,7 @@ uint32_t PA_GetRampTime(void);
* @warning
* The radio should not be transmitting when this function is called!
*/
uint32_t PA_SetRampTime(uint32_t ramptime, StateTimings_t *timings);
uint32_t PA_SetRampTime(uint32_t rampTime, const StateTimings_t *timings);
/**
* Enable/Disable PA calibration
@ -194,7 +201,7 @@ void PA_SetCTune(uint8_t txPaCtuneValue, uint8_t rxPaCtuneValue);
* @warning
* The radio should not be transmitting when this function is called!
*/
RAIL_TxPowerLevel_t PA_SetPowerLevel(RAIL_TxPowerLevel_t pwrLevel);
RAIL_TxPowerLevel_t PA_SetPowerLevel(RAIL_TxPowerLevel_t powerLevel);
/** @} (end addtogroup EFR32xG1x_PA_Advanced) */
/** @} (end addtogroup EFR32xG1x_PA) */

View File

@ -2,7 +2,7 @@
* @file pti.h
* @brief This header file contains information for working with the packet
* trace APIs.
* @copyright Copyright 2015 Silicon Laboratories, Inc. http://www.silabs.com
* @copyright Copyright 2015 Silicon Laboratories, Inc. www.silabs.com
******************************************************************************/
#ifndef __RADIO_PTI_H

View File

@ -1,11 +1,12 @@
/***************************************************************************//**
* @file rail_assert_error_codes.h
* @brief Definition of error codes that occur in rail for use in
RAILCb_AssertFailed. This file is purely informational and optional -
it need not be included even if rail_assert libraries are included.
* @copyright Copyright 2017 Silicon Laboratories, Inc. http://www.silabs.com
* RAILCb_AssertFailed. This file is purely informational and optional -
* it need not be included even if rail_assert libraries are included.
* @copyright Copyright 2017 Silicon Laboratories, Inc. www.silabs.com
******************************************************************************/
#ifndef __RAIL_ASSERT_ERROR_CODES_H__
#define __RAIL_ASSERT_ERROR_CODES_H__
#include "rail_types.h"
@ -14,132 +15,132 @@
* @{
*/
#ifndef _RAIL_ASSERT_ERROR_CODES_
#define _RAIL_ASSERT_ERROR_CODES_
/**
* Enumeration of all possible error codes from RAIL_ASSERT
*/
RAIL_ENUM(RAIL_AssertErrorCodes_t)
RAIL_ENUM_GENERIC(RAIL_AssertErrorCodes_t, uint32_t)
{
RAIL_ASSERT_FAILED_APPENDED_INFO_MISSING,
RAIL_ASSERT_FAILED_RX_FIFO_BYTES,
RAIL_ASSERT_FAILED_RX_FIFO_ZERO_BYTES_READ,
RAIL_ASSERT_FAILED_ILLEGAL_RXLEN_ENTRY_STATUS,
RAIL_ASSERT_FAILED_BAD_PACKET_LENGTH,
RAIL_ASSERT_FAILED_SYNTH_DIVCTRL_ENUM_CONVERSION_ERROR, //5
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_RX_FIFO,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_RXLEN_FIFO,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_TX_FIFO,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_TXACK_FIFO,
RAIL_ASSERT_FAILED_PBUFFER_NOT_DEFINED, //10
RAIL_ASSERT_FAILED_INSUFFICIENT_BYTES_IN_RX_PACKET,
RAIL_ASSERT_FAILED_CLOCK_PRESCALER,
RAIL_ASSERT_FAILED_RTCC_POST_WAKEUP,
RAIL_ASSERT_FAILED_SYNTH_VCO_FREQUENCY,
RAIL_ASSERT_FAILED_RAC_STATE, //15
RAIL_ASSERT_FAILED_RETIME_LIMIT,
RAIL_ASSERT_FAILED_NESTED_SEQUENCER_LOCK,
RAIL_ASSERT_FAILED_RSSI_AVERAGE_DONE,
RAIL_ASSERT_FAILED_DFL_BITS_SIZE,
RAIL_ASSERT_FAILED_PROTIMER_RANDOM_SEED, //20
RAIL_ASSERT_FAILED_EFR32XG1_REGISTER_SIZE,
RAIL_ASSERT_FAILED_PROTIMER_CHANNEL,
RAIL_ASSERT_FAILED_TIMER_REQUIRES_WRAP,
RAIL_ASSERT_FAILED_BASECNTTOP,
RAIL_ASSERT_FAILED_DEPRECATED_LBTRETRY, //25
RAIL_ASSERT_FAILED_RTCC_SYNC_MISSED,
RAIL_ASSERT_FAILED_CLOCK_SOURCE_NOT_READY,
RAIL_ASSERT_FAILED_TIMINGS_INVALID,
RAIL_ASSERT_NULL_HANDLE,
RAIL_ASSERT_FAILED_TMRDRV_SCHED_TIMER_NOT_RUNNING, //30
RAIL_ASSERT_FAILED_NO_ACTIVE_CONFIG,
RAIL_ASSERT_FAILED_NO_ACTIVE_HANDLE_SWITCH,
RAIL_ASSERT_FAILED_RFINIT,
RAIL_ASSERT_FAILED_NO_ACTIVE_HANDLE_SCHEDRX,
RAIL_ASSERT_FAILED_INVALID_HANDLE_SCHEDTX, //35
RAIL_ASSERT_FAILED_INACTIVE_HANDLE_SCHEDTX,
RAIL_ASSERT_FAILED_CONFIG_INDEX_INVALID,
RAIL_ASSERT_FAILED_NO_ACTIVE_HANDLE_SINGLEPROTOCOL,
RAIL_ASSERT_DEPRECATED_FUNCTION,
RAIL_ASSERT_MULTIPROTOCOL_NO_EVENT, //40
RAIL_ASSERT_FAILED_INVALID_INTERRUPT_ENABLED,
RAIL_ASSERT_CONVERSION_CURVES_NOT_INITIALIZED,
RAIL_ASSERT_FAILED_APPENDED_INFO_MISSING = 0,
RAIL_ASSERT_FAILED_RX_FIFO_BYTES = 1,
RAIL_ASSERT_FAILED_RX_FIFO_ZERO_BYTES_READ = 2,
RAIL_ASSERT_FAILED_ILLEGAL_RXLEN_ENTRY_STATUS = 3,
RAIL_ASSERT_FAILED_BAD_PACKET_LENGTH = 4,
RAIL_ASSERT_FAILED_SYNTH_DIVCTRL_ENUM_CONVERSION_ERROR = 5,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_RX_FIFO = 6,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_RXLEN_FIFO = 7,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_TX_FIFO = 8,
RAIL_ASSERT_FAILED_UNEXPECTED_STATE_TXACK_FIFO = 9,
RAIL_ASSERT_FAILED_PBUFFER_NOT_DEFINED = 10,
RAIL_ASSERT_FAILED_INSUFFICIENT_BYTES_IN_RX_PACKET = 11,
RAIL_ASSERT_FAILED_CLOCK_PRESCALER = 12,
RAIL_ASSERT_FAILED_RTCC_POST_WAKEUP = 13,
RAIL_ASSERT_FAILED_SYNTH_VCO_FREQUENCY = 14,
RAIL_ASSERT_FAILED_RAC_STATE = 15,
RAIL_ASSERT_FAILED_RETIME_LIMIT = 16,
RAIL_ASSERT_FAILED_NESTED_SEQUENCER_LOCK = 17,
RAIL_ASSERT_FAILED_RSSI_AVERAGE_DONE = 18,
RAIL_ASSERT_FAILED_DFL_BITS_SIZE = 19,
RAIL_ASSERT_FAILED_PROTIMER_RANDOM_SEED = 20,
RAIL_ASSERT_FAILED_EFR32XG1_REGISTER_SIZE = 21,
RAIL_ASSERT_FAILED_PROTIMER_CHANNEL = 22,
RAIL_ASSERT_FAILED_TIMER_REQUIRES_WRAP = 23,
RAIL_ASSERT_FAILED_BASECNTTOP = 24,
RAIL_ASSERT_FAILED_DEPRECATED_LBTRETRY = 25,
RAIL_ASSERT_FAILED_RTCC_SYNC_MISSED = 26,
RAIL_ASSERT_FAILED_CLOCK_SOURCE_NOT_READY = 27,
RAIL_ASSERT_FAILED_TIMINGS_INVALID = 28,
RAIL_ASSERT_NULL_HANDLE = 29,
RAIL_ASSERT_FAILED_SCHED_TIMER_NOT_RUNNING = 30,
RAIL_ASSERT_FAILED_NO_ACTIVE_CONFIG = 31,
RAIL_ASSERT_FAILED_NO_ACTIVE_HANDLE_SWITCH = 32,
RAIL_ASSERT_FAILED_RFINIT = 33,
RAIL_ASSERT_FAILED_NO_ACTIVE_HANDLE_SCHEDRX = 34,
RAIL_ASSERT_FAILED_INVALID_HANDLE_SCHEDTX = 35,
RAIL_ASSERT_FAILED_INACTIVE_HANDLE_SCHEDTX = 36,
RAIL_ASSERT_FAILED_CONFIG_INDEX_INVALID = 37,
RAIL_ASSERT_FAILED_NO_ACTIVE_HANDLE_SINGLEPROTOCOL = 38,
RAIL_ASSERT_DEPRECATED_FUNCTION = 39,
RAIL_ASSERT_MULTIPROTOCOL_NO_EVENT = 40,
RAIL_ASSERT_FAILED_INVALID_INTERRUPT_ENABLED = 41,
RAIL_ASSERT_CONVERSION_CURVES_NOT_INITIALIZED = 42,
RAIL_ASSERT_DIVISION_BY_ZERO = 43,
RAIL_ASSERT_CANT_USE_HARDWARE = 44,
};
/**
* Use this define to create an array of error messages that map to the codes
* in \ref RAIL_AssertErrorCodes_t. You can use these to print slightly more
* detailed error strings related to a particular assert error code if desired.
* For example, you could implement your assert failed callback as follows to
* make use of this.
*
* @code{.c}
* void RAILCb_AssertFailed(RAIL_Handle_t railHandle, uint32_t errorCode)
* {
* static const char* railErrorMessages[] = RAIL_ASSERT_ERROR_MESSAGES;
* const char *errorMessage = "Unknown";
*
* // If this error code is within the range of known error messages then use
* // the appropriate error message.
* if (errorCode < (sizeof(railErrorMessages) / sizeof(char*))) {
* errorMessage = railErrorMessages[errorCode];
* }
* printf(errorMessage);
*
* // Reset the chip since an assert is a fatal error
* NVIC_SystemReset();
* }
* @endcode
*/
#define RAIL_ASSERT_ERROR_MESSAGES { \
"Appended info missing from Rx packet", \
"Payload bytes missing from Rx packet", \
"Error reading back packet payload", \
"Receive fifo entry has invalid status", \
"Receive fifo entry bad packet length", \
"Unable to configure radio for IR calibration", \
"Reached unexpected state while handling Rx fifo events", \
"Reached unexpected state while handling RXLEN fifo events", \
"Reached unexpected state while handling Tx fifo events", \
"Reached unexpected state while handling Tx ACK fifo events", \
"No memory to store receive packet", \
"Packet length longer than the receive FIFO size", \
"Invalid radio clock prescaler", \
"Error synchronizing the RAIL timebase after sleep", \
"VCO frequency outside supported range", \
"Radio active while changing channels", \
"Unable to configure DCDC retiming", \
"Nested attempt to lock the sequencer", \
"RSSI averaging enabled without a valid callback", \
"Invalid dynamic frame length setting provided (dflBits)", \
"Unable to seed radio pseudo random number generator", \
"Timeout exceeds EFR32XG1 register size", \
"Invalid timer channel specified", \
"Timer value larger than RAIL timebase", \
"LBT config exceeds EFR32XG1 register size", \
"Deprecated CSMA/LBT retry callback unexpectedly called", \
"Could not synchronize RAIL timebase with the RTC", \
"Clock source not ready", \
"Attempted to set RAIL timings to invalid value", \
"NULL was supplied as a RAIL_Handle_t argument", \
"Scheduled timer not running", \
"No active config to switch from", \
"No active handle after switch", \
"RfInit failed to configure active state", \
"No active handle for scheduled rx", \
"Invalid handle for scheduled tx", \
"Inactive handle for scheduled tx", \
"Invalid config index to switch to", \
"No active handle for single protocol", \
"This function is deprecated and must not be called", \
"Multiprotocol task started with no event to run", \
"Invalid interrupt enabled", \
"Power conversion functions called before curves were initialized", \
/// Use this define to create an array of error messages that map to the codes
/// in \ref RAIL_AssertErrorCodes_t. You can use these to print slightly more
/// detailed error strings related to a particular assert error code if desired.
/// For example, you could implement your assert failed callback as follows to
/// make use of this.
///
/// @code{.c}
/// void RAILCb_AssertFailed(RAIL_Handle_t railHandle, uint32_t errorCode)
/// {
/// static const char* railErrorMessages[] = RAIL_ASSERT_ERROR_MESSAGES;
/// const char *errorMessage = "Unknown";
///
/// // If this error code is within the range of known error messages then use
/// // the appropriate error message.
/// if (errorCode < (sizeof(railErrorMessages) / sizeof(char*))) {
/// errorMessage = railErrorMessages[errorCode];
/// }
/// printf(errorMessage);
///
/// // Reset the chip since an assert is a fatal error
/// NVIC_SystemReset();
/// }
/// @endcode
///
#define RAIL_ASSERT_ERROR_MESSAGES { \
/* 0*/ "Appended info missing from Rx packet", \
/* 1*/ "Payload bytes missing from Rx packet", \
/* 2*/ "Error reading back packet payload", \
/* 3*/ "Receive fifo entry has invalid status", \
/* 4*/ "Receive fifo entry bad packet length", \
/* 5*/ "Unable to configure radio for IR calibration", \
/* 6*/ "Reached unexpected state while handling Rx fifo events", \
/* 7*/ "Reached unexpected state while handling RXLEN fifo events", \
/* 8*/ "Reached unexpected state while handling Tx fifo events", \
/* 9*/ "Reached unexpected state while handling Tx ACK fifo events", \
/*10*/ "No memory to store receive packet", \
/*11*/ "Packet length longer than the receive FIFO size", \
/*12*/ "Invalid radio clock prescaler", \
/*13*/ "Error synchronizing the RAIL timebase after sleep", \
/*14*/ "VCO frequency outside supported range", \
/*15*/ "Radio active while changing channels", \
/*16*/ "Unable to configure DCDC retiming", \
/*17*/ "Nested attempt to lock the sequencer", \
/*18*/ "RSSI averaging enabled without a valid callback", \
/*19*/ "Invalid dynamic frame length setting provided (dflBits)", \
/*20*/ "Unable to seed radio pseudo random number generator", \
/*21*/ "Timeout exceeds EFR32XG1 register size", \
/*22*/ "Invalid timer channel specified", \
/*23*/ "Timer value larger than RAIL timebase", \
/*24*/ "LBT config exceeds EFR32XG1 register size", \
/*25*/ "Deprecated CSMA/LBT retry callback unexpectedly called", \
/*26*/ "Could not synchronize RAIL timebase with the RTC", \
/*27*/ "Clock source not ready", \
/*28*/ "Attempted to set RAIL timings to invalid value", \
/*29*/ "NULL was supplied as a RAIL_Handle_t argument", \
/*30*/ "Scheduled timer not running", \
/*31*/ "No active config to switch from", \
/*32*/ "No active handle after switch", \
/*33*/ "RfInit failed to configure active state", \
/*34*/ "No active handle for scheduled rx", \
/*35*/ "Invalid handle for scheduled tx", \
/*36*/ "Inactive handle for scheduled tx", \
/*37*/ "Invalid config index to switch to", \
/*38*/ "No active handle for single protocol", \
/*39*/ "This function is deprecated and must not be called", \
/*40*/ "Multiprotocol task started with no event to run", \
/*41*/ "Invalid interrupt enabled", \
/*42*/ "Power conversion functions called before curves were initialized", \
/*43*/ "Division by zero", \
/*44*/ "Function cannot be called without access to the hardware", \
}
#endif
/**
* @}
*/
#endif // __RAIL_ASSERT_ERROR_CODES_H__

View File

@ -2,7 +2,7 @@
* @file rail_chip_specific.h
* @brief This file contains the type definitions for EFR32 chip specific
* aspects of RAIL.
* @copyright Copyright 2015 Silicon Laboratories, Inc. http://www.silabs.com
* @copyright Copyright 2015 Silicon Laboratories, Inc. www.silabs.com
******************************************************************************/
#ifndef __RAIL_CHIP_SPECIFIC_H_
@ -17,6 +17,10 @@
#include "rail_types.h"
#ifdef __cplusplus
extern "C" {
#endif
// -----------------------------------------------------------------------------
// Multiprotocol
// -----------------------------------------------------------------------------
@ -62,9 +66,9 @@
*/
/** EFR32 specific temperature calibration bit */
#define RAIL_CAL_TEMP_VCO (0x00000001)
#define RAIL_CAL_TEMP_VCO (0x00000001U)
/** EFR32 specific IR calibration bit */
#define RAIL_CAL_ONETIME_IRCAL (0x00010000)
#define RAIL_CAL_ONETIME_IRCAL (0x00010000U)
/** Mask to run temperature dependent calibrations */
#define RAIL_CAL_TEMP (RAIL_CAL_TEMP_VCO)
@ -77,9 +81,74 @@
/** Mask to run all possible calibrations for this chip */
#define RAIL_CAL_ALL (RAIL_CAL_TEMP | RAIL_CAL_ONETIME)
/** Mask to run all pending calibrations */
#define RAIL_CAL_ALL_PENDING (0x00000000)
#define RAIL_CAL_ALL_PENDING (0x00000000U)
/** Invalid calibration value */
#define RAIL_CAL_INVALID_VALUE (0xFFFFFFFF)
#define RAIL_CAL_INVALID_VALUE (0xFFFFFFFFU)
/**
* Applies a given image rejection calibration value.
*
* @param[in] railHandle A RAIL instance handle.
* @param[in] imageRejection The image rejection value to apply.
* @return Status code indicating success of the function call.
*
* Take an image rejection calibration value and apply it. This value should be
* determined from a previous run of \ref RAIL_CalibrateIr on the same
* physical device with the same radio configuration. The imageRejection value
* will also be stored to the \ref RAIL_ChannelConfigEntry_t::attr, if possible.
*
* If multiple protocols are used, this function will return
* \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
* not active. The caller must attempt to re-call this function later, in that
* case.
*/
RAIL_Status_t RAIL_ApplyIrCalibration(RAIL_Handle_t railHandle,
uint32_t imageRejection);
/**
* Run the image rejection calibration
*
* @param[in] railHandle A RAIL instance handle.
* @param[out] imageRejection The result of the image rejection calibration.
* @return Status code indicating success of the function call.
*
* Run the image rejection calibration, and apply the resulting value. If the
* imageRejection parameter is non-NULL, then also store the value at that
* location. The imageRejection value will also be stored to the
* \ref RAIL_ChannelConfigEntry_t::attr, if possible. This is a long-running
* calibration that adds significant code space when run, and can be run with a
* separate firmware image on each device in order to save code space in the
* final image.
*
* If multiple protocols are used, this function will return
* \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
* not active. The caller must attempt to re-call this function later, in that
* case.
*/
RAIL_Status_t RAIL_CalibrateIr(RAIL_Handle_t railHandle,
uint32_t *imageRejection);
/**
* Run the temperature calibration
*
* @param[in] railHandle A RAIL instance handle.
* @return Status code indicating success of the function call.
*
* Run the temperature calibration, which needs to recalibrate the synth if
* the temperature crosses 0C or the temperature delta since the last
* calibration exceeds 70C while sitting in receive. RAIL will run VCO
* calibration automatically upon entering receive state so the application can
* omit this calibration if the stack will re-enter receive with enough
* frequency to not hit this temperature delta. If the application does not
* calibrate for temperature, it's possible to miss receive packets due to
* drift in the carrier frequency.
*
* If multiple protocols are used, this function will return
* \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
* not active. In that case the calibration will be automatically performed the
* next time the radio enters receive.
*/
RAIL_Status_t RAIL_CalibrateTemp(RAIL_Handle_t railHandle);
/**
* @struct RAIL_CalValues_t
@ -311,4 +380,48 @@ typedef struct RAIL_PtiConfig {
/** @} */ // end of group PTI_EFR32
// -----------------------------------------------------------------------------
// Antenna Control
// -----------------------------------------------------------------------------
/**
* @addtogroup Antenna_Control_EFR32 EFR32
* @{
* @brief EFR32 Antenna Control functionality
* @ingroup Antenna
*
* These enums and structures are used with RAIL Antenna Control API. EFR32 supports
* up to two antennas and with configurable pin locations.
*/
/**
* @struct RAIL_AntennaConfig_t
* @brief Configuration for Antenna switch pins.
*/
typedef struct RAIL_AntennaConfig {
/** MODEM_ROUTEPEN fields */
/** Antenna 0 Pin Enable */
bool ant0PinEn;
/** Antenna 1 Pin Enable */
bool ant1PinEn;
/** MODEM_ROUTELOC1 fields */
/** Antenna 0 location for pin/port */
uint8_t ant0Loc;
/** Antenna 0 output GPIO port */
GPIO_Port_TypeDef ant0Port;
/** Antenna 0 output GPIO pin */
uint8_t ant0Pin;
/** Antenna 1 location for pin/port */
uint8_t ant1Loc;
/** Antenna 1 output GPIO port */
GPIO_Port_TypeDef ant1Port;
/** Antenna 1 output GPIO pin */
uint8_t ant1Pin;
} RAIL_AntennaConfig_t;
/** @} */ // end of group Antenna_Control_EFR32
#ifdef __cplusplus
}
#endif
#endif

View File

@ -4,7 +4,7 @@
* @version INTERNAL
*******************************************************************************
* @section License
* <b>(C) Copyright 2017 Silicon Labs, http://silabs.com</b>
* <b>(C) Copyright 2017 Silicon Labs, www.silabs.com</b>
******************************************************************************/
#ifndef __TIMING_STATE_H
#define __TIMING_STATE_H
@ -34,6 +34,12 @@ typedef struct StateTimings {
// delay for RX only calculates how long we need to stay in RX to get SYNC,
// which does not need to be precise. (And hard to measure.)
int32_t rxDoneDelayNs;
#endif
#if _SILICON_LABS_32B_SERIES_1_CONFIG >= 2
// The viterbi phy needs extra time to power up the receive path during
// TX2RX in order to receive low RSSI packets. This flag indicates to
// turn on that extra time
bool viterbiPhy;
#endif
int32_t txChainDelayNs;
uint16_t rxSearch;