From cdc772759e8b040e57c74ac169cc60cd98ff86a1 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Tue, 10 Jul 2018 00:05:46 +0800 Subject: [PATCH] [nrf52840] avoid unexpected transmit done callback after pseudo reset (#2862) Introduce a nrf5RadioPseudoReset() method, it will put the radio to sleep mode, and clear the pending events during pseudo reset. So to avoid unexpected transmit done callback after pseudo reset, which may cause the device to hang. --- examples/platforms/nrf52840/platform-nrf5.h | 6 ++++++ examples/platforms/nrf52840/platform.c | 1 + examples/platforms/nrf52840/radio.c | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/examples/platforms/nrf52840/platform-nrf5.h b/examples/platforms/nrf52840/platform-nrf5.h index 024eb7677..2820fe272 100644 --- a/examples/platforms/nrf52840/platform-nrf5.h +++ b/examples/platforms/nrf52840/platform-nrf5.h @@ -148,6 +148,12 @@ void nrf5RadioInit(void); */ void nrf5RadioDeinit(void); +/** + * Pseudo reset Radio driver. + * + */ +void nrf5RadioPseudoReset(void); + /** * Function for processing Radio. * diff --git a/examples/platforms/nrf52840/platform.c b/examples/platforms/nrf52840/platform.c index 9bbc38513..e1d5ec9da 100644 --- a/examples/platforms/nrf52840/platform.c +++ b/examples/platforms/nrf52840/platform.c @@ -55,6 +55,7 @@ void PlatformInit(int argc, char *argv[]) if (gPlatformPseudoResetWasRequested) { + nrf5RadioPseudoReset(); nrf5AlarmDeinit(); nrf5AlarmInit(); diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c index 4e38eaaf9..f1c6f4410 100644 --- a/examples/platforms/nrf52840/radio.c +++ b/examples/platforms/nrf52840/radio.c @@ -227,6 +227,12 @@ void nrf5RadioDeinit(void) nrf_802154_deinit(); } +void nrf5RadioPseudoReset(void) +{ + nrf_802154_sleep(); + sPendingEvents = 0; +} + otRadioState otPlatRadioGetState(otInstance *aInstance) { (void)aInstance;