mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[efr32] add radio.c debug counters for efr32mg12 and efr32mg21 (#4217)
Also adds Silicon Laboratories, Inc. to AUTHORS file.
This commit is contained in:
committed by
Jonathan Hui
parent
3888226c3f
commit
43c8a709db
@@ -15,3 +15,4 @@ Texas Instruments Incorporated
|
|||||||
NXP Semiconductors
|
NXP Semiconductors
|
||||||
Synopsys, Inc.
|
Synopsys, Inc.
|
||||||
Cascoda Limited
|
Cascoda Limited
|
||||||
|
Silicon Laboratories, Inc
|
||||||
|
|||||||
@@ -36,5 +36,6 @@
|
|||||||
#define __BOARD_CONFIG_H__
|
#define __BOARD_CONFIG_H__
|
||||||
|
|
||||||
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
||||||
|
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
|
||||||
|
|
||||||
#endif // __BOARD_CONFIG_H__
|
#endif // __BOARD_CONFIG_H__
|
||||||
|
|||||||
@@ -36,5 +36,7 @@
|
|||||||
#define __BOARD_CONFIG_H__
|
#define __BOARD_CONFIG_H__
|
||||||
|
|
||||||
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
||||||
|
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
|
||||||
|
|
||||||
|
|
||||||
#endif // __BOARD_CONFIG_H__
|
#endif // __BOARD_CONFIG_H__
|
||||||
|
|||||||
@@ -37,5 +37,6 @@
|
|||||||
|
|
||||||
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
||||||
#define RADIO_CONFIG_915MHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 915MHz band.
|
#define RADIO_CONFIG_915MHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 915MHz band.
|
||||||
|
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
|
||||||
|
|
||||||
#endif // __BOARD_CONFIG_H__
|
#endif // __BOARD_CONFIG_H__
|
||||||
|
|||||||
@@ -36,5 +36,6 @@
|
|||||||
#define __BOARD_CONFIG_H__
|
#define __BOARD_CONFIG_H__
|
||||||
|
|
||||||
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
||||||
|
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
|
||||||
|
|
||||||
#endif // __BOARD_CONFIG_H__
|
#endif // __BOARD_CONFIG_H__
|
||||||
|
|||||||
@@ -43,6 +43,26 @@
|
|||||||
|
|
||||||
#define RAIL_TX_FIFO_SIZE (OT_RADIO_FRAME_MAX_SIZE + 1)
|
#define RAIL_TX_FIFO_SIZE (OT_RADIO_FRAME_MAX_SIZE + 1)
|
||||||
|
|
||||||
|
typedef struct efr32RadioCounters
|
||||||
|
{
|
||||||
|
uint64_t mRailPlatTxTriggered;
|
||||||
|
uint64_t mRailPlatRadioReceiveDoneCbCount;
|
||||||
|
uint64_t mRailPlatRadioEnergyScanDoneCbCount;
|
||||||
|
uint64_t mRailPlatRadioTxDoneCbCount;
|
||||||
|
uint64_t mRailTxStarted;
|
||||||
|
uint64_t mRailTxStartFailed;
|
||||||
|
uint64_t mRailEventConfigScheduled;
|
||||||
|
uint64_t mRailEventConfigUnScheduled;
|
||||||
|
uint64_t mRailEventPacketSent;
|
||||||
|
uint64_t mRailEventChannelBusy;
|
||||||
|
uint64_t mRailEventEnergyScanCompleted;
|
||||||
|
uint64_t mRailEventCalNeeded;
|
||||||
|
uint64_t mRailEventPacketReceived;
|
||||||
|
uint64_t mRailEventNoAck;
|
||||||
|
uint64_t mRailEventTxAbort;
|
||||||
|
uint64_t mRailEventSchedulerStatusError;
|
||||||
|
} efr32RadioCounters;
|
||||||
|
|
||||||
typedef struct efr32CommonConfig
|
typedef struct efr32CommonConfig
|
||||||
{
|
{
|
||||||
RAIL_Config_t mRailConfig;
|
RAIL_Config_t mRailConfig;
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ static volatile otError sTransmitError;
|
|||||||
static efr32CommonConfig sCommonConfig;
|
static efr32CommonConfig sCommonConfig;
|
||||||
static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS];
|
static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS];
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
static efr32RadioCounters sRailDebugCounters;
|
||||||
|
#endif
|
||||||
|
|
||||||
static volatile energyScanStatus sEnergyScanStatus;
|
static volatile energyScanStatus sEnergyScanStatus;
|
||||||
static volatile int8_t sEnergyScanResultDbm;
|
static volatile int8_t sEnergyScanResultDbm;
|
||||||
static energyScanMode sEnergyScanMode;
|
static energyScanMode sEnergyScanMode;
|
||||||
@@ -188,7 +192,12 @@ static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig)
|
|||||||
RAIL_EVENT_RX_PACKET_RECEIVED | //
|
RAIL_EVENT_RX_PACKET_RECEIVED | //
|
||||||
RAIL_EVENT_RSSI_AVERAGE_DONE | //
|
RAIL_EVENT_RSSI_AVERAGE_DONE | //
|
||||||
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
|
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
|
||||||
RAIL_EVENT_CAL_NEEDED //
|
RAIL_EVENT_CAL_NEEDED | //
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
RAIL_EVENT_CONFIG_SCHEDULED | //
|
||||||
|
RAIL_EVENT_CONFIG_UNSCHEDULED | //
|
||||||
|
#endif
|
||||||
|
RAIL_EVENT_SCHEDULER_STATUS //
|
||||||
);
|
);
|
||||||
assert(status == RAIL_STATUS_NO_ERROR);
|
assert(status == RAIL_STATUS_NO_ERROR);
|
||||||
|
|
||||||
@@ -271,6 +280,11 @@ static void efr32ConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAI
|
|||||||
sBandConfigs[index].mChannelMin = OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN;
|
sBandConfigs[index].mChannelMin = OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN;
|
||||||
sBandConfigs[index].mChannelMax = OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX;
|
sBandConfigs[index].mChannelMax = OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
memset(&sRailDebugCounters, 0x00, sizeof(efr32RadioCounters));
|
||||||
|
#endif
|
||||||
|
|
||||||
gRailHandle = efr32RailInit(&sCommonConfig);
|
gRailHandle = efr32RailInit(&sCommonConfig);
|
||||||
assert(gRailHandle != NULL);
|
assert(gRailHandle != NULL);
|
||||||
efr32RailConfigLoad(&(sBandConfigs[0]));
|
efr32RailConfigLoad(&(sBandConfigs[0]));
|
||||||
@@ -500,6 +514,10 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
RAIL_Status_t status;
|
RAIL_Status_t status;
|
||||||
uint8_t frameLength;
|
uint8_t frameLength;
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatTxTriggered++;
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(sTransmitBusy == false);
|
assert(sTransmitBusy == false);
|
||||||
|
|
||||||
otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT),
|
otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT),
|
||||||
@@ -519,7 +537,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
sCurrentBandConfig = config;
|
sCurrentBandConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
otEXPECT(aFrame->mLength >= IEEE802154_MIN_LENGTH && aFrame->mLength <= IEEE802154_MAX_LENGTH);
|
|
||||||
frameLength = (uint8_t)aFrame->mLength;
|
frameLength = (uint8_t)aFrame->mLength;
|
||||||
RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true);
|
RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true);
|
||||||
RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false);
|
RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false);
|
||||||
@@ -540,10 +557,16 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
|
|
||||||
if (status == RAIL_STATUS_NO_ERROR)
|
if (status == RAIL_STATUS_NO_ERROR)
|
||||||
{
|
{
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailTxStarted++;
|
||||||
|
#endif
|
||||||
otPlatRadioTxStarted(aInstance, aFrame);
|
otPlatRadioTxStarted(aInstance, aFrame);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailTxStartFailed++;
|
||||||
|
#endif
|
||||||
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
}
|
}
|
||||||
@@ -706,6 +729,9 @@ static void processNextRxPacket(otInstance *aInstance)
|
|||||||
{
|
{
|
||||||
otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength);
|
otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength);
|
||||||
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
|
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -749,6 +775,16 @@ static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle)
|
|||||||
|
|
||||||
static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
||||||
{
|
{
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
if (aEvents & RAIL_EVENT_CONFIG_SCHEDULED)
|
||||||
|
{
|
||||||
|
sRailDebugCounters.mRailEventConfigScheduled++;
|
||||||
|
}
|
||||||
|
if (aEvents & RAIL_EVENT_CONFIG_UNSCHEDULED)
|
||||||
|
{
|
||||||
|
sRailDebugCounters.mRailEventConfigUnScheduled++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND)
|
if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND)
|
||||||
{
|
{
|
||||||
ieee802154DataRequestCommand(aRailHandle);
|
ieee802154DataRequestCommand(aRailHandle);
|
||||||
@@ -762,16 +798,25 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
sTransmitError = OT_ERROR_NONE;
|
sTransmitError = OT_ERROR_NONE;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
}
|
}
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventPacketSent++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY)
|
else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY)
|
||||||
{
|
{
|
||||||
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventChannelBusy++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sTransmitError = OT_ERROR_ABORT;
|
sTransmitError = OT_ERROR_ABORT;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventTxAbort++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,11 +824,17 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
{
|
{
|
||||||
sTransmitError = OT_ERROR_NO_ACK;
|
sTransmitError = OT_ERROR_NO_ACK;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventNoAck++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED)
|
if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED)
|
||||||
{
|
{
|
||||||
RAIL_HoldRxPacket(aRailHandle);
|
RAIL_HoldRxPacket(aRailHandle);
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventPacketReceived++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aEvents & RAIL_EVENT_CAL_NEEDED)
|
if (aEvents & RAIL_EVENT_CAL_NEEDED)
|
||||||
@@ -792,6 +843,10 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
|
|
||||||
status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING);
|
status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING);
|
||||||
assert(status == RAIL_STATUS_NO_ERROR);
|
assert(status == RAIL_STATUS_NO_ERROR);
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventCalNeeded++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE)
|
if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE)
|
||||||
@@ -808,6 +863,24 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
{
|
{
|
||||||
sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM;
|
sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatRadioEnergyScanDoneCbCount++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (aEvents & RAIL_EVENT_SCHEDULER_STATUS)
|
||||||
|
{
|
||||||
|
RAIL_SchedulerStatus_t status = RAIL_GetSchedulerStatus(aRailHandle);
|
||||||
|
|
||||||
|
if (status == RAIL_SCHEDULER_STATUS_SINGLE_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SCHEDULED_TX_FAIL ||
|
||||||
|
(status == RAIL_SCHEDULER_STATUS_SCHEDULE_FAIL && sTransmitBusy))
|
||||||
|
{
|
||||||
|
sTransmitError = OT_ERROR_ABORT;
|
||||||
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventSchedulerStatusError++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
otSysEventSignalPending();
|
otSysEventSignalPending();
|
||||||
@@ -846,6 +919,10 @@ void efr32RadioProcess(otInstance *aInstance)
|
|||||||
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
|
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatRadioTxDoneCbCount++;
|
||||||
|
#endif
|
||||||
|
|
||||||
otSysEventSignalPending();
|
otSysEventSignalPending();
|
||||||
}
|
}
|
||||||
else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED)
|
else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED)
|
||||||
@@ -853,6 +930,10 @@ void efr32RadioProcess(otInstance *aInstance)
|
|||||||
sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE;
|
sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE;
|
||||||
otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm);
|
otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm);
|
||||||
otSysEventSignalPending();
|
otSysEventSignalPending();
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventEnergyScanCompleted++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
processNextRxPacket(aInstance);
|
processNextRxPacket(aInstance);
|
||||||
|
|||||||
@@ -36,5 +36,6 @@
|
|||||||
#define __BOARD_CONFIG_H__
|
#define __BOARD_CONFIG_H__
|
||||||
|
|
||||||
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 ///< Dev board suppports OQPSK modulation in 2.4GHz band.
|
||||||
|
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
|
||||||
|
|
||||||
#endif // __BOARD_CONFIG_H__
|
#endif // __BOARD_CONFIG_H__
|
||||||
|
|||||||
@@ -43,6 +43,26 @@
|
|||||||
|
|
||||||
#define RAIL_TX_FIFO_SIZE (OT_RADIO_FRAME_MAX_SIZE + 1)
|
#define RAIL_TX_FIFO_SIZE (OT_RADIO_FRAME_MAX_SIZE + 1)
|
||||||
|
|
||||||
|
typedef struct efr32RadioCounters
|
||||||
|
{
|
||||||
|
uint64_t mRailPlatTxTriggered;
|
||||||
|
uint64_t mRailPlatRadioReceiveDoneCbCount;
|
||||||
|
uint64_t mRailPlatRadioEnergyScanDoneCbCount;
|
||||||
|
uint64_t mRailPlatRadioTxDoneCbCount;
|
||||||
|
uint64_t mRailTxStarted;
|
||||||
|
uint64_t mRailTxStartFailed;
|
||||||
|
uint64_t mRailEventConfigScheduled;
|
||||||
|
uint64_t mRailEventConfigUnScheduled;
|
||||||
|
uint64_t mRailEventPacketSent;
|
||||||
|
uint64_t mRailEventChannelBusy;
|
||||||
|
uint64_t mRailEventEnergyScanCompleted;
|
||||||
|
uint64_t mRailEventCalNeeded;
|
||||||
|
uint64_t mRailEventPacketReceived;
|
||||||
|
uint64_t mRailEventNoAck;
|
||||||
|
uint64_t mRailEventTxAbort;
|
||||||
|
uint64_t mRailEventSchedulerStatusError;
|
||||||
|
} efr32RadioCounters;
|
||||||
|
|
||||||
typedef struct efr32CommonConfig
|
typedef struct efr32CommonConfig
|
||||||
{
|
{
|
||||||
RAIL_Config_t mRailConfig;
|
RAIL_Config_t mRailConfig;
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ static volatile otError sTransmitError;
|
|||||||
static efr32CommonConfig sCommonConfig;
|
static efr32CommonConfig sCommonConfig;
|
||||||
static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS];
|
static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS];
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
static efr32RadioCounters sRailDebugCounters;
|
||||||
|
#endif
|
||||||
|
|
||||||
static volatile energyScanStatus sEnergyScanStatus;
|
static volatile energyScanStatus sEnergyScanStatus;
|
||||||
static volatile int8_t sEnergyScanResultDbm;
|
static volatile int8_t sEnergyScanResultDbm;
|
||||||
static energyScanMode sEnergyScanMode;
|
static energyScanMode sEnergyScanMode;
|
||||||
@@ -183,7 +187,12 @@ static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig)
|
|||||||
RAIL_EVENT_RX_PACKET_RECEIVED | //
|
RAIL_EVENT_RX_PACKET_RECEIVED | //
|
||||||
RAIL_EVENT_RSSI_AVERAGE_DONE | //
|
RAIL_EVENT_RSSI_AVERAGE_DONE | //
|
||||||
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
|
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
|
||||||
RAIL_EVENT_CAL_NEEDED //
|
RAIL_EVENT_CAL_NEEDED | //
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
RAIL_EVENT_CONFIG_SCHEDULED | //
|
||||||
|
RAIL_EVENT_CONFIG_UNSCHEDULED | //
|
||||||
|
#endif
|
||||||
|
RAIL_EVENT_SCHEDULER_STATUS //
|
||||||
);
|
);
|
||||||
assert(status == RAIL_STATUS_NO_ERROR);
|
assert(status == RAIL_STATUS_NO_ERROR);
|
||||||
|
|
||||||
@@ -254,6 +263,11 @@ static void efr32ConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAI
|
|||||||
|
|
||||||
index++;
|
index++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
memset(&sRailDebugCounters, 0x00, sizeof(efr32RadioCounters));
|
||||||
|
#endif
|
||||||
|
|
||||||
gRailHandle = efr32RailInit(&sCommonConfig);
|
gRailHandle = efr32RailInit(&sCommonConfig);
|
||||||
assert(gRailHandle != NULL);
|
assert(gRailHandle != NULL);
|
||||||
efr32RailConfigLoad(&(sBandConfigs[0]));
|
efr32RailConfigLoad(&(sBandConfigs[0]));
|
||||||
@@ -482,6 +496,10 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
RAIL_Status_t status;
|
RAIL_Status_t status;
|
||||||
uint8_t frameLength;
|
uint8_t frameLength;
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatTxTriggered++;
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(sTransmitBusy == false);
|
assert(sTransmitBusy == false);
|
||||||
|
|
||||||
otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT),
|
otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT),
|
||||||
@@ -501,7 +519,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
sCurrentBandConfig = config;
|
sCurrentBandConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
otEXPECT(aFrame->mLength >= IEEE802154_MIN_LENGTH && aFrame->mLength <= IEEE802154_MAX_LENGTH);
|
|
||||||
frameLength = (uint8_t)aFrame->mLength;
|
frameLength = (uint8_t)aFrame->mLength;
|
||||||
RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true);
|
RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true);
|
||||||
RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false);
|
RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false);
|
||||||
@@ -522,10 +539,16 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
|||||||
|
|
||||||
if (status == RAIL_STATUS_NO_ERROR)
|
if (status == RAIL_STATUS_NO_ERROR)
|
||||||
{
|
{
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailTxStarted++;
|
||||||
|
#endif
|
||||||
otPlatRadioTxStarted(aInstance, aFrame);
|
otPlatRadioTxStarted(aInstance, aFrame);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailTxStartFailed++;
|
||||||
|
#endif
|
||||||
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
}
|
}
|
||||||
@@ -688,6 +711,9 @@ static void processNextRxPacket(otInstance *aInstance)
|
|||||||
{
|
{
|
||||||
otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength);
|
otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength);
|
||||||
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
|
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -729,6 +755,16 @@ static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle)
|
|||||||
|
|
||||||
static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
||||||
{
|
{
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
if (aEvents & RAIL_EVENT_CONFIG_SCHEDULED)
|
||||||
|
{
|
||||||
|
sRailDebugCounters.mRailEventConfigScheduled++;
|
||||||
|
}
|
||||||
|
if (aEvents & RAIL_EVENT_CONFIG_UNSCHEDULED)
|
||||||
|
{
|
||||||
|
sRailDebugCounters.mRailEventConfigUnScheduled++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND)
|
if (aEvents & RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND)
|
||||||
{
|
{
|
||||||
ieee802154DataRequestCommand(aRailHandle);
|
ieee802154DataRequestCommand(aRailHandle);
|
||||||
@@ -742,16 +778,25 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
sTransmitError = OT_ERROR_NONE;
|
sTransmitError = OT_ERROR_NONE;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
}
|
}
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventPacketSent++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY)
|
else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY)
|
||||||
{
|
{
|
||||||
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventChannelBusy++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sTransmitError = OT_ERROR_ABORT;
|
sTransmitError = OT_ERROR_ABORT;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventTxAbort++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,11 +804,17 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
{
|
{
|
||||||
sTransmitError = OT_ERROR_NO_ACK;
|
sTransmitError = OT_ERROR_NO_ACK;
|
||||||
sTransmitBusy = false;
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventNoAck++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED)
|
if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED)
|
||||||
{
|
{
|
||||||
RAIL_HoldRxPacket(aRailHandle);
|
RAIL_HoldRxPacket(aRailHandle);
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventPacketReceived++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aEvents & RAIL_EVENT_CAL_NEEDED)
|
if (aEvents & RAIL_EVENT_CAL_NEEDED)
|
||||||
@@ -772,6 +823,10 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
|
|
||||||
status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING);
|
status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING);
|
||||||
assert(status == RAIL_STATUS_NO_ERROR);
|
assert(status == RAIL_STATUS_NO_ERROR);
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventCalNeeded++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE)
|
if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE)
|
||||||
@@ -788,6 +843,24 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
|||||||
{
|
{
|
||||||
sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM;
|
sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatRadioEnergyScanDoneCbCount++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (aEvents & RAIL_EVENT_SCHEDULER_STATUS)
|
||||||
|
{
|
||||||
|
RAIL_SchedulerStatus_t status = RAIL_GetSchedulerStatus(aRailHandle);
|
||||||
|
|
||||||
|
if (status == RAIL_SCHEDULER_STATUS_SINGLE_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SCHEDULED_TX_FAIL ||
|
||||||
|
(status == RAIL_SCHEDULER_STATUS_SCHEDULE_FAIL && sTransmitBusy))
|
||||||
|
{
|
||||||
|
sTransmitError = OT_ERROR_ABORT;
|
||||||
|
sTransmitBusy = false;
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventSchedulerStatusError++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,11 +896,19 @@ void efr32RadioProcess(otInstance *aInstance)
|
|||||||
{
|
{
|
||||||
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
|
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailPlatRadioTxDoneCbCount++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED)
|
else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED)
|
||||||
{
|
{
|
||||||
sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE;
|
sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE;
|
||||||
otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm);
|
otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm);
|
||||||
|
|
||||||
|
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
|
||||||
|
sRailDebugCounters.mRailEventEnergyScanCompleted++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
processNextRxPacket(aInstance);
|
processNextRxPacket(aInstance);
|
||||||
|
|||||||
Reference in New Issue
Block a user