Skip to content

Commit 793180f

Browse files
ankunsrlubos
authored andcommitted
[nrf noup] drivers: ieee802154_nrf5: add polling of radio driver
Add Kconfig `IEEE802154_NRF5_RX_THREAD_HEARTBEAT_PERIOD_MS` to control polling of the nRF 802.15.4 radio driver. This option is to detect any malfunctions of the radio driver or the core it is running when the driver is serialized. Signed-off-by: Andrzej Kuros <[email protected]>
1 parent 8a557b6 commit 793180f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

drivers/ieee802154/Kconfig.nrf5

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ config IEEE802154_NRF5_CALLOUT_TIMEOUT_MS
8989
Set this value to 0 to have no limit (equivalent to K_FOREVER) which turns off the
9090
timing-out feature.
9191

92+
config IEEE802154_NRF5_RX_THREAD_HEARTBEAT_PERIOD_MS
93+
int "Period in milliseconds of polling nRF 802.15.4 Radio Driver to detect potential malfunctions"
94+
default 60000 if NRF_802154_SER_HOST
95+
default 0
96+
help
97+
The nRF 802.15.4 Radio Driver is polled with period set by this parameter in order to
98+
detect any potential malfunctions of the driver. This option is useful when
99+
the radio driver implementation is provided by separate core through serialization.
100+
To keep energy usage low the value should be set to big values.
101+
Value equal to 0 turns off the polling completely.
102+
92103
config IEEE802154_NRF5_LOG_RX_FAILURES
93104
bool "Frame reception failures logging"
94105
help

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
204204
{
205205
struct nrf5_802154_data *nrf5_radio = (struct nrf5_802154_data *)arg1;
206206
struct nrf5_802154_rx_frame *rx_frame;
207+
uint64_t last_heartbeat_timestamp = 0;
207208

208209
ARG_UNUSED(arg2);
209210
ARG_UNUSED(arg3);
@@ -213,10 +214,26 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
213214

214215
LOG_DBG("Waiting for frame");
215216

216-
rx_frame = k_fifo_get(&nrf5_radio->rx_fifo, K_FOREVER);
217+
rx_frame = k_fifo_get(&nrf5_radio->rx_fifo,
218+
(CONFIG_IEEE802154_NRF5_RX_THREAD_HEARTBEAT_PERIOD_MS != 0) ?
219+
K_MSEC(CONFIG_IEEE802154_NRF5_RX_THREAD_HEARTBEAT_PERIOD_MS) :
220+
K_FOREVER);
217221

218222
if (rx_frame != NULL) {
219223
nrf5_rx_frame_process(nrf5_radio, rx_frame);
224+
} else if (CONFIG_IEEE802154_NRF5_RX_THREAD_HEARTBEAT_PERIOD_MS != 0) {
225+
/* No frame was received long enough.
226+
* If core implementing the function below is dead, there will be
227+
* serialization error.
228+
*/
229+
uint64_t ts = nrf_802154_time_get();
230+
231+
if (ts < last_heartbeat_timestamp) {
232+
/* The core providing nRF 802.15.4 has been reset silently */
233+
__ASSERT(false, "802.15.4 heartbeat failure");
234+
k_oops();
235+
}
236+
last_heartbeat_timestamp = ts;
220237
}
221238
}
222239
}

0 commit comments

Comments
 (0)