Skip to content

Commit

Permalink
[efr32] add radio.c debug counters for efr32mg12 and efr32mg21 (#4217)
Browse files Browse the repository at this point in the history
Also adds Silicon Laboratories, Inc. to AUTHORS file.
  • Loading branch information
Marven Gilhespie authored and jwhui committed Oct 4, 2019
1 parent 3888226 commit 43c8a70
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Texas Instruments Incorporated
NXP Semiconductors
Synopsys, Inc.
Cascoda Limited
Silicon Laboratories, Inc
1 change: 1 addition & 0 deletions examples/platforms/efr32mg12/brd4161a/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
#define __BOARD_CONFIG_H__

#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__
2 changes: 2 additions & 0 deletions examples/platforms/efr32mg12/brd4166a/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@
#define __BOARD_CONFIG_H__

#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__
1 change: 1 addition & 0 deletions examples/platforms/efr32mg12/brd4170a/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@

#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_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c

#endif // __BOARD_CONFIG_H__
1 change: 1 addition & 0 deletions examples/platforms/efr32mg12/brd4304a/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
#define __BOARD_CONFIG_H__

#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__
20 changes: 20 additions & 0 deletions examples/platforms/efr32mg12/platform-band.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@

#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
{
RAIL_Config_t mRailConfig;
Expand Down
85 changes: 83 additions & 2 deletions examples/platforms/efr32mg12/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ static volatile otError sTransmitError;
static efr32CommonConfig sCommonConfig;
static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS];

#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
static efr32RadioCounters sRailDebugCounters;
#endif

static volatile energyScanStatus sEnergyScanStatus;
static volatile int8_t sEnergyScanResultDbm;
static energyScanMode sEnergyScanMode;
Expand Down Expand Up @@ -188,7 +192,12 @@ static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig)
RAIL_EVENT_RX_PACKET_RECEIVED | //
RAIL_EVENT_RSSI_AVERAGE_DONE | //
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);

Expand Down Expand Up @@ -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].mChannelMax = OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX;
#endif

#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
memset(&sRailDebugCounters, 0x00, sizeof(efr32RadioCounters));
#endif

gRailHandle = efr32RailInit(&sCommonConfig);
assert(gRailHandle != NULL);
efr32RailConfigLoad(&(sBandConfigs[0]));
Expand Down Expand Up @@ -500,6 +514,10 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
RAIL_Status_t status;
uint8_t frameLength;

#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailPlatTxTriggered++;
#endif

assert(sTransmitBusy == false);

otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT),
Expand All @@ -519,7 +537,6 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
sCurrentBandConfig = config;
}

otEXPECT(aFrame->mLength >= IEEE802154_MIN_LENGTH && aFrame->mLength <= IEEE802154_MAX_LENGTH);
frameLength = (uint8_t)aFrame->mLength;
RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true);
RAIL_WriteTxFifo(gRailHandle, aFrame->mPsdu, frameLength - 2, false);
Expand All @@ -540,10 +557,16 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)

if (status == RAIL_STATUS_NO_ERROR)
{
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailTxStarted++;
#endif
otPlatRadioTxStarted(aInstance, aFrame);
}
else
{
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailTxStartFailed++;
#endif
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
sTransmitBusy = false;
}
Expand Down Expand Up @@ -706,6 +729,9 @@ static void processNextRxPacket(otInstance *aInstance)
{
otLogInfoPlat("Received %d bytes", sReceiveFrame.mLength);
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailPlatRadioReceiveDoneCbCount++;
#endif
}
}
}
Expand Down Expand Up @@ -749,6 +775,16 @@ static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle)

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)
{
ieee802154DataRequestCommand(aRailHandle);
Expand All @@ -762,28 +798,43 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
sTransmitError = OT_ERROR_NONE;
sTransmitBusy = false;
}
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventPacketSent++;
#endif
}
else if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY)
{
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
sTransmitBusy = false;
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventChannelBusy++;
#endif
}
else
{
sTransmitError = OT_ERROR_ABORT;
sTransmitBusy = false;
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventTxAbort++;
#endif
}
}

if (aEvents & RAIL_EVENT_RX_ACK_TIMEOUT)
{
sTransmitError = OT_ERROR_NO_ACK;
sTransmitBusy = false;
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventNoAck++;
#endif
}

if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED)
{
RAIL_HoldRxPacket(aRailHandle);
#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventPacketReceived++;
#endif
}

if (aEvents & RAIL_EVENT_CAL_NEEDED)
Expand All @@ -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);
assert(status == RAIL_STATUS_NO_ERROR);

#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventCalNeeded++;
#endif
}

if (aEvents & RAIL_EVENT_RSSI_AVERAGE_DONE)
Expand All @@ -808,6 +863,24 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
{
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();
Expand Down Expand Up @@ -846,13 +919,21 @@ void efr32RadioProcess(otInstance *aInstance)
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
}

#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailPlatRadioTxDoneCbCount++;
#endif

otSysEventSignalPending();
}
else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED)
{
sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE;
otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm);
otSysEventSignalPending();

#if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
sRailDebugCounters.mRailEventEnergyScanCompleted++;
#endif
}

processNextRxPacket(aInstance);
Expand Down
1 change: 1 addition & 0 deletions examples/platforms/efr32mg21/brd4180a/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
#define __BOARD_CONFIG_H__

#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__
20 changes: 20 additions & 0 deletions examples/platforms/efr32mg21/platform-band.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@

#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
{
RAIL_Config_t mRailConfig;
Expand Down
Loading

0 comments on commit 43c8a70

Please sign in to comment.