diff --git a/examples/platforms/efr32mg12/Makefile.am b/examples/platforms/efr32mg12/Makefile.am index 8c3668051..72354f670 100644 --- a/examples/platforms/efr32mg12/Makefile.am +++ b/examples/platforms/efr32mg12/Makefile.am @@ -46,6 +46,7 @@ libopenthread_efr32mg12_a_CPPFLAGS = -D__START=main \ -D__STARTUP_CLEAR_BSS \ -DPLATFORM_HEADER=\"@top_builddir@/third_party/silabs/gecko_sdk_suite/v2.6/platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ + -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -Wno-sign-compare \ -DCORTEXM3 \ -DPHY=EMBER_PHY_RAIL \ diff --git a/examples/platforms/efr32mg12/alarm.c b/examples/platforms/efr32mg12/alarm.c index 9ae66e57a..d031fbeee 100644 --- a/examples/platforms/efr32mg12/alarm.c +++ b/examples/platforms/efr32mg12/alarm.c @@ -36,6 +36,7 @@ #include #include +#include "openthread-system.h" #include #include #include @@ -67,6 +68,7 @@ static bool sIsRunning = false; static void RAILCb_TimerExpired(RAIL_Handle_t aHandle) { + otSysEventSignalPending(); } void efr32AlarmInit(void) diff --git a/examples/platforms/efr32mg12/radio.c b/examples/platforms/efr32mg12/radio.c index 204f41d0a..f31992344 100644 --- a/examples/platforms/efr32mg12/radio.c +++ b/examples/platforms/efr32mg12/radio.c @@ -34,6 +34,7 @@ #include +#include "openthread-system.h" #include #include #include @@ -55,7 +56,6 @@ #include "rail.h" #include "rail_config.h" #include "rail_ieee802154.h" -#include "rtcdriver.h" enum { @@ -289,7 +289,7 @@ void efr32RadioInit(void) efr32ConfigInit(RAILCb_Generic); CMU_ClockEnable(cmuClock_PRS, true); - RTCDRV_Init(); + status = RAIL_ConfigSleep(gRailHandle, RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED); assert(status == RAIL_STATUS_NO_ERROR); @@ -704,6 +704,8 @@ static void processNextRxPacket(otInstance *aInstance) } } + otSysEventSignalPending(); + exit: if (packetHandle != RAIL_RX_PACKET_HANDLE_INVALID) @@ -801,6 +803,8 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents) sEnergyScanResultDbm = energyScanResultQuarterDbm / QUARTER_DBM_IN_DBM; } } + + otSysEventSignalPending(); } otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) @@ -835,11 +839,14 @@ void efr32RadioProcess(otInstance *aInstance) { otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError); } + + otSysEventSignalPending(); } else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) { sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm); + otSysEventSignalPending(); } processNextRxPacket(aInstance); diff --git a/examples/platforms/efr32mg12/system.c b/examples/platforms/efr32mg12/system.c index dff36008f..d51c464ce 100644 --- a/examples/platforms/efr32mg12/system.c +++ b/examples/platforms/efr32mg12/system.c @@ -34,6 +34,7 @@ #include +#include "openthread-system.h" #include #include @@ -70,17 +71,28 @@ void otSysInit(int argc, char *argv[]) OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + __disable_irq(); + +#undef FIXED_EXCEPTION +#define FIXED_EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler) +#define EXCEPTION(vectorNumber, functionName, deviceIrqn, deviceIrqHandler, priorityLevel, subpriority) \ + NVIC_SetPriority(deviceIrqn, NVIC_EncodePriority(PRIGROUP_POSITION, priorityLevel, subpriority)); +#include NVIC_CONFIG +#undef EXCEPTION + + NVIC_SetPriorityGrouping(PRIGROUP_POSITION); CHIP_Init(); - halInitChipSpecific(); - BSP_Init(BSP_INIT_BCC); + RTCDRV_Init(); #if (HAL_FEM_ENABLE) initFem(); wakeupFem(); #endif + __enable_irq(); + #if USE_EFR32_LOG efr32LogInit(); #endif @@ -153,3 +165,8 @@ void otSysProcessDrivers(otInstance *aInstance) efr32RadioProcess(aInstance); efr32AlarmProcess(aInstance); } + +__WEAK void otSysEventSignalPending(void) +{ + // Intentionally empty +} diff --git a/examples/platforms/efr32mg12/uart.c b/examples/platforms/efr32mg12/uart.c index 8402acca4..36858acd8 100644 --- a/examples/platforms/efr32mg12/uart.c +++ b/examples/platforms/efr32mg12/uart.c @@ -34,6 +34,7 @@ #include +#include "openthread-system.h" #include #include "utils/code_utils.h" @@ -132,6 +133,8 @@ static void receiveDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aDat assert(sReceiveDeferred == false); sReceiveDeferred = true; } + + otSysEventSignalPending(); } static inline bool isBufferEmpty(uint16_t unwrappedReadStart, uint16_t unwrappedReadEnd) @@ -180,6 +183,7 @@ exit: static void transmitDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aData, UARTDRV_Count_t aCount) { sTransmitLength = 0; + otSysEventSignalPending(); } static void processReceive(void)