[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:
Kamil Sroka
2018-03-21 16:06:58 +00:00
committed by Jonathan Hui
parent 996be6e147
commit ef0940644d
3 changed files with 14 additions and 31 deletions
+2
View File
@@ -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/nrf_802154_rx_buffer.c \
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/fem/nrf_fem_control.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_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/platform/clock/nrf_802154_clock_sdk.c \
@top_builddir@/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c \ @top_builddir@/third_party/NordicSemiconductor/drivers/radio/timer_scheduler/nrf_802154_timer_sched.c \
$(NULL) $(NULL)
@@ -389,7 +389,7 @@
* *
*/ */
#ifndef NRF_802154_CSMA_CA_ENABLED #ifndef NRF_802154_CSMA_CA_ENABLED
#define NRF_802154_CSMA_CA_ENABLED 0 #define NRF_802154_CSMA_CA_ENABLED 1
#endif #endif
/** /**
@@ -399,7 +399,7 @@
* *
*/ */
#ifndef NRF_802154_ACK_TIMEOUT_ENABLED #ifndef NRF_802154_ACK_TIMEOUT_ENABLED
#define NRF_802154_ACK_TIMEOUT_ENABLED 0 #define NRF_802154_ACK_TIMEOUT_ENABLED 1
#endif #endif
#endif // PLATFORM_CONFIG_H_ #endif // PLATFORM_CONFIG_H_
+10 -29
View File
@@ -88,10 +88,9 @@ static int8_t sEnergyDetected;
typedef enum { typedef enum {
kPendingEventSleep, // Requested to enter Sleep state. kPendingEventSleep, // Requested to enter Sleep state.
kPendingEventTransmit, // Frame is queued for transmission.
kPendingEventFrameTransmitted, // Transmitted frame and received ACK (if requested). kPendingEventFrameTransmitted, // Transmitted frame and received ACK (if requested).
kPendingEventChannelAccessFailure, // Failed to transmit frame (channel busy). 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. kPendingEventReceiveFailed, // Failed to receive a valid frame.
kPendingEventEnergyDetectionStart, // Requested to start Energy Detection procedure. kPendingEventEnergyDetectionStart, // Requested to start Energy Detection procedure.
kPendingEventEnergyDetected, // Energy Detection finished. kPendingEventEnergyDetected, // Energy Detection finished.
@@ -160,7 +159,7 @@ static inline void clearPendingEvents(void)
bitsToRemain &= ~(1UL << kPendingEventFrameTransmitted); bitsToRemain &= ~(1UL << kPendingEventFrameTransmitted);
bitsToRemain &= ~(1UL << kPendingEventChannelAccessFailure); bitsToRemain &= ~(1UL << kPendingEventChannelAccessFailure);
bitsToRemain &= ~(1UL << kPendingEventInvalidAck); bitsToRemain &= ~(1UL << kPendingEventInvalidOrNoAck);
bitsToRemain &= ~(1UL << kPendingEventSleep); bitsToRemain &= ~(1UL << kPendingEventSleep);
@@ -330,17 +329,9 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
aFrame->mPsdu[-1] = aFrame->mLength; aFrame->mPsdu[-1] = aFrame->mLength;
nrf_802154_channel_set(aFrame->mChannel); nrf_802154_channel_set(aFrame->mChannel);
nrf_802154_transmit_csma_ca_raw(&aFrame->mPsdu[-1]);
if (nrf_802154_transmit_raw(&aFrame->mPsdu[-1], true)) clearPendingEvents();
{ otPlatRadioTxStarted(aInstance, aFrame);
clearPendingEvents();
otPlatRadioTxStarted(aInstance, aFrame);
}
else
{
clearPendingEvents();
setPendingEvent(kPendingEventTransmit);
}
return OT_ERROR_NONE; return OT_ERROR_NONE;
} }
@@ -363,7 +354,7 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
{ {
(void)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) 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 (isPendingEventSet(kPendingEventFrameTransmitted))
{ {
#if OPENTHREAD_ENABLE_DIAG #if OPENTHREAD_ENABLE_DIAG
@@ -605,7 +585,7 @@ void nrf5RadioProcess(otInstance *aInstance)
resetPendingEvent(kPendingEventChannelAccessFailure); resetPendingEvent(kPendingEventChannelAccessFailure);
} }
if (isPendingEventSet(kPendingEventInvalidAck)) if (isPendingEventSet(kPendingEventInvalidOrNoAck))
{ {
#if OPENTHREAD_ENABLE_DIAG #if OPENTHREAD_ENABLE_DIAG
@@ -619,7 +599,7 @@ void nrf5RadioProcess(otInstance *aInstance)
otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NO_ACK); otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NO_ACK);
} }
resetPendingEvent(kPendingEventInvalidAck); resetPendingEvent(kPendingEventInvalidOrNoAck);
} }
if (isPendingEventSet(kPendingEventReceiveFailed)) if (isPendingEventSet(kPendingEventReceiveFailed))
@@ -756,8 +736,9 @@ void nrf_802154_transmit_failed(const uint8_t *aFrame, nrf_802154_tx_error_t err
break; break;
case NRF_802154_TX_ERROR_INVALID_ACK: case NRF_802154_TX_ERROR_INVALID_ACK:
case NRF_802154_TX_ERROR_NO_ACK:
case NRF_802154_TX_ERROR_NO_MEM: case NRF_802154_TX_ERROR_NO_MEM:
setPendingEvent(kPendingEventInvalidAck); setPendingEvent(kPendingEventInvalidOrNoAck);
break; break;
} }
} }