@@ -246,6 +246,15 @@ FUNC_NORETURN static void nrf5_callback_timeout(void)
246
246
CODE_UNREACHABLE ;
247
247
}
248
248
249
+ #if (CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS != 0 )
250
+ static void ed_timer_expired (struct k_timer * timer )
251
+ {
252
+ ARG_UNUSED (timer );
253
+
254
+ nrf5_callback_timeout ();
255
+ }
256
+ #endif /* CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS != 0 */
257
+
249
258
static void nrf5_callback_sem_take (struct k_sem * sem , uint32_t additional_ms )
250
259
{
251
260
if (CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS == 0 ) {
@@ -306,6 +315,14 @@ static int nrf5_energy_scan_start(const struct device *dev,
306
315
if (nrf_802154_energy_detection (duration * 1000 ) == false) {
307
316
nrf5_data .energy_scan_done = NULL ;
308
317
err = - EPERM ;
318
+ } else {
319
+ #if (CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS != 0 )
320
+ struct nrf5_802154_data * nrf5_radio = NRF5_802154_DATA (dev );
321
+
322
+ k_timer_start (& nrf5_radio -> ed_timer ,
323
+ K_MSEC (duration + CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS ),
324
+ K_NO_WAIT );
325
+ #endif
309
326
}
310
327
} else {
311
328
err = - EALREADY ;
@@ -807,6 +824,10 @@ static int nrf5_init(const struct device *dev)
807
824
k_sem_init (& nrf5_radio -> tx_wait , 0 , 1 );
808
825
k_sem_init (& nrf5_radio -> cca_wait , 0 , 1 );
809
826
827
+ #if (CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS != 0 )
828
+ k_timer_init (& nrf5_radio -> ed_timer , ed_timer_expired , NULL );
829
+ #endif
830
+
810
831
nrf_802154_init ();
811
832
812
833
nrf5_get_capabilities_at_boot ();
@@ -1168,6 +1189,10 @@ void nrf_802154_energy_detected(uint8_t result)
1168
1189
int16_t dbm ;
1169
1190
energy_scan_done_cb_t callback = nrf5_data .energy_scan_done ;
1170
1191
1192
+ #if (CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS != 0 )
1193
+ k_timer_stop (& nrf5_data .ed_timer );
1194
+ #endif
1195
+
1171
1196
nrf5_data .energy_scan_done = NULL ;
1172
1197
dbm = nrf_802154_dbm_from_energy_level_calculate (result );
1173
1198
callback (net_if_get_device (nrf5_data .iface ), dbm );
@@ -1179,6 +1204,10 @@ void nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error)
1179
1204
if (nrf5_data .energy_scan_done != NULL ) {
1180
1205
energy_scan_done_cb_t callback = nrf5_data .energy_scan_done ;
1181
1206
1207
+ #if (CONFIG_IEEE802154_NRF5_CALLOUT_TIMEOUT_MS != 0 )
1208
+ k_timer_stop (& nrf5_data .ed_timer );
1209
+ #endif
1210
+
1182
1211
nrf5_data .energy_scan_done = NULL ;
1183
1212
callback (net_if_get_device (nrf5_data .iface ), SHRT_MAX );
1184
1213
}
0 commit comments