diff --git a/config/efr32/lib/pw_rpc/BUILD.gn b/config/efr32/lib/pw_rpc/BUILD.gn index 32a95488dbdf30..ed2e3a47bc1305 100644 --- a/config/efr32/lib/pw_rpc/BUILD.gn +++ b/config/efr32/lib/pw_rpc/BUILD.gn @@ -24,7 +24,7 @@ static_library("pw_rpc") { public_deps = [ "$dir_pw_rpc:server", "$dir_pw_rpc/nanopb:echo_service", - "${chip_root}/examples/platform/silabs/efr32/pw_sys_io:pw_sys_io_efr32", + "${chip_root}/examples/platform/silabs/pw_sys_io:pw_sys_io_silabs", "${dir_pigweed}/pw_hdlc:pw_rpc", dir_pw_assert, dir_pw_checksum, diff --git a/config/efr32/lib/pw_rpc/pw_rpc.gni b/config/efr32/lib/pw_rpc/pw_rpc.gni index a72cb4d90f6dd1..101112c12dadc9 100644 --- a/config/efr32/lib/pw_rpc/pw_rpc.gni +++ b/config/efr32/lib/pw_rpc/pw_rpc.gni @@ -19,7 +19,7 @@ pw_log_BACKEND = "$dir_pw_log_basic" pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" pw_sys_io_BACKEND = - "${chip_root}/examples/platform/silabs/efr32/pw_sys_io:pw_sys_io_efr32" + "${chip_root}/examples/platform/silabs/pw_sys_io:pw_sys_io_silabs" pw_build_LINK_DEPS = [ "$dir_pw_assert:impl", diff --git a/examples/chef/silabs/BUILD.gn b/examples/chef/silabs/BUILD.gn index a7a30e2c6396f8..cecef1c71bc050 100644 --- a/examples/chef/silabs/BUILD.gn +++ b/examples/chef/silabs/BUILD.gn @@ -56,7 +56,7 @@ chip_data_model("chef-common") { efr32_sdk("sdk") { sources = [ "${efr32_project_dir}/include/CHIPProjectConfig.h", - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", ] include_dirs = [ @@ -133,7 +133,7 @@ silabs_executable("chef_app") { "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", "${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc", "${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc", - "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32", + "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs", ] deps += pw_build_LINK_DEPS @@ -144,7 +144,7 @@ silabs_executable("chef_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/light-switch-app/silabs/BUILD.gn b/examples/light-switch-app/silabs/BUILD.gn index 0707f6dbf52622..fc52c0b96b03b7 100644 --- a/examples/light-switch-app/silabs/BUILD.gn +++ b/examples/light-switch-app/silabs/BUILD.gn @@ -52,7 +52,7 @@ declare_args() { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -75,7 +75,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -170,7 +170,7 @@ silabs_executable("light_switch_app") { if (wifi_soc) { deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] } else { - deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ] + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] } deps += pw_build_LINK_DEPS @@ -181,7 +181,7 @@ silabs_executable("light_switch_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/lighting-app/silabs/BUILD.gn b/examples/lighting-app/silabs/BUILD.gn index 63a206ee8ffaab..9c314b025f63fd 100644 --- a/examples/lighting-app/silabs/BUILD.gn +++ b/examples/lighting-app/silabs/BUILD.gn @@ -68,7 +68,7 @@ if (slc_generate) { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -91,7 +91,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -191,7 +191,7 @@ silabs_executable("lighting_app") { if (wifi_soc) { deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] } else { - deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ] + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] } deps += pw_build_LINK_DEPS @@ -202,7 +202,7 @@ silabs_executable("lighting_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/lock-app/silabs/BUILD.gn b/examples/lock-app/silabs/BUILD.gn index f4bf7db01c2612..f5d00f7d48ab63 100644 --- a/examples/lock-app/silabs/BUILD.gn +++ b/examples/lock-app/silabs/BUILD.gn @@ -52,7 +52,7 @@ declare_args() { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -75,7 +75,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -172,7 +172,7 @@ silabs_executable("lock_app") { if (wifi_soc) { deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] } else { - deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ] + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] } deps += pw_build_LINK_DEPS @@ -183,7 +183,7 @@ silabs_executable("lock_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp similarity index 99% rename from examples/platform/silabs/efr32/BaseApplication.cpp rename to examples/platform/silabs/BaseApplication.cpp index 77a91236554ae5..b0d1dd0ea8a414 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -242,7 +242,12 @@ CHIP_ERROR BaseApplication::Init() } PlatformMgr().AddEventHandler(OnPlatformEvent, 0); +#ifdef SL_WIFI + sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); +#endif /* SL_WIFI */ +#if CHIP_ENABLE_OPENTHREAD sIsProvisioned = ConnectivityMgr().IsThreadProvisioned(); +#endif return err; } diff --git a/examples/platform/silabs/efr32/BaseApplication.h b/examples/platform/silabs/BaseApplication.h similarity index 99% rename from examples/platform/silabs/efr32/BaseApplication.h rename to examples/platform/silabs/BaseApplication.h index f2bc073c4ee9b2..9e99580811293c 100644 --- a/examples/platform/silabs/efr32/BaseApplication.h +++ b/examples/platform/silabs/BaseApplication.h @@ -29,6 +29,7 @@ #include "AppEvent.h" #include "FreeRTOS.h" #include "timers.h" // provides FreeRTOS timer support +#include #include #include #include @@ -47,10 +48,6 @@ #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED -#ifndef SL_STATUS_LED -#define SL_STATUS_LED 1 -#endif - /********************************************************** * Defines *********************************************************/ diff --git a/examples/platform/silabs/efr32/FreeRTOSConfig.h b/examples/platform/silabs/FreeRTOSConfig.h similarity index 100% rename from examples/platform/silabs/efr32/FreeRTOSConfig.h rename to examples/platform/silabs/FreeRTOSConfig.h diff --git a/examples/platform/silabs/efr32/matter_config.cpp b/examples/platform/silabs/MatterConfig.cpp similarity index 96% rename from examples/platform/silabs/efr32/matter_config.cpp rename to examples/platform/silabs/MatterConfig.cpp index c876abd6eaea1b..9c2253233f79e7 100644 --- a/examples/platform/silabs/efr32/matter_config.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -19,7 +19,7 @@ #include "AppConfig.h" #include "OTAConfig.h" -#include +#include #include @@ -165,6 +165,12 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) SILABS_LOG("Init CHIP Stack"); // Init Chip memory management before the stack ReturnErrorOnFailure(chip::Platform::MemoryInit()); + +// WiFi needs to be initialized after Memory Init for some reason +#ifdef SL_WIFI + InitWiFi(); +#endif + ReturnErrorOnFailure(PlatformMgr().InitChipStack()); SetDeviceInstanceInfoProvider(&Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider()); @@ -231,10 +237,6 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) SILABS_LOG("Starting Platform Manager Event Loop"); ReturnErrorOnFailure(PlatformMgr().StartEventLoopTask()); -#ifdef SL_WIFI - InitWiFi(); -#endif - #ifdef ENABLE_CHIP_SHELL chip::startShellTask(); #endif @@ -251,15 +253,14 @@ void SilabsMatterConfig::InitWiFi(void) #ifdef SL_WFX_USE_SECURE_LINK wfx_securelink_task_start(); // start securelink key renegotiation task #endif // SL_WFX_USE_SECURE_LINK -#endif /* WF200_WIFI */ - -#ifdef RS911X_WIFI - /* - * Start up any RSI interface stuff - * (Not required) - Note that wfx_wifi_start will deal with - * starting up a rsi task - which will initialize the SPI interface. - */ -#endif +#elif defined(SIWX_917) + SILABS_LOG("Init RSI 917 Platform"); + if (wfx_rsi_platform() != SL_STATUS_OK) + { + SILABS_LOG("RSI init failed"); + return CHIP_ERROR_INTERNAL; + } +#endif /* WF200_WIFI */ } #endif // SL_WIFI diff --git a/examples/platform/silabs/matter_config.h b/examples/platform/silabs/MatterConfig.h similarity index 100% rename from examples/platform/silabs/matter_config.h rename to examples/platform/silabs/MatterConfig.h diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 392663f7b16624..3fd6164b576ea1 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -247,7 +247,9 @@ source_set("siwx917-common") { ] sources = [ + "${silabs_common_plat_dir}/BaseApplication.cpp", "${silabs_common_plat_dir}/LEDWidget.cpp", + "${silabs_common_plat_dir}/MatterConfig.cpp", "${silabs_common_plat_dir}/SoftwareFaultReports.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/silabs_utils.cpp", @@ -256,11 +258,8 @@ source_set("siwx917-common") { "${wifi_sdk_dir}/ethernetif.cpp", "${wifi_sdk_dir}/lwip_netif.cpp", "${wifi_sdk_dir}/wfx_notify.cpp", - "BaseApplication.cpp", "SiWx917/rsi_if.c", "SiWx917/wfx_rsi_host.c", - "init_ccpPlatform.cpp", - "matter_config.cpp", ] if (chip_enable_pw_rpc || chip_build_libshell) { diff --git a/examples/platform/silabs/SiWx917/BaseApplication.cpp b/examples/platform/silabs/SiWx917/BaseApplication.cpp deleted file mode 100644 index feab970b95fe5b..00000000000000 --- a/examples/platform/silabs/SiWx917/BaseApplication.cpp +++ /dev/null @@ -1,637 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/********************************************************** - * Includes - *********************************************************/ - -#include "AppConfig.h" -#include "AppEvent.h" -#include "AppTask.h" - -#include "LEDWidget.h" - -#ifdef DISPLAY_ENABLED -#include "lcd.h" -#ifdef QR_CODE_ENABLED -#include "qrcodegen.h" -#endif // QR_CODE_ENABLED -#endif // DISPLAY_ENABLED - -#include "SilabsDeviceDataProvider.h" -#include "rsi_board.h" -#include "rsi_chip.h" -#include "silabs_utils.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef SL_WIFI -#include "wfx_host_events.h" -#include -#include -#endif // SL_WIFI - -/********************************************************** - * Defines and Constants - *********************************************************/ - -#define FACTORY_RESET_TRIGGER_TIMEOUT 7000 -#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define FACTORY_RESET_LOOP_COUNT 5 -#ifndef APP_TASK_STACK_SIZE -#define APP_TASK_STACK_SIZE (4096) -#endif -#define APP_TASK_PRIORITY 2 -#define APP_EVENT_QUEUE_SIZE 10 -#define EXAMPLE_VENDOR_ID 0xcafe -#define APP_STATE_LED 0 - -using namespace chip; -using namespace chip::app; -using namespace ::chip::DeviceLayer; -using namespace ::chip::DeviceLayer::Silabs; - -namespace { - -/********************************************************** - * Variable declarations - *********************************************************/ - -TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. -TimerHandle_t sLightTimer; - -TaskHandle_t sAppTaskHandle; -QueueHandle_t sAppEventQueue; - -LEDWidget sStatusLED; - -#ifdef SL_WIFI -app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::SlWiFiDriver::GetInstance())); -#endif /* SL_WIFI */ - -#if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER) - -bool sIsProvisioned = false; -bool sIsEnabled = false; -bool sIsAttached = false; -bool sHaveBLEConnections = false; - -#endif // CHIP_CONFIG_ENABLE_ICD_SERVER - -uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(AppEvent)]; -StaticQueue_t sAppEventQueueStruct; - -StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t appTaskStruct; - -BaseApplication::Function_t mFunction; -bool mFunctionTimerActive; - -#ifdef DISPLAY_ENABLED -SilabsLCD slLCD; -#endif - -#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER -Clusters::Identify::EffectIdentifierEnum sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect; - -Identify gIdentify = { - chip::EndpointId{ 1 }, - BaseApplication::OnIdentifyStart, - BaseApplication::OnIdentifyStop, - Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator, - BaseApplication::OnTriggerIdentifyEffect, -}; - -#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER -} // namespace - -/********************************************************** - * AppTask Definitions - *********************************************************/ - -CHIP_ERROR BaseApplication::StartAppTask(TaskFunction_t taskFunction) -{ - sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct); - if (sAppEventQueue == NULL) - { - SILABS_LOG("Failed to allocate app event queue"); - appError(APP_ERROR_EVENT_QUEUE_FAILED); - } - - // Start App task. - sAppTaskHandle = - xTaskCreateStatic(taskFunction, APP_TASK_NAME, ArraySize(appStack), &sAppEventQueue, 1, appStack, &appTaskStruct); - if (sAppTaskHandle == nullptr) - { - SILABS_LOG("Failed to create app task"); - appError(APP_ERROR_CREATE_TASK_FAILED); - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR BaseApplication::Init() -{ - CHIP_ERROR err = CHIP_NO_ERROR; - -#ifdef SL_WIFI - /* - * Wait for the WiFi to be initialized - */ - SILABS_LOG("APP: Wait WiFi Init"); - while (!wfx_hw_ready()) - { - vTaskDelay(10); - } - SILABS_LOG("APP: Done WiFi Init"); - /* We will init server when we get IP */ - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - sWiFiNetworkCommissioningInstance.Init(); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - -#endif - - // Create FreeRTOS sw timer for Function Selection. - sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel - pdMS_TO_TICKS(1), // == default timer period - false, // no timer reload (==one-shot) - (void *) this, // init timer id = app task obj context - FunctionTimerEventHandler // timer callback handler - ); - if (sFunctionTimer == NULL) - { - SILABS_LOG("funct timer create failed"); - appError(APP_ERROR_CREATE_TIMER_FAILED); - } - - // Create FreeRTOS sw timer for LED Management. - sLightTimer = xTimerCreate("LightTmr", // Text Name - pdMS_TO_TICKS(10), // Default timer period - true, // reload timer - (void *) this, // Timer Id - LightTimerEventHandler // Timer callback handler - ); - if (sLightTimer == NULL) - { - SILABS_LOG("Light Timer create failed"); - appError(APP_ERROR_CREATE_TIMER_FAILED); - } - - SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); - SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - - sStatusLED.Init(APP_STATE_LED); - - ConfigurationMgr().LogDeviceConfig(); - - // Create buffer for QR code that can fit max size and null terminator. - char qrCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; - chip::MutableCharSpan QRCode(qrCodeBuffer); - - if (Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider().GetSetupPayload(QRCode) == CHIP_NO_ERROR) - { - // Print setup info on LCD if available -#ifdef QR_CODE_ENABLED - slLCD.SetQRCode((uint8_t *) QRCode.data(), QRCode.size()); - slLCD.ShowQRCode(true, true); -#else - PrintQrCodeURL(QRCode); -#endif // QR_CODE_ENABLED - } - else - { - SILABS_LOG("Getting QR code failed!"); - } - - return err; -} - -void BaseApplication::FunctionTimerEventHandler(TimerHandle_t xTimer) -{ - AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.TimerEvent.Context = (void *) xTimer; - event.Handler = FunctionEventHandler; - PostEvent(&event); -} - -void BaseApplication::FunctionEventHandler(AppEvent * aEvent) -{ - if (aEvent->Type != AppEvent::kEventType_Timer) - { - return; - } -} - -void BaseApplication::FunctionFactoryReset(void) -{ - SILABS_LOG("#################################################################"); - SILABS_LOG("################### Factory reset triggered #####################"); - SILABS_LOG("#################################################################"); - - // Actually trigger Factory Reset - mFunction = kFunction_NoneSelected; - -#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 - StopStatusLEDTimer(); -#endif // CHIP_CONFIG_ENABLE_ICD_SERVER - - chip::Server::GetInstance().ScheduleFactoryReset(); -} - -bool BaseApplication::ActivateStatusLedPatterns() -{ - bool isPatternSet = false; -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER - if (gIdentify.mActive) - { - // Identify in progress - // Do a steady blink on the status led - sStatusLED.Blink(250, 250); - isPatternSet = true; - } - else if (sIdentifyEffect != Clusters::Identify::EffectIdentifierEnum::kStopEffect) - { - // Identify trigger effect received. Do some on/off patterns on the status led - if (sIdentifyEffect == Clusters::Identify::EffectIdentifierEnum::kBlink) - { - // Fast blink - sStatusLED.Blink(50, 50); - } - else if (sIdentifyEffect == Clusters::Identify::EffectIdentifierEnum::kBreathe) - { - // Slow blink - sStatusLED.Blink(1000, 1000); - } - else if (sIdentifyEffect == Clusters::Identify::EffectIdentifierEnum::kOkay) - { - // Pulse effect - sStatusLED.Blink(300, 700); - } - else if (sIdentifyEffect == Clusters::Identify::EffectIdentifierEnum::kChannelChange) - { - // Alternate between Short and Long pulses effect - static uint64_t mLastChangeTimeMS = 0; - static bool alternatePattern = false; - uint32_t onTimeMS = alternatePattern ? 50 : 700; - uint32_t offTimeMS = alternatePattern ? 950 : 300; - - uint64_t nowMS = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - if (nowMS >= mLastChangeTimeMS + 1000) // each pattern is done over a 1 second period - { - mLastChangeTimeMS = nowMS; - alternatePattern = !alternatePattern; - sStatusLED.Blink(onTimeMS, offTimeMS); - } - } - isPatternSet = true; - } -#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER - -#if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER) - // Identify Patterns have priority over Status patterns - if (!isPatternSet) - { - // Apply different status feedbacks - if (sIsProvisioned && sIsEnabled) - { - if (sIsAttached) - { - sStatusLED.Set(true); - } - else - { - sStatusLED.Blink(950, 50); - } - } - else if (sHaveBLEConnections) - { - sStatusLED.Blink(100, 100); - } - else - { - sStatusLED.Blink(50, 950); - } - isPatternSet = true; - } -#endif // CHIP_CONFIG_ENABLE_ICD_SERVER -#endif // ENABLE_WSTK_LEDS) && SL_CATALOG_SIMPLE_LED_LED1_PRESENT - return isPatternSet; -} - -void BaseApplication::LightEventHandler() -{ - // Collect connectivity and configuration state from the CHIP stack. Because - // the CHIP event loop is being run in a separate task, the stack must be - // locked while these values are queried. However we use a non-blocking - // lock request (TryLockCHIPStack()) to avoid blocking other UI activities - // when the CHIP task is busy (e.g. with a long crypto operation). -#if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER) - if (PlatformMgr().TryLockChipStack()) - { -#ifdef SL_WIFI - sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); - sIsEnabled = ConnectivityMgr().IsWiFiStationEnabled(); - sIsAttached = ConnectivityMgr().IsWiFiStationConnected(); -#endif /* SL_WIFI */ -#if CHIP_ENABLE_OPENTHREAD - sIsProvisioned = ConnectivityMgr().IsThreadProvisioned(); - sIsEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsAttached = ConnectivityMgr().IsThreadAttached(); -#endif /* CHIP_ENABLE_OPENTHREAD */ - sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); - PlatformMgr().UnlockChipStack(); - } -#endif // CHIP_CONFIG_ENABLE_ICD_SERVER - - // Update the status LED if factory reset has not been initiated. - // - // If system has "full connectivity", keep the LED On constantly. - // - // If thread and service provisioned, but not attached to the thread network - // yet OR no connectivity to the service OR subscriptions are not fully - // established THEN blink the LED Off for a short period of time. - // - // If the system has ble connection(s) uptill the stage above, THEN blink - // the LEDs at an even rate of 100ms. - // - // Otherwise, blink the LED ON for a very short time. - if (mFunction != kFunction_FactoryReset) - { - ActivateStatusLedPatterns(); - } - sStatusLED.Animate(); -} - -void BaseApplication::ButtonHandler(AppEvent * aEvent) -{ - uint8_t count = FACTORY_RESET_LOOP_COUNT; - - // To trigger software update: press the APP_FUNCTION_BUTTON button briefly (< - // FACTORY_RESET_TRIGGER_TIMEOUT) To initiate factory reset: press the - // APP_FUNCTION_BUTTON for FACTORY_RESET_TRIGGER_TIMEOUT + - // FACTORY_RESET_CANCEL_WINDOW_TIMEOUT All LEDs start blinking after - // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. - // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs - // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT - if (aEvent->ButtonEvent.Action == static_cast(SilabsPlatform::ButtonAction::ButtonPressed)) - { - if ((!mFunctionTimerActive) && (mFunction == kFunction_NoneSelected)) - { - mFunction = kFunction_FactoryReset; - - // Wait for sometime to determine button is pressed for Factory reset - // other functionality - vTaskDelay(1000); // Delay of 1sec before we check the button status - } - } - - while (!(RSI_NPSSGPIO_GetPin(NPSS_GPIO_0))) - { - if (count == 0) - { - FunctionFactoryReset(); - break; - } - - // Turn off status LED before starting blink to make sure blink is - // co-ordinated. - sStatusLED.Set(false); - sStatusLED.Blink(500); - SILABS_LOG("Factory reset triggering in %d sec release button to cancel", count--); - - // Delay of 1sec before checking the button status again - vTaskDelay(1000); - } - - if (count > 0) - { - sStatusLED.Set(false); - SILABS_LOG("Factory Reset has been Canceled"); // button held past Timeout wait till button is released - } - - // If the button was released before factory reset got initiated, start BLE advertissement in fast mode - if (mFunction == kFunction_FactoryReset) - { - mFunction = kFunction_NoneSelected; - -#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 - StopStatusLEDTimer(); -#endif - - if (!ConnectivityMgr().IsWiFiStationProvisioned()) - { - // Enable BLE advertisements - ConnectivityMgr().SetBLEAdvertisingEnabled(true); - ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising); - } - else - { - SILABS_LOG("Network is already provisioned, Ble advertissement not enabled"); - } - } -} - -void BaseApplication::CancelFunctionTimer() -{ - if (xTimerStop(sFunctionTimer, pdMS_TO_TICKS(0)) == pdFAIL) - { - SILABS_LOG("app timer stop() failed"); - appError(APP_ERROR_STOP_TIMER_FAILED); - } - - mFunctionTimerActive = false; -} - -void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs) -{ - if (xTimerIsTimerActive(sFunctionTimer)) - { - SILABS_LOG("app timer already started!"); - CancelFunctionTimer(); - } - - // timer is not active, change its period to required value (== restart). - // FreeRTOS- Block for a maximum of 100 ms if the change period command - // cannot immediately be sent to the timer command queue. - if (xTimerChangePeriod(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs), pdMS_TO_TICKS(100)) != pdPASS) - { - SILABS_LOG("app timer start() failed"); - appError(APP_ERROR_START_TIMER_FAILED); - } - - mFunctionTimerActive = true; -} - -void BaseApplication::StartStatusLEDTimer() -{ - if (pdPASS != xTimerStart(sLightTimer, pdMS_TO_TICKS(0))) - { - SILABS_LOG("Light Time start failed"); - appError(APP_ERROR_START_TIMER_FAILED); - } -} - -void BaseApplication::StopStatusLEDTimer() -{ - sStatusLED.Set(false); - - if (xTimerStop(sLightTimer, pdMS_TO_TICKS(100)) != pdPASS) - { - SILABS_LOG("Light Time start failed"); - appError(APP_ERROR_START_TIMER_FAILED); - } -} - -#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER -void BaseApplication::OnIdentifyStart(Identify * identify) -{ - ChipLogProgress(Zcl, "onIdentifyStart"); - -#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 - StartStatusLEDTimer(); -#endif -} - -void BaseApplication::OnIdentifyStop(Identify * identify) -{ - ChipLogProgress(Zcl, "onIdentifyStop"); - -#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 - StopStatusLEDTimer(); -#endif -} - -void BaseApplication::OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState) -{ - ChipLogProgress(Zcl, "Trigger Identify Complete"); - sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect; - -#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 - StopStatusLEDTimer(); -#endif -} - -void BaseApplication::OnTriggerIdentifyEffect(Identify * identify) -{ - sIdentifyEffect = identify->mCurrentEffectIdentifier; - - if (identify->mEffectVariant != Clusters::Identify::EffectVariantEnum::kDefault) - { - ChipLogDetail(AppServer, "Identify Effect Variant unsupported. Using default"); - } - -#if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 - StartStatusLEDTimer(); -#endif - - switch (sIdentifyEffect) - { - case Clusters::Identify::EffectIdentifierEnum::kBlink: - case Clusters::Identify::EffectIdentifierEnum::kOkay: - (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted, - identify); - break; - case Clusters::Identify::EffectIdentifierEnum::kBreathe: - case Clusters::Identify::EffectIdentifierEnum::kChannelChange: - (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(10), OnTriggerIdentifyEffectCompleted, - identify); - break; - case Clusters::Identify::EffectIdentifierEnum::kFinishEffect: - (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); - (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerIdentifyEffectCompleted, - identify); - break; - case Clusters::Identify::EffectIdentifierEnum::kStopEffect: - (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); - break; - default: - sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect; - ChipLogProgress(Zcl, "No identifier effect"); - } -} -#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER - -void BaseApplication::LightTimerEventHandler(TimerHandle_t xTimer) -{ - LightEventHandler(); -} - -#ifdef DISPLAY_ENABLED -SilabsLCD & BaseApplication::GetLCD(void) -{ - return slLCD; -} -#endif - -void BaseApplication::PostEvent(const AppEvent * aEvent) -{ - if (sAppEventQueue != NULL) - { - BaseType_t status; - if (xPortIsInsideInterrupt()) - { - BaseType_t higherPrioTaskWoken = pdFALSE; - status = xQueueSendFromISR(sAppEventQueue, aEvent, &higherPrioTaskWoken); - -#ifdef portYIELD_FROM_ISR - portYIELD_FROM_ISR(higherPrioTaskWoken); -#elif portEND_SWITCHING_ISR // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - portEND_SWITCHING_ISR(higherPrioTaskWoken); -#else // portYIELD_FROM_ISR or portEND_SWITCHING_ISR -#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" -#endif // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - } - else - { - status = xQueueSend(sAppEventQueue, aEvent, 1); - } - - if (!status) - { - SILABS_LOG("Failed to post event to app task event queue"); - } - } - else - { - SILABS_LOG("Event Queue is NULL should never happen"); - } -} - -void BaseApplication::DispatchEvent(AppEvent * aEvent) -{ - if (aEvent->Handler) - { - aEvent->Handler(aEvent); - } - else - { - SILABS_LOG("Event received with no handler. Dropping event."); - } -} diff --git a/examples/platform/silabs/SiWx917/BaseApplication.h b/examples/platform/silabs/SiWx917/BaseApplication.h deleted file mode 100644 index badb42a84db54b..00000000000000 --- a/examples/platform/silabs/SiWx917/BaseApplication.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -/********************************************************** - * Includes - *********************************************************/ - -#include -#include - -#include "AppEvent.h" -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer support -#include -#include -#include -#include -#include - -#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER -#include -#endif - -#ifdef DISPLAY_ENABLED -#include "demo-ui.h" -#include "lcd.h" -#ifdef QR_CODE_ENABLED -#include "qrcodegen.h" -#endif // QR_CODE_ENABLED -#endif // DISPLAY_ENABLED - -/********************************************************** - * Defines - *********************************************************/ - -// Application-defined error codes in the CHIP_ERROR space. -#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01) -#define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02) -#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) -#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) -#define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) -#define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) - -/********************************************************** - * BaseApplication Declaration - *********************************************************/ - -class BaseApplication -{ - -public: - BaseApplication() = default; - virtual ~BaseApplication(){}; - - /** - * @brief Create AppTask task and Event Queue - * If an error occurs during creation, application will hang after printing out error code - * - * @return CHIP_ERROR CHIP_NO_ERROR if no errors - */ - CHIP_ERROR StartAppTask(TaskFunction_t taskFunction); - - /** - * @brief PostEvent function that add event to AppTask queue for processing - * - * @param event AppEvent to post - */ - static void PostEvent(const AppEvent * event); - -#ifdef DISPLAY_ENABLED - /** - * @brief Return LCD object - */ - static SilabsLCD & GetLCD(void); -#endif - - /** - * @brief Function called to start the LED light timer - */ - static void StartStatusLEDTimer(void); - - /** - * @brief Function to stop LED light timer - * Turns off Status LED before stopping timer - */ - static void StopStatusLEDTimer(void); - -#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER - // Idenfiy server command callbacks. - static void OnIdentifyStart(Identify * identify); - static void OnIdentifyStop(Identify * identify); - static void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState); - static void OnTriggerIdentifyEffect(Identify * identify); -#endif - - enum Function_t - { - kFunction_NoneSelected = 0, - kFunction_SoftwareUpdate = 0, - kFunction_StartBleAdv = 1, - kFunction_FactoryReset = 2, - - kFunction_Invalid - } Function; - -protected: - CHIP_ERROR Init(); - - /** - * @brief Function called to start the function timer - * - * @param aTimeoutMs timer duration in ms - */ - static void StartFunctionTimer(uint32_t aTimeoutMs); - - /** - * @brief Function to stop function timer - */ - static void CancelFunctionTimer(void); - - /** - * @brief Function call event callback function for processing - * - * @param event triggered event to be processed - */ - void DispatchEvent(AppEvent * event); - - /** - * @brief Function Timer finished callback function - * Post an FunctionEventHandler event - * - * @param xTimer timer that finished - */ - static void FunctionTimerEventHandler(TimerHandle_t xTimer); - - /** - * @brief Factory reset trigger function - * Trigger factory if called - * - */ - static void FunctionFactoryReset(void); - - /** - * @brief Timer Event processing function - * Trigger factory if Press and Hold duration is respected - * - * @param aEvent post event being processed - */ - static void FunctionEventHandler(AppEvent * aEvent); - - /** - * @brief PB0 Button event processing function - * Press and hold will trigger a factory reset timer start - * Press and release will restart BLEAdvertising if not commisionned - * - * @param aEvent button event being processed - */ - static void ButtonHandler(AppEvent * aEvent); - - /** - * @brief Light Timer finished callback function - * Calls LED processing function - * - * @param xTimer timer that finished - */ - static void LightTimerEventHandler(TimerHandle_t xTimer); - - /** - * @brief Activate a set of Led patterns of the Status led - * Identify patterns and Trigger effects have priority - * If no identification patterns are in progress, we provide - * commissioning status feedback. - * - * @return True if a Led pattern was set, otherwise, returns false. - */ - static bool ActivateStatusLedPatterns(); - - /** - * @brief Updates device LEDs - */ - static void LightEventHandler(); - - /********************************************************** - * Protected Attributes declaration - *********************************************************/ - bool mSyncClusterToButtonAction; -}; diff --git a/examples/platform/silabs/SiWx917/FreeRTOSConfig.h b/examples/platform/silabs/SiWx917/FreeRTOSConfig.h deleted file mode 100644 index cfbc571454a209..00000000000000 --- a/examples/platform/silabs/SiWx917/FreeRTOSConfig.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*************************************************************************** - * # License - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of Silicon Labs Master Software License - * Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. This - * software is Third Party Software licensed by Silicon Labs from a third party - * and is governed by the sections of the MSLA applicable to Third Party - * Software and the additional terms set forth below. - * - ******************************************************************************/ -/* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html. - *----------------------------------------------------------*/ - -extern uint32_t SystemCoreClock; - -/* Energy saving modes. */ -#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) -#define configUSE_TICKLESS_IDLE 1 -#else -#define configUSE_TICKLESS_IDLE 0 -#endif // SL_CATALOG_POWER_MANAGER_PRESENT - -#define configTICK_RATE_HZ (1000) -/* Definition used by Keil to replace default system clock source. */ -#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1 - -/* Hook function related definitions. */ -#define configUSE_TICK_HOOK (1) -#define configCHECK_FOR_STACK_OVERFLOW (2) -#define configUSE_MALLOC_FAILED_HOOK (1) -#define configUSE_IDLE_HOOK (0) - -/* Main functions*/ -/* Run time stats gathering related definitions. */ -#define configGENERATE_RUN_TIME_STATS (0) - -/* Co-routine related definitions. */ -#define configUSE_CO_ROUTINES (0) -#define configMAX_CO_ROUTINE_PRIORITIES (1) - -/* Software timer related definitions. */ -#define configUSE_TIMERS (1) -#define configTIMER_TASK_PRIORITY (40) /* Highest priority */ -#define configTIMER_QUEUE_LENGTH (10) -#define configTIMER_TASK_STACK_DEPTH (1024) - -/* Interrupt priorities used by the kernel port layer itself. These are generic -to all Cortex-M ports, and do not rely on any particular library functions. */ -#define configKERNEL_INTERRUPT_PRIORITY (255) -/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! -See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ -#define configMAX_SYSCALL_INTERRUPT_PRIORITY 48 -#define configENABLE_FPU 0 -#define configENABLE_MPU 0 -/* FreeRTOS Secure Side Only and TrustZone Security Extension */ -#define configRUN_FREERTOS_SECURE_ONLY 1 -#define configENABLE_TRUSTZONE 0 -/* FreeRTOS MPU specific definitions. */ -#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS (0) - -#define configCPU_CLOCK_HZ (SystemCoreClock) -#define configUSE_PREEMPTION (1) -#define configUSE_TIME_SLICING (1) -#define configUSE_PORT_OPTIMISED_TASK_SELECTION (0) -#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG (1) /* See into vPortSuppressTicksAndSleep source code for explanation */ -#define configMAX_PRIORITIES (56) -#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */ -#define configMAX_TASK_NAME_LEN (10) -#define configUSE_16_BIT_TICKS (0) -#define configIDLE_SHOULD_YIELD (1) -#define configUSE_MUTEXES (1) -#define configUSE_RECURSIVE_MUTEXES (1) -#define configUSE_COUNTING_SEMAPHORES (1) -#define configUSE_TASK_NOTIFICATIONS 1 -#define configUSE_TRACE_FACILITY 1 -#define configQUEUE_REGISTRY_SIZE (10) -#define configUSE_QUEUE_SETS (0) -#define configUSE_NEWLIB_REENTRANT (1) -#define configENABLE_BACKWARD_COMPATIBILITY (1) -#define configSUPPORT_STATIC_ALLOCATION (1) -#define configSUPPORT_DYNAMIC_ALLOCATION (1) - -#ifndef configTOTAL_HEAP_SIZE -#ifdef DIC_ENABLE -#define configTOTAL_HEAP_SIZE ((size_t)(50 * 1024)) -#else -#define configTOTAL_HEAP_SIZE ((size_t)(34 * 1024)) -#endif // DIC_ENABLE -#endif // configTOTAL_HEAP_SIZE - -/* Optional functions - most linkers will remove unused functions anyway. */ -#define INCLUDE_vTaskPrioritySet (1) -#define INCLUDE_uxTaskPriorityGet (1) -#define INCLUDE_vTaskDelete (1) -#define INCLUDE_vTaskSuspend (1) -#define INCLUDE_xResumeFromISR (1) -#define INCLUDE_vTaskDelayUntil (1) -#define INCLUDE_vTaskDelay (1) -#define INCLUDE_xTaskGetSchedulerState (1) -#define INCLUDE_xTaskGetCurrentTaskHandle (1) -#define INCLUDE_uxTaskGetStackHighWaterMark (1) -#define INCLUDE_xTaskGetIdleTaskHandle (1) -#define INCLUDE_xTimerGetTimerDaemonTaskHandle (1) -#define INCLUDE_pcTaskGetTaskName (1) -#define INCLUDE_eTaskGetState (1) -#define INCLUDE_xEventGroupSetBitFromISR (1) -#define INCLUDE_xEventGroupSetBitsFromISR (1) -#define INCLUDE_xSemaphoreGetMutexHolder (1) -#define INCLUDE_xTimerPendFunctionCall (1) -#define INCLUDE_xTaskGetHandle (1) - -/* Stop if an assertion fails. */ -#define configASSERT(x) \ - if ((x) == 0) \ - { \ - taskDISABLE_INTERRUPTS(); \ - printf("\nFREERTOS ASSERT ( %s )\n", #x); \ - for (;;) \ - ; \ - } -#define configASSERTNULL(x) \ - if ((x) == NULL) \ - { \ - taskDISABLE_INTERRUPTS(); \ - for (;;) \ - ; \ - } - -/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS -standard names. */ -#define vPortSVCHandler SVC_Handler -#define xPortPendSVHandler PendSV_Handler -/* Ensure Cortex-M port compatibility. */ -#define SysTick_Handler xPortSysTickHandler - -/* Thread local storage pointers used by the SDK */ -#ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS -#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0 -#endif - -#if defined(__GNUC__) -/* For the linker. */ -#define fabs __builtin_fabs -#endif - -#ifdef __cplusplus -} -#endif diff --git a/examples/platform/silabs/SiWx917/init_ccpPlatform.cpp b/examples/platform/silabs/SiWx917/init_ccpPlatform.cpp deleted file mode 100644 index 3723d72f090c5b..00000000000000 --- a/examples/platform/silabs/SiWx917/init_ccpPlatform.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppConfig.h" -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif -#include -#include - -#include - -#include "init_ccpPlatform.h" - -void initAntenna(void); - -/* GPIO button config */ -void RSI_Wakeupsw_config(void); -void RSI_Wakeupsw_config_gpio0(void); - -void init_ccpPlatform(void) -{ - - RSI_Wakeupsw_config(); - - RSI_Wakeupsw_config_gpio0(); -#if SILABS_LOG_ENABLED - silabsInitLog(); -#endif -} - -#ifdef __cplusplus -} -#endif diff --git a/examples/platform/silabs/SiWx917/init_ccpPlatform.h b/examples/platform/silabs/SiWx917/init_ccpPlatform.h deleted file mode 100644 index 986e2fecb18dd9..00000000000000 --- a/examples/platform/silabs/SiWx917/init_ccpPlatform.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*******************************************************************************/ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void init_ccpPlatform(void); -#ifdef __cplusplus -} -#endif diff --git a/examples/platform/silabs/SiWx917/matter_config.cpp b/examples/platform/silabs/SiWx917/matter_config.cpp deleted file mode 100644 index e0a7dc1e570079..00000000000000 --- a/examples/platform/silabs/SiWx917/matter_config.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2022 Silabs. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppConfig.h" -#include "OTAConfig.h" -#include - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef SL_WIFI -#include "wfx_host_events.h" -#endif /* SL_WIFI */ -#ifdef __cplusplus -} -#endif - -#if PW_RPC_ENABLED -#include "Rpc.h" -#endif - -#ifdef ENABLE_CHIP_SHELL -#include "matter_shell.h" -#endif - -#ifdef HEAP_MONITORING -#include "MemMonitoring.h" -#endif - -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; - -#include -// If building with the SiWx917-provided crypto backend, we can use the - -#include "SilabsDeviceDataProvider.h" -#include "SilabsTestEventTriggerDelegate.h" -#include - -#if SILABS_OTA_ENABLED -void SilabsMatterConfig::InitOTARequestorHandler(System::Layer * systemLayer, void * appState) -{ -#if 0 // TODO : OTA is not planned now for CCP - OTAConfig::Init(); -#endif -} -#endif - -void SilabsMatterConfig::ConnectivityEventCallback(const ChipDeviceEvent * event, intptr_t arg) -{ - // Initialize OTA only when Thread or WiFi connectivity is established - /*if (((event->Type == DeviceEventType::kThreadConnectivityChange) && - (event->ThreadConnectivityChange.Result == kConnectivity_Established)) || - ((event->Type == DeviceEventType::kInternetConnectivityChange) && - (event->InternetConnectivityChange.IPv6 == kConnectivity_Established))) - { - SILABS_LOG("Scheduling OTA Requestor initialization") - chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(OTAConfig::kInitOTARequestorDelaySec), - InitOTARequestorHandler, nullptr); - }*/ - SILABS_LOG("Scheduling OTA Requestor initialization") -} - -#if SILABS_TEST_EVENT_TRIGGER_ENABLED -static uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, - 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, - 0xcc, 0xdd, 0xee, 0xff }; -#endif // SILABS_TEST_EVENT_TRIGGER_ENABLED - -CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) -{ - CHIP_ERROR err; - - mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); - - SILABS_LOG("=================================================="); - SILABS_LOG("%s starting", appName); - SILABS_LOG("=================================================="); - -#if PW_RPC_ENABLED - chip::rpc::Init(); -#endif - -#ifdef HEAP_MONITORING - MemMonitoring::startHeapMonitoring(); -#endif - //============================================== - // Init Matter Stack - //============================================== - SILABS_LOG("Init CHIP Stack"); - // Init Chip memory management before the stack - ReturnErrorOnFailure(chip::Platform::MemoryInit()); - - SILABS_LOG("Init RSI 911x Platform"); - int32_t deviceInit = wfx_rsi_platform(); - if (deviceInit != SL_STATUS_OK) - { - SILABS_LOG("RSI init failed"); - return CHIP_ERROR_INTERNAL; - } - ReturnErrorOnFailure(PlatformMgr().InitChipStack()); - - SetDeviceInstanceInfoProvider(&Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider()); - SetCommissionableDataProvider(&Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider()); - -#ifdef SIWX917_USE_COMISSIONABLE_DATA - err = Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider().FlashFactoryData(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("Flashing to the device failed"); - return err; - } -#endif - chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(appName); - - // Stop Matter event handling while setting up resources - chip::DeviceLayer::PlatformMgr().LockChipStack(); - - // Create initParams with SDK example defaults here - static chip::CommonCaseDeviceServerInitParams initParams; - -#if SILABS_TEST_EVENT_TRIGGER_ENABLED - if (Encoding::HexToBytes(SILABS_TEST_EVENT_TRIGGER_ENABLE_KEY, strlen(SILABS_TEST_EVENT_TRIGGER_ENABLE_KEY), - sTestEventTriggerEnableKey, - TestEventTriggerDelegate::kEnableKeyLength) != TestEventTriggerDelegate::kEnableKeyLength) - { - SILABS_LOG("Failed to convert the EnableKey string to octstr type value"); - memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); - } - static SilabsTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &testEventTriggerDelegate; -#endif // SILABS_TEST_EVENT_TRIGGER_ENABLED - - // Initialize the remaining (not overridden) providers to the SDK example defaults - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - - // Init Matter Server and Start Event Loop - err = chip::Server::GetInstance().Init(initParams); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - ReturnErrorOnFailure(err); - - // OTA Requestor initialization will be triggered by the connectivity events - // TODO - // PlatformMgr().AddEventHandler(ConnectivityEventCallback, reinterpret_cast(nullptr)); - - SILABS_LOG("Starting Platform Manager Event Loop"); - ReturnErrorOnFailure(PlatformMgr().StartEventLoopTask()); - -#ifdef SL_WIFI - InitWiFi(); -#endif - -#ifdef ENABLE_CHIP_SHELL - chip::startShellTask(); -#endif - - return CHIP_NO_ERROR; -} - -#ifdef SL_WIFI -void SilabsMatterConfig::InitWiFi(void) -{ -#ifdef RS911X_WIFI - /* - * Start up any RSI interface stuff - * (Not required) - Note that wfx_wifi_start will deal with - * starting up a rsi task - which will initialize the SPI interface. - */ -#endif -} -#endif // SL_WIFI - -// ================================================================================ -// FreeRTOS Callbacks -// ================================================================================ -extern "C" void vApplicationIdleHook(void) -{ - // FreeRTOS Idle callback -} diff --git a/examples/platform/silabs/SiWx917/pw_sys_io/BUILD.gn b/examples/platform/silabs/SiWx917/pw_sys_io/BUILD.gn deleted file mode 100644 index 20547c3b7beabc..00000000000000 --- a/examples/platform/silabs/SiWx917/pw_sys_io/BUILD.gn +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") -import("//build_overrides/pigweed.gni") - -import("$dir_pw_build/target_types.gni") - -examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" - -config("default_config") { - include_dirs = [ "public" ] -} - -pw_source_set("pw_sys_io_efr32") { - sources = [ "sys_io_efr32.cc" ] - - deps = [ - "$dir_pw_sys_io:default_putget_bytes", - "$dir_pw_sys_io:facade", - ] - - cflags = [ "-Wconversion" ] - - public_configs = [ ":default_config" ] - - include_dirs = [ "${examples_plat_dir}" ] -} diff --git a/examples/platform/silabs/SiWx917/uart.h b/examples/platform/silabs/SiWx917/uart.h deleted file mode 100644 index 035d5b3b0ede7d..00000000000000 --- a/examples/platform/silabs/SiWx917/uart.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void uartConsoleInit(void); -int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength); -int16_t uartConsoleRead(char * Buf, uint16_t NbBytesToRead); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/examples/platform/silabs/efr32/TemperatureSensor.cpp b/examples/platform/silabs/TemperatureSensor.cpp similarity index 100% rename from examples/platform/silabs/efr32/TemperatureSensor.cpp rename to examples/platform/silabs/TemperatureSensor.cpp diff --git a/examples/platform/silabs/efr32/TemperatureSensor.h b/examples/platform/silabs/TemperatureSensor.h similarity index 100% rename from examples/platform/silabs/efr32/TemperatureSensor.h rename to examples/platform/silabs/TemperatureSensor.h diff --git a/examples/platform/silabs/SiWx917/board_config.h b/examples/platform/silabs/board_config.h similarity index 98% rename from examples/platform/silabs/SiWx917/board_config.h rename to examples/platform/silabs/board_config.h index ed92fdd145a1c7..fa6779f583afd1 100644 --- a/examples/platform/silabs/SiWx917/board_config.h +++ b/examples/platform/silabs/board_config.h @@ -28,7 +28,7 @@ /** * @file - * This file includes dev board compile-time configuration constants for SiWx917. + * This file includes dev board compile-time configuration constants for Silabs board. * */ diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 38d77a45e19498..3a965cb01185b1 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -285,14 +285,13 @@ source_set("efr32-common") { include_dirs = [ "." ] sources = [ + "${silabs_common_plat_dir}/BaseApplication.cpp", "${silabs_common_plat_dir}/LEDWidget.cpp", + "${silabs_common_plat_dir}/MatterConfig.cpp", "${silabs_common_plat_dir}/SoftwareFaultReports.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/silabs_utils.cpp", "${silabs_common_plat_dir}/syscalls_stubs.cpp", - "BaseApplication.cpp", - "init_efrPlatform.cpp", - "matter_config.cpp", ] if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli) { diff --git a/examples/platform/silabs/efr32/board_config.h b/examples/platform/silabs/efr32/board_config.h deleted file mode 100644 index 8c495b4fa7f513..00000000000000 --- a/examples/platform/silabs/efr32/board_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018, The OpenThread Authors. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file - * This file includes dev borad compile-time configuration constants for efr32. - * - */ - -#pragma once - -/// Dev board suppports OQPSK modulation in 2.4GHz band. -#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 -#define RADIO_CONFIG_915MHZ_OQPSK_SUPPORT 0 - -/// The PA(s) is(are) fed from the DCDC -#if (BRD4166A) -#define RADIO_CONFIG_PA_USES_DCDC 1 -#else -#define RADIO_CONFIG_PA_USES_DCDC 0 -#endif - -#ifndef RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT -#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c -#endif - -#ifndef RADIO_CONFIG_DMP_SUPPORT -#define RADIO_CONFIG_DMP_SUPPORT 0 /// Set to 1 to enable Dynamic Multi-Protocol support in radio.c -#endif diff --git a/examples/platform/silabs/efr32/init_efrPlatform.cpp b/examples/platform/silabs/efr32/init_efrPlatform.cpp deleted file mode 100644 index 5deaf666e4b12e..00000000000000 --- a/examples/platform/silabs/efr32/init_efrPlatform.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppConfig.h" -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif -#include -#include - -#include - -#if CHIP_ENABLE_OPENTHREAD -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform-efr32.h" -#include "sl_openthread.h" - -#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE -#include "openthread/heap.h" -#endif // OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE -#endif // CHIP_ENABLE_OPENTHREAD - -#include "init_efrPlatform.h" -#include "sl_component_catalog.h" -#include "sl_mbedtls.h" -#include "sl_system_init.h" -#if SILABS_LOG_OUT_UART || ENABLE_CHIP_SHELL || CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI -#include "uart.h" -#endif - -#if SL_SYSTEM_VIEW -#include "SEGGER_SYSVIEW.h" -#endif - -void initAntenna(void); - -void init_efrPlatform(void) -{ - sl_system_init(); - sl_mbedtls_init(); -#if CHIP_ENABLE_OPENTHREAD -#ifdef MGM24 - sl_openthread_init(); -#endif - efr32RadioInit(); - efr32AlarmInit(); - efr32MiscInit(); -#endif // CHIP_ENABLE_OPENTHREAD - -#if SL_SYSTEM_VIEW - SEGGER_SYSVIEW_Conf(); - SEGGER_SYSVIEW_Start(); -#endif -#if SILABS_LOG_OUT_UART || ENABLE_CHIP_SHELL || CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI - uartConsoleInit(); -#endif -#if SILABS_LOG_ENABLED - silabsInitLog(); -#endif -} - -#ifdef __cplusplus -} -#endif diff --git a/examples/platform/silabs/efr32/init_efrPlatform.h b/examples/platform/silabs/efr32/init_efrPlatform.h deleted file mode 100644 index aeb47b8aaed3d1..00000000000000 --- a/examples/platform/silabs/efr32/init_efrPlatform.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*******************************************************************************/ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void init_efrPlatform(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/platform/silabs/efr32/pw_sys_io/public/pw_sys_io_efr32/init.h b/examples/platform/silabs/efr32/pw_sys_io/public/pw_sys_io_efr32/init.h deleted file mode 100644 index f11f5e928f3e14..00000000000000 --- a/examples/platform/silabs/efr32/pw_sys_io/public/pw_sys_io_efr32/init.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "pw_preprocessor/util.h" - -PW_EXTERN_C_START - -// The actual implement of PreMainInit() in sys_io_BACKEND. -void pw_sys_io_Init(); - -PW_EXTERN_C_END diff --git a/examples/platform/silabs/efr32/pw_sys_io/sys_io_efr32.cc b/examples/platform/silabs/efr32/pw_sys_io/sys_io_efr32.cc deleted file mode 100644 index 4bc7d98f7477c4..00000000000000 --- a/examples/platform/silabs/efr32/pw_sys_io/sys_io_efr32.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "pw_sys_io/sys_io.h" -#include -#include -#include -#include - -#include "uart.h" - -int16_t console_getchar(char * chr) -{ - int16_t retVal = 0; - - // Busy wait for pw_rcp reads - while (retVal == 0) - { - retVal = uartConsoleRead(chr, 1); - } - return retVal; -} - -int16_t console_putchar(const char * chr) -{ - return uartConsoleWrite(chr, 1); -} - -extern "C" void pw_sys_io_Init() -{ - uartConsoleInit(); -} - -namespace pw::sys_io { - -Status ReadByte(std::byte * dest) -{ - if (!dest) - return Status::InvalidArgument(); - - int16_t ret = console_getchar(reinterpret_cast(dest)); - return ret < 0 ? Status::FailedPrecondition() : OkStatus(); -} - -Status WriteByte(std::byte b) -{ - int16_t ret = console_putchar(reinterpret_cast(&b)); - return ret < 0 ? Status::FailedPrecondition() : OkStatus(); -} - -// Writes a string using pw::sys_io, and add newline characters at the end. -StatusWithSize WriteLine(const std::string_view & s) -{ - size_t chars_written = 0; - StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s))); - if (!result.ok()) - { - return result; - } - chars_written += result.size(); - result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2))); - chars_written += result.size(); - - return StatusWithSize(result.status(), chars_written); -} - -} // namespace pw::sys_io diff --git a/examples/platform/silabs/SiWx917/ldscripts/SiWx917.ld b/examples/platform/silabs/ldscripts/SiWx917.ld similarity index 100% rename from examples/platform/silabs/SiWx917/ldscripts/SiWx917.ld rename to examples/platform/silabs/ldscripts/SiWx917.ld diff --git a/examples/platform/silabs/efr32/ldscripts/efr32mg12.ld b/examples/platform/silabs/ldscripts/efr32mg12.ld similarity index 100% rename from examples/platform/silabs/efr32/ldscripts/efr32mg12.ld rename to examples/platform/silabs/ldscripts/efr32mg12.ld diff --git a/examples/platform/silabs/efr32/ldscripts/efr32mg21.ld b/examples/platform/silabs/ldscripts/efr32mg21.ld similarity index 100% rename from examples/platform/silabs/efr32/ldscripts/efr32mg21.ld rename to examples/platform/silabs/ldscripts/efr32mg21.ld diff --git a/examples/platform/silabs/efr32/ldscripts/efr32mg24.ld b/examples/platform/silabs/ldscripts/efr32mg24.ld similarity index 100% rename from examples/platform/silabs/efr32/ldscripts/efr32mg24.ld rename to examples/platform/silabs/ldscripts/efr32mg24.ld diff --git a/examples/platform/silabs/efr32/ldscripts/mgm24.ld b/examples/platform/silabs/ldscripts/mgm24.ld similarity index 100% rename from examples/platform/silabs/efr32/ldscripts/mgm24.ld rename to examples/platform/silabs/ldscripts/mgm24.ld diff --git a/examples/platform/silabs/main.cpp b/examples/platform/silabs/main.cpp index a94696ef08374e..03fb25b549db67 100644 --- a/examples/platform/silabs/main.cpp +++ b/examples/platform/silabs/main.cpp @@ -22,9 +22,9 @@ #include "AppConfig.h" #include +#include #include #include -#include #ifdef SILABS_ATTESTATION_CREDENTIALS #include #else diff --git a/examples/platform/silabs/efr32/pw_sys_io/BUILD.gn b/examples/platform/silabs/pw_sys_io/BUILD.gn similarity index 87% rename from examples/platform/silabs/efr32/pw_sys_io/BUILD.gn rename to examples/platform/silabs/pw_sys_io/BUILD.gn index 722d2a7cad24e6..354ed573eb9935 100644 --- a/examples/platform/silabs/efr32/pw_sys_io/BUILD.gn +++ b/examples/platform/silabs/pw_sys_io/BUILD.gn @@ -17,14 +17,14 @@ import("//build_overrides/pigweed.gni") import("$dir_pw_build/target_types.gni") -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" +examples_plat_dir = "${chip_root}/examples/platform/silabs" config("default_config") { include_dirs = [ "public" ] } -pw_source_set("pw_sys_io_efr32") { - sources = [ "sys_io_efr32.cc" ] +pw_source_set("pw_sys_io_silabs") { + sources = [ "sys_io_silabs.cc" ] deps = [ "$dir_pw_sys_io:default_putget_bytes", diff --git a/examples/platform/silabs/SiWx917/pw_sys_io/public/pw_sys_io_efr32/init.h b/examples/platform/silabs/pw_sys_io/public/pw_sys_io_efr32/init.h similarity index 100% rename from examples/platform/silabs/SiWx917/pw_sys_io/public/pw_sys_io_efr32/init.h rename to examples/platform/silabs/pw_sys_io/public/pw_sys_io_efr32/init.h diff --git a/examples/platform/silabs/SiWx917/pw_sys_io/sys_io_siwx917.cc b/examples/platform/silabs/pw_sys_io/sys_io_silabs.cc similarity index 100% rename from examples/platform/silabs/SiWx917/pw_sys_io/sys_io_siwx917.cc rename to examples/platform/silabs/pw_sys_io/sys_io_silabs.cc diff --git a/examples/platform/silabs/silabs_utils.cpp b/examples/platform/silabs/silabs_utils.cpp index 0e67a9e723a764..7231836c15bf7e 100644 --- a/examples/platform/silabs/silabs_utils.cpp +++ b/examples/platform/silabs/silabs_utils.cpp @@ -19,7 +19,7 @@ #include "silabs_utils.h" #include "SoftwareFaultReports.h" -#include +#include void appError(int err) { diff --git a/examples/platform/silabs/efr32/uart.h b/examples/platform/silabs/uart.h similarity index 100% rename from examples/platform/silabs/efr32/uart.h rename to examples/platform/silabs/uart.h diff --git a/examples/pump-app/silabs/BUILD.gn b/examples/pump-app/silabs/BUILD.gn index 1dc594d535d327..f255000ea525d5 100644 --- a/examples/pump-app/silabs/BUILD.gn +++ b/examples/pump-app/silabs/BUILD.gn @@ -66,7 +66,7 @@ if (slc_generate) { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -89,7 +89,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -189,7 +189,7 @@ silabs_executable("pump_app") { if (wifi_soc) { deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] } else { - deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ] + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] } deps += pw_build_LINK_DEPS @@ -200,7 +200,7 @@ silabs_executable("pump_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/smoke-co-alarm-app/silabs/BUILD.gn b/examples/smoke-co-alarm-app/silabs/BUILD.gn index cafd4b6f7cc1bd..7750dc31f6324b 100644 --- a/examples/smoke-co-alarm-app/silabs/BUILD.gn +++ b/examples/smoke-co-alarm-app/silabs/BUILD.gn @@ -68,7 +68,7 @@ if (slc_generate) { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -91,7 +91,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -188,7 +188,7 @@ silabs_executable("smoke_co_alarm_app") { if (wifi_soc) { deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] } else { - deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ] + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] } deps += pw_build_LINK_DEPS @@ -199,7 +199,7 @@ silabs_executable("smoke_co_alarm_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/thermostat/silabs/BUILD.gn b/examples/thermostat/silabs/BUILD.gn index 684ab738804105..f82bbc40776c40 100644 --- a/examples/thermostat/silabs/BUILD.gn +++ b/examples/thermostat/silabs/BUILD.gn @@ -56,7 +56,7 @@ declare_args() { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -79,7 +79,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -147,7 +147,7 @@ silabs_executable("thermostat_app") { "${efr32_sdk_root}/platform/common/src/sl_status.c", "${efr32_sdk_root}/platform/driver/i2cspm/src/sl_i2cspm.c", "${efr32_sdk_root}/platform/emlib/src/em_i2c.c", - "${examples_plat_dir}/TemperatureSensor.cpp", + "${examples_common_plat_dir}/TemperatureSensor.cpp", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_i2cspm_init.c", ] } @@ -198,7 +198,7 @@ silabs_executable("thermostat_app") { if (wifi_soc) { deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] } else { - deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ] + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] } deps += pw_build_LINK_DEPS @@ -209,7 +209,7 @@ silabs_executable("thermostat_app") { ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/window-app/silabs/BUILD.gn b/examples/window-app/silabs/BUILD.gn index e5c33fdbdeab9e..cc6f916712d233 100644 --- a/examples/window-app/silabs/BUILD.gn +++ b/examples/window-app/silabs/BUILD.gn @@ -53,7 +53,7 @@ declare_args() { if (wifi_soc) { siwx917_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -76,7 +76,7 @@ if (wifi_soc) { } else { efr32_sdk("sdk") { sources = [ - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", "${silabs_project_dir}/include/CHIPProjectConfig.h", ] @@ -134,7 +134,7 @@ silabs_executable("window_app") { } else { deps += [ "${examples_plat_dir}:efr32-common" ] } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp index 3deb5fd2359087..98eaa6f7114724 100644 --- a/src/platform/silabs/platformAbstraction/GsdkSpam.cpp +++ b/src/platform/silabs/platformAbstraction/GsdkSpam.cpp @@ -15,7 +15,6 @@ * limitations under the License. */ -#include "init_efrPlatform.h" #include #include "sl_system_kernel.h" @@ -30,6 +29,34 @@ extern "C" { #include "sl_simple_button_instances.h" #endif +extern "C" { +#include + +#if CHIP_ENABLE_OPENTHREAD +#include "platform-efr32.h" + +#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE +#include "openthread/heap.h" +#endif // OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE + +#endif // CHIP_ENABLE_OPENTHREAD + +#include "sl_component_catalog.h" +#include "sl_mbedtls.h" +#include "sl_system_init.h" +#if SILABS_LOG_OUT_UART || ENABLE_CHIP_SHELL || CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI +#include "uart.h" +#endif + +#if SL_SYSTEM_VIEW +#include "SEGGER_SYSVIEW.h" +#endif +} + +#if SILABS_LOG_ENABLED +#include "silabs_utils.h" +#endif + namespace chip { namespace DeviceLayer { namespace Silabs { @@ -40,7 +67,25 @@ SilabsPlatform::SilabsButtonCb SilabsPlatform::mButtonCallback = nullptr; CHIP_ERROR SilabsPlatform::Init(void) { - init_efrPlatform(); + sl_system_init(); + sl_mbedtls_init(); + +#if CHIP_ENABLE_OPENTHREAD + sl_ot_sys_init(); +#endif + +#if SL_SYSTEM_VIEW + SEGGER_SYSVIEW_Conf(); + SEGGER_SYSVIEW_Start(); +#endif + +#if SILABS_LOG_OUT_UART || ENABLE_CHIP_SHELL || CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI + uartConsoleInit(); +#endif + +#if SILABS_LOG_ENABLED + silabsInitLog(); +#endif return CHIP_NO_ERROR; } diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp index d39a1180a524ad..f226caeaaa8395 100644 --- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp @@ -17,13 +17,14 @@ #include -#include "init_ccpPlatform.h" #include #include // TODO add includes ? extern "C" void RSI_Board_LED_Set(int, bool); extern "C" void RSI_Board_LED_Toggle(int); +extern "C" void RSI_Wakeupsw_config(void); +extern "C" void RSI_Wakeupsw_config_gpio0(void); namespace chip { namespace DeviceLayer { @@ -35,7 +36,12 @@ SilabsPlatform::SilabsButtonCb SilabsPlatform::mButtonCallback = nullptr; CHIP_ERROR SilabsPlatform::Init(void) { mButtonCallback = nullptr; - init_ccpPlatform(); + RSI_Wakeupsw_config(); + + RSI_Wakeupsw_config_gpio0(); +#if SILABS_LOG_ENABLED + silabsInitLog(); +#endif return CHIP_NO_ERROR; } diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 9a250bb730ad22..59df8e9d54f03d 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -45,7 +45,7 @@ pw_proto_library("nl_test_service") { efr32_sdk("sdk") { sources = [ "${efr32_project_dir}/include/CHIPProjectConfig.h", - "${examples_plat_dir}/FreeRTOSConfig.h", + "${examples_common_plat_dir}/FreeRTOSConfig.h", ] include_dirs = [ @@ -73,7 +73,6 @@ silabs_executable("efr32_device_tests") { "${examples_common_plat_dir}/PigweedLogger.cpp", "${examples_common_plat_dir}/heap_4_silabs.c", "${examples_common_plat_dir}/syscalls_stubs.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", "${examples_plat_dir}/uart.cpp", "src/main.cpp", ] @@ -86,7 +85,7 @@ silabs_executable("efr32_device_tests") { "${chip_root}/src:tests", "${chip_root}/src/lib", "${chip_root}/src/lib/support:testing", - "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32", + "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs", "${nlunit_test_root}:nlunit-test", ] @@ -108,7 +107,7 @@ silabs_executable("efr32_device_tests") { include_dirs = [ "${chip_root}/examples/common/pigweed/efr32" ] - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/src/test_driver/efr32/src/main.cpp b/src/test_driver/efr32/src/main.cpp index 03f0a626f1b9a7..533fb5f94c307e 100644 --- a/src/test_driver/efr32/src/main.cpp +++ b/src/test_driver/efr32/src/main.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include #include @@ -181,7 +181,7 @@ void RunRpcService(void *) int main(void) { - init_efrPlatform(); + chip::DeviceLayer::Silabs::GetPlatform().Init(); PigweedLogger::init(); mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 3267d87e9bd398..dd3e93fb0a6883 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -181,6 +181,9 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/driver/debug/inc", "${silabs_gen_folder}/config", "${silabs_gen_folder}/autogen", + + # Headers needed for Init no function will be called if OT is not used + "${sl_ot_efr32_root}", ] if (silabs_family != "mgm24") { @@ -393,6 +396,7 @@ template("efr32_sdk") { libs += [ "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_efr32xg12_gcc_release.a", "${sdk_support_root}/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a", + "${sdk_support_root}/protocol/openthread/libs/libsl_openthread_efr32mg1x_gcc.a", ] if (!chip_enable_ble_rs911x) { @@ -435,6 +439,7 @@ template("efr32_sdk") { "${sdk_support_root}/protocol/bluetooth/lib/EFR32MG24/GCC/libbluetooth.a", "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_efr32xg24_gcc_release.a", "${sdk_support_root}/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a", + "${sdk_support_root}/protocol/openthread/libs/libsl_openthread_efr32mg2x_gcc.a", ] defines += [ diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 433ccfc014ffe3..f76916640f577c 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 433ccfc014ffe313bf5cbc848478701778040ef2 +Subproject commit f76916640f577ce81db2ec361d560c77c2e21478