mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 14:59:54 +00:00
[nrf52840] reinitialize all peripherals except uart for pseudo reset (#2878)
There are some problems if radio is not reinitialized during pseudo reset: * It may trigger unexpected otPlatRadioTxDone(), and cause the device to hang; * The uncleared radio timer queue is invalid, it may block the new added timer which has a larger targer time. Note: The clock init/deinit is disabled during radio init/deinit.
This commit is contained in:
@@ -148,12 +148,6 @@ void nrf5RadioInit(void);
|
||||
*/
|
||||
void nrf5RadioDeinit(void);
|
||||
|
||||
/**
|
||||
* Pseudo reset Radio driver.
|
||||
*
|
||||
*/
|
||||
void nrf5RadioPseudoReset(void);
|
||||
|
||||
/**
|
||||
* Function for processing Radio.
|
||||
*
|
||||
|
||||
@@ -38,11 +38,14 @@
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
#include "platform.h"
|
||||
#include <drivers/clock/nrf_drv_clock.h>
|
||||
#include <nrf.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
|
||||
extern bool gPlatformPseudoResetWasRequested;
|
||||
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1)
|
||||
@@ -51,17 +54,9 @@ void __cxa_pure_virtual(void)
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
extern bool gPlatformPseudoResetWasRequested;
|
||||
|
||||
if (gPlatformPseudoResetWasRequested)
|
||||
{
|
||||
nrf5RadioPseudoReset();
|
||||
nrf5AlarmDeinit();
|
||||
nrf5AlarmInit();
|
||||
|
||||
gPlatformPseudoResetWasRequested = false;
|
||||
|
||||
return;
|
||||
PlatformDeinit();
|
||||
}
|
||||
|
||||
(void)argc;
|
||||
@@ -80,7 +75,10 @@ void PlatformInit(int argc, char *argv[])
|
||||
#endif
|
||||
nrf5AlarmInit();
|
||||
nrf5RandomInit();
|
||||
nrf5UartInit();
|
||||
if (!gPlatformPseudoResetWasRequested)
|
||||
{
|
||||
nrf5UartInit();
|
||||
}
|
||||
#ifndef SPIS_TRANSPORT_DISABLE
|
||||
nrf5SpiSlaveInit();
|
||||
#endif
|
||||
@@ -88,6 +86,8 @@ void PlatformInit(int argc, char *argv[])
|
||||
nrf5CryptoInit();
|
||||
nrf5RadioInit();
|
||||
nrf5TempInit();
|
||||
|
||||
gPlatformPseudoResetWasRequested = false;
|
||||
}
|
||||
|
||||
void PlatformDeinit(void)
|
||||
@@ -99,7 +99,10 @@ void PlatformDeinit(void)
|
||||
#ifndef SPIS_TRANSPORT_DISABLE
|
||||
nrf5SpiSlaveDeinit();
|
||||
#endif
|
||||
nrf5UartDeinit();
|
||||
if (!gPlatformPseudoResetWasRequested)
|
||||
{
|
||||
nrf5UartDeinit();
|
||||
}
|
||||
nrf5RandomDeinit();
|
||||
nrf5AlarmDeinit();
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED) || \
|
||||
@@ -110,7 +113,6 @@ void PlatformDeinit(void)
|
||||
|
||||
bool PlatformPseudoResetWasRequested(void)
|
||||
{
|
||||
extern bool gPlatformPseudoResetWasRequested;
|
||||
return gPlatformPseudoResetWasRequested;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,13 +223,9 @@ void nrf5RadioInit(void)
|
||||
}
|
||||
|
||||
void nrf5RadioDeinit(void)
|
||||
{
|
||||
nrf_802154_deinit();
|
||||
}
|
||||
|
||||
void nrf5RadioPseudoReset(void)
|
||||
{
|
||||
nrf_802154_sleep();
|
||||
nrf_802154_deinit();
|
||||
sPendingEvents = 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -65,12 +65,12 @@ static void clock_handler(nrf_drv_clock_evt_type_t event)
|
||||
|
||||
void nrf_802154_clock_init(void)
|
||||
{
|
||||
nrf_drv_clock_init();
|
||||
// Intentionally empty.
|
||||
}
|
||||
|
||||
void nrf_802154_clock_deinit(void)
|
||||
{
|
||||
nrf_drv_clock_uninit();
|
||||
// Intentionally empty.
|
||||
}
|
||||
|
||||
void nrf_802154_clock_hfclk_start(void)
|
||||
|
||||
Reference in New Issue
Block a user