mirror of
https://github.com/espressif/openthread.git
synced 2026-08-14 14:47:46 +00:00
[nrf52840] use mac features introduced in new radio driver (#2629)
* Use ACK timeout feature introduced in new driver version * Use CSMA-CA feature introduced in new driver version
This commit is contained in:
committed by
Jonathan Hui
parent
996be6e147
commit
ef0940644d
@@ -149,6 +149,8 @@ RADIO_DRIVER_SOURCES
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/nrf_802154_rx_buffer.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_ack_timeout.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_csma_ca.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/platform/clock/nrf_802154_clock_sdk.c \
|
||||
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c \
|
||||
$(NULL)
|
||||
|
||||
@@ -389,7 +389,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef NRF_802154_CSMA_CA_ENABLED
|
||||
#define NRF_802154_CSMA_CA_ENABLED 0
|
||||
#define NRF_802154_CSMA_CA_ENABLED 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -399,7 +399,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef NRF_802154_ACK_TIMEOUT_ENABLED
|
||||
#define NRF_802154_ACK_TIMEOUT_ENABLED 0
|
||||
#define NRF_802154_ACK_TIMEOUT_ENABLED 1
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_CONFIG_H_
|
||||
|
||||
@@ -88,10 +88,9 @@ static int8_t sEnergyDetected;
|
||||
|
||||
typedef enum {
|
||||
kPendingEventSleep, // Requested to enter Sleep state.
|
||||
kPendingEventTransmit, // Frame is queued for transmission.
|
||||
kPendingEventFrameTransmitted, // Transmitted frame and received ACK (if requested).
|
||||
kPendingEventChannelAccessFailure, // Failed to transmit frame (channel busy).
|
||||
kPendingEventInvalidAck, // Failed to transmit frame (received invalid ACK).
|
||||
kPendingEventInvalidOrNoAck, // Failed to transmit frame (received invalid or no ACK).
|
||||
kPendingEventReceiveFailed, // Failed to receive a valid frame.
|
||||
kPendingEventEnergyDetectionStart, // Requested to start Energy Detection procedure.
|
||||
kPendingEventEnergyDetected, // Energy Detection finished.
|
||||
@@ -160,7 +159,7 @@ static inline void clearPendingEvents(void)
|
||||
|
||||
bitsToRemain &= ~(1UL << kPendingEventFrameTransmitted);
|
||||
bitsToRemain &= ~(1UL << kPendingEventChannelAccessFailure);
|
||||
bitsToRemain &= ~(1UL << kPendingEventInvalidAck);
|
||||
bitsToRemain &= ~(1UL << kPendingEventInvalidOrNoAck);
|
||||
|
||||
bitsToRemain &= ~(1UL << kPendingEventSleep);
|
||||
|
||||
@@ -330,17 +329,9 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
aFrame->mPsdu[-1] = aFrame->mLength;
|
||||
|
||||
nrf_802154_channel_set(aFrame->mChannel);
|
||||
|
||||
if (nrf_802154_transmit_raw(&aFrame->mPsdu[-1], true))
|
||||
{
|
||||
clearPendingEvents();
|
||||
otPlatRadioTxStarted(aInstance, aFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
clearPendingEvents();
|
||||
setPendingEvent(kPendingEventTransmit);
|
||||
}
|
||||
nrf_802154_transmit_csma_ca_raw(&aFrame->mPsdu[-1]);
|
||||
clearPendingEvents();
|
||||
otPlatRadioTxStarted(aInstance, aFrame);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
@@ -363,7 +354,7 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
return OT_RADIO_CAPS_ENERGY_SCAN;
|
||||
return OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF;
|
||||
}
|
||||
|
||||
bool otPlatRadioGetPromiscuous(otInstance *aInstance)
|
||||
@@ -553,17 +544,6 @@ void nrf5RadioProcess(otInstance *aInstance)
|
||||
}
|
||||
}
|
||||
|
||||
if (isPendingEventSet(kPendingEventTransmit))
|
||||
{
|
||||
nrf_802154_channel_set(sTransmitFrame.mChannel);
|
||||
|
||||
if (nrf_802154_transmit_raw(sTransmitPsdu, true))
|
||||
{
|
||||
resetPendingEvent(kPendingEventTransmit);
|
||||
otPlatRadioTxStarted(aInstance, &sTransmitFrame);
|
||||
}
|
||||
}
|
||||
|
||||
if (isPendingEventSet(kPendingEventFrameTransmitted))
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
@@ -605,7 +585,7 @@ void nrf5RadioProcess(otInstance *aInstance)
|
||||
resetPendingEvent(kPendingEventChannelAccessFailure);
|
||||
}
|
||||
|
||||
if (isPendingEventSet(kPendingEventInvalidAck))
|
||||
if (isPendingEventSet(kPendingEventInvalidOrNoAck))
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
|
||||
@@ -619,7 +599,7 @@ void nrf5RadioProcess(otInstance *aInstance)
|
||||
otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NO_ACK);
|
||||
}
|
||||
|
||||
resetPendingEvent(kPendingEventInvalidAck);
|
||||
resetPendingEvent(kPendingEventInvalidOrNoAck);
|
||||
}
|
||||
|
||||
if (isPendingEventSet(kPendingEventReceiveFailed))
|
||||
@@ -756,8 +736,9 @@ void nrf_802154_transmit_failed(const uint8_t *aFrame, nrf_802154_tx_error_t err
|
||||
break;
|
||||
|
||||
case NRF_802154_TX_ERROR_INVALID_ACK:
|
||||
case NRF_802154_TX_ERROR_NO_ACK:
|
||||
case NRF_802154_TX_ERROR_NO_MEM:
|
||||
setPendingEvent(kPendingEventInvalidAck);
|
||||
setPendingEvent(kPendingEventInvalidOrNoAck);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user