From a718c4e170d7331327a123dfc5f79ba19b976a07 Mon Sep 17 00:00:00 2001 From: Marven Gilhespie <45208741+marvensilabs@users.noreply.github.com> Date: Mon, 28 Oct 2019 21:09:20 +0000 Subject: [PATCH] [efr32] Added otSysEventSignalPending and NVIC configuration to efr32mg21 (#4279) --- examples/platforms/efr32mg21/Makefile.am | 2 ++ examples/platforms/efr32mg21/alarm.c | 1 + examples/platforms/efr32mg21/radio.c | 8 ++++++++ examples/platforms/efr32mg21/system.c | 21 ++++++++++++++++++--- examples/platforms/efr32mg21/uart.c | 3 +++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/examples/platforms/efr32mg21/Makefile.am b/examples/platforms/efr32mg21/Makefile.am index 75fa001ab..da76e076e 100644 --- a/examples/platforms/efr32mg21/Makefile.am +++ b/examples/platforms/efr32mg21/Makefile.am @@ -44,6 +44,8 @@ EFR32MG_SDK_SRCDIR = $(top_srcdir)/third_party/silabs libopenthread_efr32mg21_a_CPPFLAGS = \ -DPLATFORM_HEADER=\"@top_builddir@/third_party/silabs/gecko_sdk_suite/v2.6/platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ + -DEFR32_SERIES2_CONFIG1_MICRO \ + -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -Wno-sign-compare \ -DCORTEXM3 \ -DPHY=EMBER_PHY_RAIL \ diff --git a/examples/platforms/efr32mg21/alarm.c b/examples/platforms/efr32mg21/alarm.c index 4c2c3d9e6..21fe16931 100644 --- a/examples/platforms/efr32mg21/alarm.c +++ b/examples/platforms/efr32mg21/alarm.c @@ -68,6 +68,7 @@ static bool sIsRunning = false; static void RAILCb_TimerExpired(RAIL_Handle_t aHandle) { + otSysEventSignalPending(); } void efr32AlarmInit(void) diff --git a/examples/platforms/efr32mg21/radio.c b/examples/platforms/efr32mg21/radio.c index d1820b0d6..3074fb2e0 100644 --- a/examples/platforms/efr32mg21/radio.c +++ b/examples/platforms/efr32mg21/radio.c @@ -34,6 +34,7 @@ #include +#include "openthread-system.h" #include #include #include @@ -718,6 +719,8 @@ static void processNextRxPacket(otInstance *aInstance) } } + otSysEventSignalPending(); + exit: if (packetHandle != RAIL_RX_PACKET_HANDLE_INVALID) @@ -862,6 +865,8 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents) #endif } } + + otSysEventSignalPending(); } otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) @@ -900,11 +905,14 @@ void efr32RadioProcess(otInstance *aInstance) #if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT sRailDebugCounters.mRailPlatRadioTxDoneCbCount++; #endif + + otSysEventSignalPending(); } else if (sEnergyScanMode == ENERGY_SCAN_MODE_ASYNC && sEnergyScanStatus == ENERGY_SCAN_STATUS_COMPLETED) { sEnergyScanStatus = ENERGY_SCAN_STATUS_IDLE; otPlatRadioEnergyScanDone(aInstance, sEnergyScanResultDbm); + otSysEventSignalPending(); #if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT sRailDebugCounters.mRailEventEnergyScanCompleted++; diff --git a/examples/platforms/efr32mg21/system.c b/examples/platforms/efr32mg21/system.c index dbecf7f20..c02ab874c 100644 --- a/examples/platforms/efr32mg21/system.c +++ b/examples/platforms/efr32mg21/system.c @@ -34,7 +34,7 @@ #include -#include +#include "openthread-system.h" #include #include "common/logging.hpp" @@ -71,10 +71,18 @@ 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(); @@ -83,6 +91,8 @@ void otSysInit(int argc, char *argv[]) wakeupFem(); #endif + __enable_irq(); + #if USE_EFR32_LOG efr32LogInit(); #endif @@ -160,3 +170,8 @@ void otSysProcessDrivers(otInstance *aInstance) efr32RadioProcess(aInstance); efr32AlarmProcess(aInstance); } + +__WEAK void otSysEventSignalPending(void) +{ + // Intentionally empty +} diff --git a/examples/platforms/efr32mg21/uart.c b/examples/platforms/efr32mg21/uart.c index ac7132106..9d93a3b37 100644 --- a/examples/platforms/efr32mg21/uart.c +++ b/examples/platforms/efr32mg21/uart.c @@ -34,6 +34,7 @@ #include +#include "openthread-system.h" #include #include "utils/code_utils.h" @@ -106,11 +107,13 @@ static void receiveDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aDat } UARTDRV_Receive(aHandle, aData, 1, receiveDone); + otSysEventSignalPending(); } static void transmitDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aData, UARTDRV_Count_t aCount) { sTransmitLength = 0; + otSysEventSignalPending(); } static void processReceive(void)