Skip to content

Commit 5d8ee84

Browse files
eriksandgrencursoragent
authored andcommitted
samples: radio_test: Handle CRCOK before PHYEND in radio_handler
Reorder radio_handler event checks so CRCOK runs before PHYEND. When both events are pending in one ISR, packet counting and RX timeout updates run before PHYEND restart handling. Signed-off-by: Erik Sandgren <erik.sandgren@nordicsemi.no> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 9d4508a commit 5d8ee84

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

samples/peripheral/radio_test/src/radio_test.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,19 +1422,6 @@ void radio_handler(const void *context)
14221422
const struct radio_test_config *config =
14231423
(const struct radio_test_config *) context;
14241424

1425-
#if defined(RADIO_INTENSET_PHYEND_Msk) || defined(RADIO_INTENSET00_PHYEND_Msk)
1426-
/* PHYEND is handled ahead of the packet handling below because on EasyVDMA targets this
1427-
* is where reception is restarted. The transmitter sends packets back to back, so every
1428-
* microsecond between one packet ending and the radio listening again risks missing the
1429-
* next one, and the shorter the packet the more that costs.
1430-
*/
1431-
if (nrf_radio_int_enable_check(NRF_RADIO, NRF_RADIO_INT_PHYEND_MASK) &&
1432-
nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_PHYEND)) {
1433-
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_PHYEND);
1434-
on_radio_phyend(config);
1435-
}
1436-
#endif /* defined(RADIO_INTENSET_PHYEND_Msk) || defined(RADIO_INTENSET00_PHYEND_Msk) */
1437-
14381425
if (nrf_radio_int_enable_check(NRF_RADIO, NRF_RADIO_INT_CRCOK_MASK) &&
14391426
nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_CRCOK)) {
14401427
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_CRCOK);
@@ -1450,11 +1437,20 @@ void radio_handler(const void *context)
14501437
*/
14511438
k_work_reschedule(&rx_timeout_work, K_MSEC(RX_PACKET_TIMEOUT_MS));
14521439
} else {
1453-
deferred_timeout_reschedule = true;
1440+
deferred_rx_timeout_reschedule = true;
14541441
}
14551442
}
14561443
}
14571444

1445+
#if defined(RADIO_INTENSET_PHYEND_Msk) || defined(RADIO_INTENSET00_PHYEND_Msk)
1446+
if (nrf_radio_int_enable_check(NRF_RADIO, NRF_RADIO_INT_PHYEND_MASK) &&
1447+
nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_PHYEND)) {
1448+
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_PHYEND);
1449+
on_radio_phyend(config);
1450+
}
1451+
#endif /* defined(RADIO_INTENSET_PHYEND_Msk) || defined(RADIO_INTENSET00_PHYEND_Msk) */
1452+
1453+
14581454
if (nrf_radio_int_enable_check(NRF_RADIO, NRF_RADIO_INT_END_MASK) &&
14591455
nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_END)) {
14601456
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_END);

0 commit comments

Comments
 (0)