Skip to content

Commit 68af78a

Browse files
author
Jędrzej Ciupis
committed
[nrf fromlist] drivers: ieee802154: fix nRF5 Rx error handling
The current implementation implicitly assumes that if the device is configured to have the capability of acting as a CSL endpoint then in case a delayed reception with matching ID finishes with a timeout no action is needed. This assumption is correct when RxOnWhenIdle mode is disabled because the transition to sleep is done automatically by the driver below. However, it's wrong when RxOnWhenIdle is enabled. This commit fixes that case by adding a call to event handler that notifies the higher layer about the event and allows it to transition to RxOff if needed. Upstream PR: zephyrproject-rtos/zephyr#67774 Signed-off-by: Jędrzej Ciupis <[email protected]>
1 parent 9087637 commit 68af78a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ static int nrf5_init(const struct device *dev)
763763

764764
nrf5_get_capabilities_at_boot();
765765

766+
nrf5_radio->rx_on_when_idle = true;
766767
nrf5_radio_cfg->irq_config_func(dev);
767768

768769
k_thread_create(&nrf5_radio->rx_thread, nrf5_radio->rx_stack,
@@ -1003,6 +1004,7 @@ static int nrf5_configure(const struct device *dev,
10031004

10041005
case IEEE802154_CONFIG_RX_ON_WHEN_IDLE:
10051006
nrf_802154_rx_on_when_idle_set(config->rx_on_when_idle);
1007+
nrf5_data.rx_on_when_idle = config->rx_on_when_idle;
10061008
break;
10071009

10081010
default:
@@ -1083,7 +1085,13 @@ void nrf_802154_receive_failed(nrf_802154_rx_error_t error, uint32_t id)
10831085

10841086
#if defined(CONFIG_IEEE802154_CSL_ENDPOINT)
10851087
if (id == DRX_SLOT_RX && error == NRF_802154_RX_ERROR_DELAYED_TIMEOUT) {
1086-
return;
1088+
if (!nrf5_data.rx_on_when_idle) {
1089+
/* Transition to RxOff done automatically by the driver */
1090+
return;
1091+
} else if (nrf5_data.event_handler) {
1092+
/* Notify the higher layer to allow it to transition if needed */
1093+
nrf5_data.event_handler(dev, IEEE802154_EVENT_RX_OFF, NULL);
1094+
}
10871095
}
10881096
#else
10891097
ARG_UNUSED(id);

drivers/ieee802154/ieee802154_nrf5.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ struct nrf5_802154_data {
110110
/* The last configured value of CSL phase time in nanoseconds. */
111111
net_time_t csl_rx_time;
112112
#endif /* CONFIG_NRF_802154_SER_HOST && CONFIG_IEEE802154_CSL_ENDPOINT */
113+
114+
/* Indicates if RxOnWhenIdle mode is enabled. */
115+
bool rx_on_when_idle;
113116
};
114117

115118
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_NRF5_H_ */

0 commit comments

Comments
 (0)