diff --git a/examples/all-clusters-app/asr/BUILD.gn b/examples/all-clusters-app/asr/BUILD.gn index d639d658589519..7d0b089b657b87 100755 --- a/examples/all-clusters-app/asr/BUILD.gn +++ b/examples/all-clusters-app/asr/BUILD.gn @@ -73,13 +73,13 @@ asr_executable("clusters_app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", + "${examples_plat_dir}/ButtonHandler.cpp", "${examples_plat_dir}/CHIPDeviceManager.cpp", "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", "${examples_plat_dir}/init_asrPlatform.cpp", "${examples_plat_dir}/shell/matter_shell.cpp", "src/AppTask.cpp", - "src/ButtonHandler.cpp", "src/DeviceCallbacks.cpp", "src/main.cpp", ] diff --git a/examples/all-clusters-app/asr/README.md b/examples/all-clusters-app/asr/README.md index 287da141fc0e24..bde062feab4445 100755 --- a/examples/all-clusters-app/asr/README.md +++ b/examples/all-clusters-app/asr/README.md @@ -6,20 +6,12 @@ control on ASR platform. --- - [Matter ASR All Clusters Example](#matter-asr-all-clusters-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Cluster Control](#cluster-control) - [Light switch press button and light status LED](#light-switch-press-button-and-light-status-led) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer diff --git a/examples/all-clusters-app/asr/include/AppConfig.h b/examples/all-clusters-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 40abc79020f59e..3f2e1a80b4df84 --- a/examples/all-clusters-app/asr/include/AppConfig.h +++ b/examples/all-clusters-app/asr/include/AppConfig.h @@ -28,18 +28,6 @@ #define MATTER_DEVICE_NAME "ASR-Clusters" -#define GPIO_TASK_NAME "gpio" -#define GPIO_TASK_STACK_SIZE 1024 - -#define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - -#define SWITCH1_BUTTON GPIO12_INDEX -#define SWITCH2_BUTTON GPIO13_INDEX - -#define LIGHT1_LED PWM_OUTPUT_CH4 -#define LIGHT2_LED PWM_OUTPUT_CH6 - // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/all-clusters-app/asr/include/AppTask.h b/examples/all-clusters-app/asr/include/AppTask.h old mode 100644 new mode 100755 index 184e309af5eeba..210fd5a6fc7032 --- a/examples/all-clusters-app/asr/include/AppTask.h +++ b/examples/all-clusters-app/asr/include/AppTask.h @@ -40,7 +40,7 @@ class AppTask CHIP_ERROR StartAppTask(); static void AppTaskMain(void * pvParameter); static void AppEventHandler(AppEvent * aEvent); - void PostButtonEvent(uint8_t btnIdx, uint8_t btnAction); + void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); void PostEvent(const AppEvent * event); /** * Use internally for registration of the ChipDeviceEvents diff --git a/examples/all-clusters-app/asr/include/ButtonHandler.h b/examples/all-clusters-app/asr/include/ButtonHandler.h deleted file mode 100644 index 621459d464c322..00000000000000 --- a/examples/all-clusters-app/asr/include/ButtonHandler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright (c) 2022 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 "AppEvent.h" -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer support -#include -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#else -#include "duet_gpio.h" -#endif - -class ButtonHandler -{ -public: - static void Init(void); - - struct KeyInformation - { - uint8_t keyDown; - uint8_t keyImPulse; - uint8_t keyReleasePulse; - }; - - static KeyInformation keyInfo; - - static ButtonHandler & GetInstance() - { - static ButtonHandler sButtonHandler; - return sButtonHandler; - } - -private: - static void GpioInit(void); -}; diff --git a/examples/all-clusters-app/asr/src/AppTask.cpp b/examples/all-clusters-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index d55ef713dde3f2..3efb22ffcc338b --- a/examples/all-clusters-app/asr/src/AppTask.cpp +++ b/examples/all-clusters-app/asr/src/AppTask.cpp @@ -47,7 +47,6 @@ using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; -LEDWidget sStatusLED; LEDWidget sLightLED; namespace { @@ -119,7 +118,11 @@ CHIP_ERROR AppTask::Init() ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ return CHIP_NO_ERROR; } @@ -131,8 +134,7 @@ void AppTask::AppTaskMain(void * pvParameter) ButtonHandler::Init(); - sLightLED.Init(LIGHT1_LED); // embedded board light - sStatusLED.Init(LIGHT2_LED); + sLightLED.Init(LIGHT_LED); lega_rtos_start_timer(&sAppTimer); @@ -186,7 +188,6 @@ void AppTask::AppEventHandler(AppEvent * aEvent) if (lightState) { sLightLED.Set(1); - sLightLED.SetBrightness(100); } else { @@ -213,9 +214,9 @@ void AppTask::AppTimerCallback(void * params) sAppTask.PostEvent(&timer_event); } -void AppTask::PostButtonEvent(uint8_t btnIdx, uint8_t btnAction) +void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) { - ASR_LOG("%s %s\n", btnIdx == SWITCH1_BUTTON ? "btn1" : "btn2", btnAction == APP_BUTTON_PRESSED ? "Pressed" : "Released"); + ASR_LOG("%s %s\n", btnIdx == SWITCH1_BUTTON ? "btn1" : "btn2", btnAction == BUTTON_PRESSED ? "Pressed" : "Released"); if (btnIdx != SWITCH1_BUTTON && btnIdx != SWITCH2_BUTTON) { @@ -227,7 +228,7 @@ void AppTask::PostButtonEvent(uint8_t btnIdx, uint8_t btnAction) button_event.ButtonEvent.ButtonIdx = btnIdx; button_event.ButtonEvent.Action = btnAction; - if (btnAction == APP_BUTTON_RELEASED) + if (btnAction == BUTTON_RELEASED) { button_event.Handler = AppEventHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/all-clusters-app/asr/src/ButtonHandler.cpp b/examples/all-clusters-app/asr/src/ButtonHandler.cpp deleted file mode 100644 index 1faa7f7f56fbe1..00000000000000 --- a/examples/all-clusters-app/asr/src/ButtonHandler.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Copyright (c) 2022 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. - */ - -#include "ButtonHandler.h" -#include "AppConfig.h" -#include "AppTask.h" -#include - -#ifdef CFG_PLF_RV32 -#define duet_gpio_dev_t asr_gpio_dev_t -#define duet_gpio_init asr_gpio_init -#define duet_gpio_input_get asr_gpio_input_get -#define DUET_INPUT_PULL_UP ASR_INPUT_PULL_UP -#endif - -TaskHandle_t sGpioTaskHandle; -ButtonHandler::KeyInformation ButtonHandler::keyInfo = { 0 }; - -static void GpioTaskMain(void * pvParameter); - -void ButtonHandler::Init(void) -{ - GpioInit(); - - xTaskCreate(GpioTaskMain, GPIO_TASK_NAME, GPIO_TASK_STACK_SIZE, 0, 2, &sGpioTaskHandle); -} - -// port pin -duet_gpio_dev_t switch1_btn; -duet_gpio_dev_t switch2_btn; - -void ButtonHandler::GpioInit(void) -{ - // light switch1 button - switch1_btn.port = SWITCH1_BUTTON; - switch1_btn.config = DUET_INPUT_PULL_UP; - switch1_btn.priv = NULL; - duet_gpio_init(&switch1_btn); - - switch2_btn.port = SWITCH2_BUTTON; - switch2_btn.config = DUET_INPUT_PULL_UP; - switch2_btn.priv = NULL; - duet_gpio_init(&switch2_btn); -} - -void GpioTaskMain(void * pvParameter) -{ - ASR_LOG("GPIO Task started"); - uint32_t btnValue; - uint8_t currentKeys = 0; - - for (;;) - { - vTaskDelay(50 / portTICK_PERIOD_MS); - - duet_gpio_input_get(&switch1_btn, &btnValue); - - if (!btnValue) - { - currentKeys |= 0x01; - } - else - { - currentKeys &= ~0x01; - } - - duet_gpio_input_get(&switch2_btn, &btnValue); - - if (!btnValue) - { - currentKeys |= 0x02; - } - else - { - currentKeys &= ~0x02; - } - - ButtonHandler::keyInfo.keyImPulse = (ButtonHandler::keyInfo.keyDown ^ currentKeys) & ~ButtonHandler::keyInfo.keyDown; - ButtonHandler::keyInfo.keyReleasePulse = (ButtonHandler::keyInfo.keyDown ^ currentKeys) & ButtonHandler::keyInfo.keyDown; - ButtonHandler::keyInfo.keyDown = currentKeys; - - if (ButtonHandler::keyInfo.keyImPulse & 0x01) - { - GetAppTask().PostButtonEvent(SWITCH1_BUTTON, APP_BUTTON_PRESSED); - } - - if (ButtonHandler::keyInfo.keyImPulse & 0x02) - { - GetAppTask().PostButtonEvent(SWITCH2_BUTTON, APP_BUTTON_PRESSED); - } - - if (ButtonHandler::keyInfo.keyReleasePulse & 0x01) - { - GetAppTask().PostButtonEvent(SWITCH1_BUTTON, APP_BUTTON_RELEASED); - } - - if (ButtonHandler::keyInfo.keyReleasePulse & 0x02) - { - GetAppTask().PostButtonEvent(SWITCH2_BUTTON, APP_BUTTON_RELEASED); - } - } -} diff --git a/examples/all-clusters-app/asr/src/DeviceCallbacks.cpp b/examples/all-clusters-app/asr/src/DeviceCallbacks.cpp old mode 100644 new mode 100755 index 7b284250787382..859e3fb1043430 --- a/examples/all-clusters-app/asr/src/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/asr/src/DeviceCallbacks.cpp @@ -54,7 +54,6 @@ using namespace ::chip::DeviceManager; using namespace ::chip::Logging; extern LEDWidget sLightLED; -extern LEDWidget sStatusLED; uint32_t identifyTimerCount; constexpr uint32_t kIdentifyTimerDelayMS = 250; @@ -191,7 +190,6 @@ void DeviceCallbacks::OnLevelPostAttributeChangeCallback(EndpointId endpointId, { uint8_t tmp = *value; ChipLogProgress(Zcl, "New level: %u ", tmp); - sLightLED.SetBrightness(tmp); } else { diff --git a/examples/all-clusters-minimal-app/asr/README.md b/examples/all-clusters-minimal-app/asr/README.md index 8926066fccece9..5160ef5d4d5cf8 100755 --- a/examples/all-clusters-minimal-app/asr/README.md +++ b/examples/all-clusters-minimal-app/asr/README.md @@ -6,20 +6,11 @@ control on ASR platform. --- - [Matter ASR All Clusters Example](#matter-asr-all-clusters-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Cluster Control](#cluster-control) - - [Light switch press button and light status LED](#light-switch-press-button-and-light-status-led) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer @@ -42,13 +33,3 @@ For example,control the OnOff Cluster attribute: ./chip-tool onoff off 1 ./chip-tool onoff toggle 1 ``` - -## Light switch press button and light status LED - -This demo uses button to test changing the light states and LED to show the -state of these changes. - -| Name | Pin | -| :----: | :---: | -| LED | PAD6 | -| BUTTON | PAD12 | diff --git a/examples/all-clusters-minimal-app/asr/include/AppConfig.h b/examples/all-clusters-minimal-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 6a633267878a8d..46f0a9a00128ea --- a/examples/all-clusters-minimal-app/asr/include/AppConfig.h +++ b/examples/all-clusters-minimal-app/asr/include/AppConfig.h @@ -28,12 +28,6 @@ #define MATTER_DEVICE_NAME "ASR-Clusters-m" -#define APP_LIGHT_BUTTON_IDX 0 -#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50 - -#define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/all-clusters-minimal-app/asr/src/AppTask.cpp b/examples/all-clusters-minimal-app/asr/src/AppTask.cpp index 6b97d430953867..ac9dfe7ba5d8d0 100644 --- a/examples/all-clusters-minimal-app/asr/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/asr/src/AppTask.cpp @@ -21,6 +21,7 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" +#include "ButtonHandler.h" #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" #include "LEDWidget.h" @@ -50,9 +51,7 @@ using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; -LEDWidget sStatusLED; LEDWidget sLightLED; -LEDWidget sClusterLED; namespace { TaskHandle_t sAppTaskHandle; @@ -112,7 +111,13 @@ CHIP_ERROR AppTask::Init() ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ + + sLightLED.Init(LIGHT_LED); return CHIP_NO_ERROR; } @@ -150,7 +155,7 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent) void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) { - if (btnIdx != APP_LIGHT_BUTTON_IDX) + if (btnIdx != SWITCH1_BUTTON) { return; } @@ -160,7 +165,7 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) button_event.ButtonEvent.ButtonIdx = btnIdx; button_event.ButtonEvent.Action = btnAction; - if ((btnIdx == APP_LIGHT_BUTTON_IDX) && (btnAction == APP_BUTTON_RELEASED)) + if (btnAction == BUTTON_RELEASED) { button_event.Handler = LightActionEventHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/all-clusters-minimal-app/asr/src/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/asr/src/DeviceCallbacks.cpp old mode 100644 new mode 100755 index 269d1a8c7623a2..a7be66c3fbef2c --- a/examples/all-clusters-minimal-app/asr/src/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/asr/src/DeviceCallbacks.cpp @@ -52,6 +52,8 @@ using namespace ::chip::DeviceLayer; using namespace ::chip::DeviceManager; using namespace ::chip::Logging; +extern LEDWidget sLightLED; + uint32_t identifyTimerCount; constexpr uint32_t kIdentifyTimerDelayMS = 250; #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR @@ -151,9 +153,27 @@ void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); - // At this point we can assume that value points to a bool value. - // statusLED1.Set(*value); + switch (attributeId) + { + case chip::app::Clusters::OnOff::Attributes::OnOff::Id: { + ChipLogProgress(Zcl, "ON/OFF level: %u ", *value); + // At this point we can assume that value points to a bool value. + sLightLED.Set(*value); + } + break; + + case chip::app::Clusters::OnOff::Attributes::OnTime::Id: + case chip::app::Clusters::OnOff::Attributes::OffWaitTime::Id: + case chip::app::Clusters::OnOff::Attributes::StartUpOnOff::Id: + case chip::app::Clusters::OnOff::Attributes::GlobalSceneControl::Id: { + ChipLogProgress(Zcl, "Unprocessed attribute ID: %" PRIx32, attributeId); + } + break; + default: + ChipLogProgress(Zcl, "Unknown attribute ID: %" PRIx32, attributeId); + return; + } // switch (attributeId) exit: return; } diff --git a/examples/bridge-app/asr/BUILD.gn b/examples/bridge-app/asr/BUILD.gn index a8db71bd3de7d3..ebd3619278423e 100755 --- a/examples/bridge-app/asr/BUILD.gn +++ b/examples/bridge-app/asr/BUILD.gn @@ -73,7 +73,6 @@ asr_executable("bridge_app") { sources = [ "${examples_plat_dir}/CHIPDeviceManager.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", "${examples_plat_dir}/init_asrPlatform.cpp", "${examples_plat_dir}/shell/matter_shell.cpp", diff --git a/examples/bridge-app/asr/README.md b/examples/bridge-app/asr/README.md index 7f4e11a4b2bbe1..1986037085b645 100755 --- a/examples/bridge-app/asr/README.md +++ b/examples/bridge-app/asr/README.md @@ -5,20 +5,12 @@ This example demonstrates the Matter Bridge application on ASR platform. --- - [Matter ASR Bridge Example](#matter-asr-bridge-example) - - [Supported Chips](#supported-chips) - [Introduction](#introduction) - [Building and Commissioning](#building-and-commissioning) - [Testing the example](#testing-the-example) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Introduction A prototype application that demonstrates dynamic endpoint with device @@ -62,6 +54,6 @@ guides to get started This demo uses button to test changing the `Light1`, and the bridge device will output log information: - | Name | Pin | - | :----: | :--: | - | BUTTON | PAD6 | + | Name | Pin | + | :----: | :---: | + | BUTTON | PAD12 | diff --git a/examples/bridge-app/asr/include/AppConfig.h b/examples/bridge-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 1250881f65bf60..3a496455b02ff4 --- a/examples/bridge-app/asr/include/AppConfig.h +++ b/examples/bridge-app/asr/include/AppConfig.h @@ -24,8 +24,6 @@ #define MATTER_DEVICE_NAME "ASR-Bridge" #define APP_TASK_STACK_SIZE (1024 * 4) -#define LIGHT_LED PWM_OUTPUT_CH4 - // ASR Logging #ifdef __cplusplus extern "C" { diff --git a/examples/bridge-app/asr/src/AppTask.cpp b/examples/bridge-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index be6763819ac986..9583fb3a7017e4 --- a/examples/bridge-app/asr/src/AppTask.cpp +++ b/examples/bridge-app/asr/src/AppTask.cpp @@ -92,7 +92,11 @@ void AppTask::AppTaskMain(void * pvParameter) ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ /* Init Device Endpoint */ Init_Bridge_Endpoint(); diff --git a/examples/light-switch-app/asr/BUILD.gn b/examples/light-switch-app/asr/BUILD.gn index 68f0db7fbe4ef7..8e2e620c18abea 100755 --- a/examples/light-switch-app/asr/BUILD.gn +++ b/examples/light-switch-app/asr/BUILD.gn @@ -86,6 +86,7 @@ asr_executable("light_switch_app") { ] sources = [ + "${examples_plat_dir}/ButtonHandler.cpp", "${examples_plat_dir}/CHIPDeviceManager.cpp", "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", @@ -93,9 +94,7 @@ asr_executable("light_switch_app") { "${examples_plat_dir}/shell/matter_shell.cpp", "src/AppTask.cpp", "src/BindingHandler.cpp", - "src/ButtonHandler.cpp", "src/DeviceCallbacks.cpp", - "src/LEDManager.cpp", "src/LightSwitch.cpp", "src/main.cpp", ] @@ -112,8 +111,6 @@ asr_executable("light_switch_app") { include_dirs += [ "${examples_plat_dir}/shell" ] } - defines += [ "GENERIC_SWITCH_ENDPOINT=1" ] - public_deps += [ "${chip_root}/examples/light-switch-app/light-switch-common" ] diff --git a/examples/light-switch-app/asr/README.md b/examples/light-switch-app/asr/README.md index c7eba7e2ea116e..ed3b65b82f0e36 100755 --- a/examples/light-switch-app/asr/README.md +++ b/examples/light-switch-app/asr/README.md @@ -5,19 +5,11 @@ This example demonstrates the Matter Light Switch application on ASR platform. --- - [Matter ASR Light Switch Example](#matter-asr-light-switch-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Testing the example](#testing-the-example) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer @@ -47,6 +39,6 @@ guides to get started This demo uses button to test changing the state of lighting: - | Name | Pin | - | :----: | :--: | - | BUTTON | PAD6 | + | Name | Pin | + | :----: | :---: | + | BUTTON | PAD12 | diff --git a/examples/light-switch-app/asr/include/AppConfig.h b/examples/light-switch-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 88fefe79fd45cc..b26ab4d8b89605 --- a/examples/light-switch-app/asr/include/AppConfig.h +++ b/examples/light-switch-app/asr/include/AppConfig.h @@ -18,34 +18,11 @@ #pragma once -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#include "asr_pinmux.h" -#define duet_gpio_dev_t asr_gpio_dev_t -#else -#include "duet_gpio.h" -#include "duet_pinmux.h" -#endif - #define TASK_NAME "APP" #define MATTER_DEVICE_NAME "ASR-Switch" #define APP_TASK_STACK_SIZE (4096) #define APP_EVENT_QUEUE_SIZE 10 -#define GPIO_TASK_NAME "gpio" -#define GPIO_TASK_STACK_SIZE 1024 - -#define BUTTON_DEBOUNCE_PERIOD_MS 50 - -#define BUTTON_PRESSED 0 -#define BUTTON_RELEASED 1 - -#define SWITCH1_BUTTON GPIO6_INDEX -#define SWITCH2_BUTTON GPIO7_INDEX -#define GENERIC_SWITCH_BUTTON GPIO7_INDEX -#define SYSTEM_STATE_LED GPIO12_INDEX -#define SWITCH_LED GPIO13_INDEX - // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/light-switch-app/asr/include/LEDManager.h b/examples/light-switch-app/asr/include/LEDManager.h deleted file mode 100644 index a8c29a24a61e07..00000000000000 --- a/examples/light-switch-app/asr/include/LEDManager.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright (c) 2022 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 "AppConfig.h" -#include - -#ifndef LED_Manager_H -#define LED_Manager_H - -class LEDManager -{ -public: - static void InitGpio(void); - void Init(uint8_t ledNum); - void Set(bool state); - void Invert(void); - void Blink(uint32_t changeRateMS); - void Blink(uint32_t onTimeMS, uint32_t offTimeMS); - void Animate(); - -private: - uint64_t mLastChangeTimeMS; - uint32_t mBlinkOnTimeMS; - uint32_t mBlinkOffTimeMS; - uint8_t mGPIONum; - bool mState; - duet_gpio_dev_t gpio; - - void DoSet(bool state); -}; - -#endif // LED_Manager_H diff --git a/examples/light-switch-app/asr/src/AppTask.cpp b/examples/light-switch-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index 8836459a7564f2..f398b3496edd0c --- a/examples/light-switch-app/asr/src/AppTask.cpp +++ b/examples/light-switch-app/asr/src/AppTask.cpp @@ -23,7 +23,7 @@ #include "ButtonHandler.h" #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" -#include "LEDManager.h" +#include "LEDWidget.h" #include "LightSwitch.h" #include "init_Matter.h" #include "lega_rtos_api.h" @@ -56,18 +56,12 @@ namespace { TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; -LEDManager sStatusLED; -LEDManager sSwitchLED; +LEDWidget sStatusLED; constexpr EndpointId kLightSwitch1_EndpointId = 1; -#if DUAL_LIGHTSWITCH_ENDPOINT -LightSwitch kLightSwitch2; -constexpr EndpointId kLightSwitch2_EndpointId = 2; -#endif -#if GENERIC_SWITCH_ENDPOINT + LightSwitch GenericSwitch; constexpr EndpointId kGenericSwitchEndpointId = 2; -#endif constexpr size_t kAppEventQueueSize = 10; @@ -176,20 +170,12 @@ CHIP_ERROR AppTask::Init() NetWorkCommissioningInstInit(); kLightSwitch1.Init(kLightSwitch1_EndpointId); -#if DUAL_LIGHTSWITCH_ENDPOINT - kLightSwitch2.Init(kLightSwitch2_EndpointId); -#endif -#if GENERIC_SWITCH_ENDPOINT + GenericSwitch.InitGeneric(kGenericSwitchEndpointId); -#endif // Initialize LEDs - LEDManager::InitGpio(); - - sStatusLED.Init(SYSTEM_STATE_LED); + sStatusLED.Init(LIGHT_LED); sStatusLED.Set(false); - sSwitchLED.Init(SWITCH_LED); - sSwitchLED.Set(false); UpdateStatusLED(); // Initialise WSTK buttons PB0 and PB1 (including debounce). @@ -202,7 +188,11 @@ CHIP_ERROR AppTask::Init() ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ return CHIP_NO_ERROR; } @@ -228,7 +218,6 @@ void AppTask::AppTaskMain(void * pvParameter) } sStatusLED.Animate(); - sSwitchLED.Animate(); } } @@ -278,26 +267,6 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState(void) {} -#define SWITCH_Toggle - -//#define SWITCH_DELAY_ONOFF - -#if DUAL_LIGHTSWITCH_ENDPOINT -#undef SWITCH_Toggle -#undef SWITCH_DELAY_ONOFF -#endif - -#ifdef SWITCH_DELAY_ONOFF -#define SWITCH_TIMER "switch_delay_timer" -#define SWITCH_DELAY_TIME 5 * 1000 -static TimerHandle_t Switch_TimerHandle; -void Switch_Delay_CallBack(TimerHandle_t xTimer) -{ - ASR_LOG("Switch1 OFF!"); - kLightSwitch1.InitiateActionSwitch(LightSwitch::Action::Off); -} -#endif - void AppTask::ButtonPushHandler(AppEvent * aEvent) { if (aEvent->Type == AppEvent::kEventType_Button) @@ -305,54 +274,11 @@ void AppTask::ButtonPushHandler(AppEvent * aEvent) switch (aEvent->ButtonEvent.PinNo) { case SWITCH1_BUTTON: -#ifdef SWITCH_Toggle - // ASR_LOG("Switch1 Button Pushed."); -#endif -#if DUAL_LIGHTSWITCH_ENDPOINT - ASR_LOG("Switch1 ON!"); - kLightSwitch1.InitiateActionSwitch(LightSwitch::Action::On); -#endif -#ifdef SWITCH_DELAY_ONOFF - { - ASR_LOG("Switch1 ON ,delay %d ms!", SWITCH_DELAY_TIME); - kLightSwitch1.InitiateActionSwitch(LightSwitch::Action::On); - - if (Switch_TimerHandle == NULL) - { - Switch_TimerHandle = - xTimerCreate(SWITCH_TIMER, pdMS_TO_TICKS(SWITCH_DELAY_TIME), pdFALSE, NULL, Switch_Delay_CallBack); - if (Switch_TimerHandle == NULL) - { - ASR_LOG("Failed to create a timer"); - } - } - if (xTimerIsTimerActive(Switch_TimerHandle)) - { - ASR_LOG("switch timer already started!"); - if (xTimerStop(Switch_TimerHandle, 0) == pdFAIL) - { - ASR_LOG("switch timer stop() failed"); - } - } - if (xTimerChangePeriod(Switch_TimerHandle, pdMS_TO_TICKS(SWITCH_DELAY_TIME), 100) != pdPASS) - { - ASR_LOG("switch timer start() failed"); - } - } -#endif break; -#if DUAL_LIGHTSWITCH_ENDPOINT case SWITCH2_BUTTON: - ASR_LOG("Switch2 ON!"); - kLightSwitch2.InitiateActionSwitch(LightSwitch::Action::On); - break; -#endif -#if GENERIC_SWITCH_ENDPOINT - case GENERIC_SWITCH_BUTTON: ASR_LOG("GenericSwitch: InitialPress"); GenericSwitch.GenericSwitchInitialPress(); break; -#endif default: break; } @@ -367,28 +293,13 @@ void AppTask::ButtonReleaseHandler(AppEvent * aEvent) switch (aEvent->ButtonEvent.PinNo) { case SWITCH1_BUTTON: -#ifdef SWITCH_Toggle - sSwitchLED.Set(false); ASR_LOG("Switch1 Toggle!"); kLightSwitch1.InitiateActionSwitch(LightSwitch::Action::Toggle); -#endif -#if DUAL_LIGHTSWITCH_ENDPOINT - ASR_LOG("Switch1 OFF!"); - kLightSwitch1.InitiateActionSwitch(LightSwitch::Action::Off); -#endif break; -#if DUAL_LIGHTSWITCH_ENDPOINT case SWITCH2_BUTTON: - ASR_LOG("Switch2 OFF!"); - kLightSwitch2.InitiateActionSwitch(LightSwitch::Action::Off); - break; -#endif -#if GENERIC_SWITCH_ENDPOINT - case GENERIC_SWITCH_BUTTON: ASR_LOG("GenericSwitch: ShortRelease"); GenericSwitch.GenericSwitchReleasePress(); break; -#endif default: break; } @@ -468,7 +379,6 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) sAppTask.PostEvent(&buttonEvent); } } -#if DUAL_LIGHTSWITCH_ENDPOINT else if (btnIdx == SWITCH2_BUTTON) { if (btnAction == BUTTON_PRESSED) @@ -486,24 +396,4 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) sAppTask.PostEvent(&buttonEvent); } } -#endif -#if GENERIC_SWITCH_ENDPOINT - else if (btnIdx == GENERIC_SWITCH_BUTTON) - { - if (btnAction == BUTTON_PRESSED) - { - buttonEvent.ButtonEvent.PinNo = GENERIC_SWITCH_BUTTON; - buttonEvent.ButtonEvent.Action = AppEvent::kButtonPushEvent; - buttonEvent.Handler = ButtonPushHandler; - sAppTask.PostEvent(&buttonEvent); - } - else if (btnAction == BUTTON_RELEASED) - { - buttonEvent.ButtonEvent.PinNo = GENERIC_SWITCH_BUTTON; - buttonEvent.ButtonEvent.Action = AppEvent::kButtonReleaseEvent; - buttonEvent.Handler = ButtonReleaseHandler; - sAppTask.PostEvent(&buttonEvent); - } - } -#endif } diff --git a/examples/light-switch-app/asr/src/LEDManager.cpp b/examples/light-switch-app/asr/src/LEDManager.cpp deleted file mode 100644 index 518f5c05186abf..00000000000000 --- a/examples/light-switch-app/asr/src/LEDManager.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Copyright (c) 2022 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. - */ - -#include "LEDManager.h" -#include "AppTask.h" -#include - -#ifdef CFG_PLF_RV32 -#define duet_gpio_init asr_gpio_init -#define duet_gpio_output_low asr_gpio_output_low -#define duet_gpio_output_high asr_gpio_output_high -#define DUET_OUTPUT_PUSH_PULL ASR_OUTPUT_PUSH_PULL -#endif - -void LEDManager::InitGpio(void) {} - -void LEDManager::Init(uint8_t gpioNum) -{ - mLastChangeTimeMS = 0; - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - mGPIONum = gpioNum; - - gpio.port = mGPIONum; - gpio.config = DUET_OUTPUT_PUSH_PULL; - duet_gpio_init(&gpio); -} - -void LEDManager::Invert(void) -{ - Set(!mState); -} - -void LEDManager::Set(bool state) -{ - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - DoSet(state); -} - -void LEDManager::Blink(uint32_t changeRateMS) -{ - Blink(changeRateMS, changeRateMS); -} - -void LEDManager::Blink(uint32_t onTimeMS, uint32_t offTimeMS) -{ - mBlinkOnTimeMS = onTimeMS; - mBlinkOffTimeMS = offTimeMS; - Animate(); -} - -void LEDManager::Animate() -{ - if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) - { - uint64_t nowMS = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - uint64_t stateDurMS = ((mState) ? mBlinkOnTimeMS : mBlinkOffTimeMS); - uint64_t nextChangeTimeMS = mLastChangeTimeMS + stateDurMS; - - if (nextChangeTimeMS < nowMS) - { - DoSet(!mState); - mLastChangeTimeMS = nowMS; - } - } -} - -void LEDManager::DoSet(bool state) -{ - mState = state; - - if (state) - { - duet_gpio_output_low(&gpio); - } - else - { - duet_gpio_output_high(&gpio); - } -} diff --git a/examples/lighting-app/asr/BUILD.gn b/examples/lighting-app/asr/BUILD.gn index 55b102fb25116f..3420374296aca5 100755 --- a/examples/lighting-app/asr/BUILD.gn +++ b/examples/lighting-app/asr/BUILD.gn @@ -42,6 +42,7 @@ asr_sdk_sources("lighting_app_sdk_sources") { defines = [ "ASR_LOG_ENABLED=1", + "LIGHT_SELECT_RGB", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", ] diff --git a/examples/lighting-app/asr/README.md b/examples/lighting-app/asr/README.md index c9b8009b8a35f1..234154ce8b2222 100755 --- a/examples/lighting-app/asr/README.md +++ b/examples/lighting-app/asr/README.md @@ -5,20 +5,12 @@ This example demonstrates the Matter Lighting application on ASR platform. --- - [Matter ASR Lighting Example](#matter-asr-lighting-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Cluster Control](#cluster-control) - [Indicate current state of lightbulb](#indicate-current-state-of-lightbulb) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer diff --git a/examples/lighting-app/asr/include/AppConfig.h b/examples/lighting-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index fd0622e3dae21e..911a15d47a4cde --- a/examples/lighting-app/asr/include/AppConfig.h +++ b/examples/lighting-app/asr/include/AppConfig.h @@ -27,8 +27,6 @@ #define APP_TASK_NAME "APP" -#define LIGHT_LED PWM_OUTPUT_CH4 - #define APP_TASK_STACK_SIZE (1024 * 4) #define MATTER_DEVICE_NAME "ASR-Lighting" diff --git a/examples/lighting-app/asr/src/AppTask.cpp b/examples/lighting-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index 619a71540c0759..3aba980a5414e6 --- a/examples/lighting-app/asr/src/AppTask.cpp +++ b/examples/lighting-app/asr/src/AppTask.cpp @@ -150,12 +150,16 @@ void AppTask::AppTaskMain(void * pvParameter) ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ -#if (LIGHT_SELECT == LIGHT_SELECT_LED) - lightLED.Init(LIGHT_LED); // embedded board light -#elif (LIGHT_SELECT == LIGHT_SELECT_RGB) +#ifdef LIGHT_SELECT_RGB lightLED.RGB_init(); +#else + lightLED.Init(LIGHT_LED); #endif /* get led onoff status and level value */ diff --git a/examples/lock-app/asr/BUILD.gn b/examples/lock-app/asr/BUILD.gn index 8e6b86822418d8..e4db0d8b2f7329 100755 --- a/examples/lock-app/asr/BUILD.gn +++ b/examples/lock-app/asr/BUILD.gn @@ -87,6 +87,7 @@ asr_executable("lock_app") { ] sources = [ + "${examples_plat_dir}/ButtonHandler.cpp", "${examples_plat_dir}/CHIPDeviceManager.cpp", "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", @@ -94,9 +95,7 @@ asr_executable("lock_app") { "${examples_plat_dir}/shell/matter_shell.cpp", "src/AppTask.cpp", "src/BoltLockManager.cpp", - "src/ButtonHandler.cpp", "src/DeviceCallbacks.cpp", - "src/LEDManager.cpp", "src/main.cpp", ] diff --git a/examples/lock-app/asr/README.md b/examples/lock-app/asr/README.md index 00c7bc0f8a37eb..1da71f5800fd44 100755 --- a/examples/lock-app/asr/README.md +++ b/examples/lock-app/asr/README.md @@ -8,20 +8,12 @@ reference for creating your own application. --- - [Matter ASR Lock Example](#matter-asr-lock-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Cluster Control](#cluster-control) - [Lock press button and lock status led](#lock-press-button-and-lock-status-led) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer @@ -52,5 +44,5 @@ show the state of these changes. | Name | Pin | | :---------: | :---: | -| LOCK-STATE | PAD13 | -| LOCK-BUTTON | PAD6 | +| LOCK-STATE | PAD7 | +| LOCK-BUTTON | PAD12 | diff --git a/examples/lock-app/asr/include/AppConfig.h b/examples/lock-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 60320f47c9f3c7..c7cace065e69ef --- a/examples/lock-app/asr/include/AppConfig.h +++ b/examples/lock-app/asr/include/AppConfig.h @@ -19,15 +19,6 @@ #pragma once -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#include "asr_pinmux.h" -#define duet_gpio_dev_t asr_gpio_dev_t -#else -#include "duet_gpio.h" -#include "duet_pinmux.h" -#endif - // ---- Lock Example App Config ---- #define APP_TASK_NAME "APP" @@ -38,20 +29,6 @@ #define MATTER_DEVICE_NAME "ASR-LOCK" -#define APP_LOCK_BUTTON_IDX 0 -#define APP_FUNCTION_BUTTON_IDX 1 - -#define APP_LOCK_BUTTON GPIO6_INDEX -#define APP_FUNCTION_BUTTON GPIO7_INDEX - -#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50 - -#define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - -#define SYSTEM_STATE_LED GPIO12_INDEX -#define LOCK_STATE_LED GPIO13_INDEX - #define FACTORY_RESET_TRIGGER_TIMEOUT 3000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 diff --git a/examples/lock-app/asr/include/ButtonHandler.h b/examples/lock-app/asr/include/ButtonHandler.h deleted file mode 100755 index 978cad1937b8d9..00000000000000 --- a/examples/lock-app/asr/include/ButtonHandler.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * 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 - -#include - -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer suppo -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#define duet_gpio_dev_t asr_gpio_dev_t -#define DUET_INPUT_PULL_UP ASR_INPUT_PULL_UP -#define duet_gpio_init asr_gpio_init -#define duet_gpio_output_low asr_gpio_output_low -#define duet_gpio_output_high asr_gpio_output_high -#define duet_gpio_input_get asr_gpio_input_get -#define duet_gpio_enable_irq asr_gpio_enable_irq -#define DUET_IRQ_TRIGGER_FALLING_EDGE ASR_IRQ_TRIGGER_FALLING_EDGE -#else -#include "duet_gpio.h" -#endif - -#define GPIO_INTERRUPT_PRIORITY (5) - -class ButtonHandler -{ -public: - static void Init(void); - -private: - static void GpioInit(void); - static void lockbuttonIsr(void * handler_arg); - static void functionbuttonIsr(void * handler_arg); - static void TimerCallback(TimerHandle_t xTimer); -}; diff --git a/examples/lock-app/asr/include/LEDManager.h b/examples/lock-app/asr/include/LEDManager.h deleted file mode 100644 index b64d1e88e8c17c..00000000000000 --- a/examples/lock-app/asr/include/LEDManager.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright (c) 2020 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 "AppConfig.h" -#include - -#ifndef LED_Manager_H -#define LED_Manager_H - -class LEDManager -{ -public: - void InitGpio(void); - void Init(uint8_t ledNum); - void Set(bool state); - void Invert(void); - void Blink(uint32_t changeRateMS); - void Blink(uint32_t onTimeMS, uint32_t offTimeMS); - void Animate(); - -private: - uint64_t mLastChangeTimeMS; - uint32_t mBlinkOnTimeMS; - uint32_t mBlinkOffTimeMS; - uint8_t mGPIONum; - bool mState; - duet_gpio_dev_t gpio; - - void DoSet(bool state); -}; - -#endif // LED_Manager_H diff --git a/examples/lock-app/asr/src/AppTask.cpp b/examples/lock-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index d46069955dc6ab..36d53399a991f1 --- a/examples/lock-app/asr/src/AppTask.cpp +++ b/examples/lock-app/asr/src/AppTask.cpp @@ -22,7 +22,7 @@ #include "ButtonHandler.h" #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" -#include "LEDManager.h" +#include "LEDWidget.h" #include "qrcodegen.h" #include #include @@ -51,8 +51,8 @@ TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; -LEDManager sStatusLED; -LEDManager sLockLED; +LEDWidget sStatusLED; +LEDWidget sLockLED; bool sIsWiFiStationEnabled = false; bool sIsWiFiStationConnected = false; @@ -147,16 +147,20 @@ CHIP_ERROR AppTask::Init() BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted); // Initialize LEDs - sStatusLED.Init(SYSTEM_STATE_LED); + sStatusLED.Init(LIGHT_LED); sStatusLED.Set(0); - sLockLED.Init(LOCK_STATE_LED); + sLockLED.Init(STATE_LED); sLockLED.Set(!BoltLockMgr().IsUnlocked()); ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ return err; } @@ -254,7 +258,7 @@ void AppTask::LockActionEventHandler(AppEvent * event) void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) { - if (btnIdx != APP_LOCK_BUTTON_IDX && btnIdx != APP_FUNCTION_BUTTON_IDX) + if (btnIdx != SWITCH1_BUTTON && btnIdx != SWITCH2_BUTTON) { return; } @@ -264,12 +268,12 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) button_event.ButtonEvent.ButtonIdx = btnIdx; button_event.ButtonEvent.Action = btnAction; - if (btnIdx == APP_LOCK_BUTTON_IDX) + if (btnIdx == SWITCH1_BUTTON) { button_event.Handler = LockActionEventHandler; sAppTask.PostEvent(&button_event); } - else if (btnIdx == APP_FUNCTION_BUTTON_IDX) + else if (btnIdx == SWITCH2_BUTTON) { button_event.Handler = FunctionHandler; sAppTask.PostEvent(&button_event); @@ -322,18 +326,11 @@ void AppTask::FunctionTimerEventHandler(AppEvent * event) void AppTask::FunctionHandler(AppEvent * event) { - if (event->ButtonEvent.ButtonIdx != APP_FUNCTION_BUTTON_IDX) + if (event->ButtonEvent.ButtonIdx != SWITCH2_BUTTON) { return; } - // 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 (event->ButtonEvent.Action == APP_BUTTON_RELEASED) + if (event->ButtonEvent.Action == BUTTON_RELEASED) { if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kNoneSelected) { diff --git a/examples/lock-app/asr/src/ButtonHandler.cpp b/examples/lock-app/asr/src/ButtonHandler.cpp deleted file mode 100644 index b74f1befd4652d..00000000000000 --- a/examples/lock-app/asr/src/ButtonHandler.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * 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 "ButtonHandler.h" -#include "AppConfig.h" -#include "AppTask.h" - -namespace { -constexpr int kButtonCount = 2; - -TimerHandle_t buttonTimers[kButtonCount]; // FreeRTOS timers used for debouncing -// buttons. Array to hold handles to -// the created timers. - -} // namespace - -void ButtonHandler::Init(void) -{ - GpioInit(); - // Create FreeRTOS sw timers for debouncing buttons. - for (uint8_t i = 0; i < kButtonCount; i++) - { - buttonTimers[i] = xTimerCreate("BtnTmr", // Just a text name, not used by the RTOS kernel - APP_BUTTON_DEBOUNCE_PERIOD_MS, // timer period - false, // no timer reload (==one-shot) - (void *) (int) i, // init timer id = button index - TimerCallback // timer callback handler (all buttons use - // the same timer cn function) - ); - } -} - -// port pin -duet_gpio_dev_t lock_btn; -duet_gpio_dev_t func_btn; - -void ButtonHandler::GpioInit(void) -{ - // lock button - lock_btn.port = APP_LOCK_BUTTON; - lock_btn.config = DUET_INPUT_PULL_UP; - lock_btn.priv = NULL; - duet_gpio_init(&lock_btn); - duet_gpio_enable_irq(&lock_btn, DUET_IRQ_TRIGGER_FALLING_EDGE, lockbuttonIsr, NULL); - - // function button - func_btn.port = APP_FUNCTION_BUTTON; - func_btn.config = DUET_INPUT_PULL_UP; - func_btn.priv = NULL; - duet_gpio_init(&func_btn); - duet_gpio_enable_irq(&func_btn, DUET_IRQ_TRIGGER_FALLING_EDGE, functionbuttonIsr, NULL); -} - -void ButtonHandler::lockbuttonIsr(void * handler_arg) -{ - portBASE_TYPE taskWoken = pdFALSE; - xTimerStartFromISR(buttonTimers[APP_LOCK_BUTTON_IDX], &taskWoken); -} - -void ButtonHandler::functionbuttonIsr(void * handler_arg) -{ - portBASE_TYPE taskWoken = pdFALSE; - xTimerStartFromISR(buttonTimers[APP_FUNCTION_BUTTON_IDX], &taskWoken); -} - -void ButtonHandler::TimerCallback(TimerHandle_t xTimer) -{ - // Get the button index of the expired timer and call button event helper. - uint32_t timerId; - uint8_t buttonevent = 0; - uint32_t btnValue; - - timerId = (uint32_t) pvTimerGetTimerID(xTimer); - if (timerId == APP_LOCK_BUTTON_IDX) - { - duet_gpio_input_get(&lock_btn, &btnValue); - buttonevent = (uint8_t) btnValue; - } - else - { - duet_gpio_input_get(&func_btn, &btnValue); - buttonevent = (uint8_t) btnValue; - } - GetAppTask().ButtonEventHandler(timerId, (buttonevent) ? APP_BUTTON_PRESSED : APP_BUTTON_RELEASED); -} diff --git a/examples/lock-app/asr/src/LEDManager.cpp b/examples/lock-app/asr/src/LEDManager.cpp deleted file mode 100644 index c5e140f98487b6..00000000000000 --- a/examples/lock-app/asr/src/LEDManager.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Copyright (c) 2018 Nest Labs, Inc. - * 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 "LEDManager.h" -#include "AppTask.h" -#include - -#ifdef CFG_PLF_RV32 -#define duet_gpio_init asr_gpio_init -#define duet_gpio_output_low asr_gpio_output_low -#define duet_gpio_output_high asr_gpio_output_high -#define DUET_OUTPUT_PUSH_PULL ASR_OUTPUT_PUSH_PULL -#endif - -void LEDManager::InitGpio(void) {} - -void LEDManager::Init(uint8_t gpioNum) -{ - mLastChangeTimeMS = 0; - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - mGPIONum = gpioNum; - - gpio.port = mGPIONum; - gpio.config = DUET_OUTPUT_PUSH_PULL; - duet_gpio_init(&gpio); -} - -void LEDManager::Invert(void) -{ - Set(!mState); -} - -void LEDManager::Set(bool state) -{ - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - DoSet(state); -} - -void LEDManager::Blink(uint32_t changeRateMS) -{ - Blink(changeRateMS, changeRateMS); -} - -void LEDManager::Blink(uint32_t onTimeMS, uint32_t offTimeMS) -{ - mBlinkOnTimeMS = onTimeMS; - mBlinkOffTimeMS = offTimeMS; - Animate(); -} - -void LEDManager::Animate() -{ - if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) - { - uint64_t nowMS = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - uint64_t stateDurMS = ((mState) ? mBlinkOnTimeMS : mBlinkOffTimeMS); - uint64_t nextChangeTimeMS = mLastChangeTimeMS + stateDurMS; - - if (nextChangeTimeMS < nowMS) - { - DoSet(!mState); - mLastChangeTimeMS = nowMS; - } - } -} - -void LEDManager::DoSet(bool state) -{ - mState = state; - - if (state) - { - duet_gpio_output_low(&gpio); - } - else - { - duet_gpio_output_high(&gpio); - } -} diff --git a/examples/ota-requestor-app/asr/BUILD.gn b/examples/ota-requestor-app/asr/BUILD.gn index 93b0b4a0673bec..e4365a59d2ea9b 100755 --- a/examples/ota-requestor-app/asr/BUILD.gn +++ b/examples/ota-requestor-app/asr/BUILD.gn @@ -72,7 +72,6 @@ asr_executable("ota_requestor_app") { sources = [ "${examples_plat_dir}/CHIPDeviceManager.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", "${examples_plat_dir}/init_asrPlatform.cpp", "${examples_plat_dir}/shell/matter_shell.cpp", diff --git a/examples/ota-requestor-app/asr/README.md b/examples/ota-requestor-app/asr/README.md index 1a907d4637a5ab..7af3c25e92781e 100755 --- a/examples/ota-requestor-app/asr/README.md +++ b/examples/ota-requestor-app/asr/README.md @@ -5,19 +5,11 @@ This example demonstrates the Matter OTA Requestor application on ASR platform. --- - [Matter ASR OTA Requestor Example](#matter-asr-ota-requestor-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Testing the example](#testing-the-example) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer diff --git a/examples/ota-requestor-app/asr/include/AppConfig.h b/examples/ota-requestor-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 826ebfd44f3793..b6a75bfa03e486 --- a/examples/ota-requestor-app/asr/include/AppConfig.h +++ b/examples/ota-requestor-app/asr/include/AppConfig.h @@ -25,8 +25,6 @@ #define APP_TASK_NAME "APP" #define APP_TASK_STACK_SIZE (1024 * 4) -#define LIGHT_LED PWM_OUTPUT_CH3 - // ASR Logging #ifdef __cplusplus extern "C" { diff --git a/examples/ota-requestor-app/asr/src/AppTask.cpp b/examples/ota-requestor-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index 3eb7cd14b69aec..56910e92019f55 --- a/examples/ota-requestor-app/asr/src/AppTask.cpp +++ b/examples/ota-requestor-app/asr/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" -#include "LEDWidget.h" #include "init_Matter.h" #include "qrcodegen.h" #include @@ -37,8 +36,6 @@ namespace { TaskHandle_t sAppTaskHandle; } // namespace -LEDWidget lightLED; - using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; @@ -95,9 +92,12 @@ void AppTask::AppTaskMain(void * pvParameter) ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ - lightLED.Init(LIGHT_LED); /* Delete task */ vTaskDelete(NULL); } diff --git a/examples/light-switch-app/asr/src/ButtonHandler.cpp b/examples/platform/asr/ButtonHandler.cpp similarity index 88% rename from examples/light-switch-app/asr/src/ButtonHandler.cpp rename to examples/platform/asr/ButtonHandler.cpp index c0d521bc9d8858..05c1ded81f7e30 100644 --- a/examples/light-switch-app/asr/src/ButtonHandler.cpp +++ b/examples/platform/asr/ButtonHandler.cpp @@ -22,9 +22,15 @@ #include #ifdef CFG_PLF_RV32 +#define duet_gpio_dev_t asr_gpio_dev_t #define duet_gpio_init asr_gpio_init #define duet_gpio_input_get asr_gpio_input_get #define DUET_INPUT_PULL_UP ASR_INPUT_PULL_UP +#elif !defined CFG_PLF_DUET +#define duet_gpio_dev_t lega_gpio_dev_t +#define duet_gpio_init lega_gpio_init +#define duet_gpio_input_get lega_gpio_input_get +#define DUET_INPUT_PULL_UP LEGA_INPUT_PULL_UP #endif TaskHandle_t sGpioTaskHandle; @@ -48,14 +54,8 @@ void ButtonHandler::GpioInit(void) switch1_btn.config = DUET_INPUT_PULL_UP; switch1_btn.priv = NULL; duet_gpio_init(&switch1_btn); -#if DUAL_LIGHTSWITCH_ENDPOINT - // light switch2 button - switch2_btn.port = SWITCH2_BUTTON; -#endif -#if GENERIC_SWITCH_ENDPOINT // generic switch2 button - switch2_btn.port = GENERIC_SWITCH_BUTTON; -#endif + switch2_btn.port = SWITCH2_BUTTON; switch2_btn.config = DUET_INPUT_PULL_UP; switch2_btn.priv = NULL; duet_gpio_init(&switch2_btn); @@ -101,12 +101,7 @@ void GpioTaskMain(void * pvParameter) { btn2Value = btnValue; buttonevent = (uint8_t) btnValue; -#if DUAL_LIGHTSWITCH_ENDPOINT GetAppTask().ButtonEventHandler(SWITCH2_BUTTON, (buttonevent) ? BUTTON_RELEASED : BUTTON_PRESSED); -#endif -#if GENERIC_SWITCH_ENDPOINT - GetAppTask().ButtonEventHandler(GENERIC_SWITCH_BUTTON, (buttonevent) ? BUTTON_RELEASED : BUTTON_PRESSED); -#endif btn2_trigger = 0; } else diff --git a/examples/light-switch-app/asr/include/ButtonHandler.h b/examples/platform/asr/ButtonHandler.h old mode 100644 new mode 100755 similarity index 80% rename from examples/light-switch-app/asr/include/ButtonHandler.h rename to examples/platform/asr/ButtonHandler.h index 8e853ba46b1da1..2d027355fa4029 --- a/examples/light-switch-app/asr/include/ButtonHandler.h +++ b/examples/platform/asr/ButtonHandler.h @@ -24,10 +24,21 @@ #include #ifdef CFG_PLF_RV32 #include "asr_gpio.h" -#else +#elif defined CFG_PLF_DUET #include "duet_gpio.h" +#else +#include "lega_gpio.h" #endif +#define SWITCH1_BUTTON GPIO12_INDEX +#define SWITCH2_BUTTON GPIO13_INDEX + +#define BUTTON_PRESSED 0 +#define BUTTON_RELEASED 1 + +#define GPIO_TASK_NAME "gpio" +#define GPIO_TASK_STACK_SIZE 1024 + class ButtonHandler { public: diff --git a/examples/platform/asr/LEDWidget.cpp b/examples/platform/asr/LEDWidget.cpp old mode 100644 new mode 100755 index f89f502f7ff62f..5364bd1620b850 --- a/examples/platform/asr/LEDWidget.cpp +++ b/examples/platform/asr/LEDWidget.cpp @@ -17,20 +17,6 @@ */ #include "LEDWidget.h" -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#include "asr_pinmux.h" -#include "asr_pwm.h" -#define duet_pwm_dev_t asr_pwm_dev_t -#define duet_pwm_config_t asr_pwm_config_t -#define duet_pwm_para_chg asr_pwm_para_chg -#define duet_pwm_init asr_pwm_init -#define duet_pwm_start asr_pwm_start -#else -#include "duet_gpio.h" -#include "duet_pinmux.h" -#include "duet_pwm.h" -#endif #include "AppConfig.h" #include @@ -51,6 +37,7 @@ // PWM period in micro seconds #define LED_PWM_PERIOD_US (255u) +#ifdef LIGHT_SELECT_RGB static void show_pwm(duet_pwm_dev_t * pwm_dev, uint8_t val) { duet_pwm_config_t pwm_cfg; @@ -71,6 +58,7 @@ static void init_pwm(duet_pwm_dev_t * pwm_dev, uint8_t ledNum, uint8_t val) pwm_dev->priv = NULL; duet_pwm_init(pwm_dev); } +#endif void LEDWidget::Init(uint8_t ledNum) { @@ -81,7 +69,7 @@ void LEDWidget::Init(uint8_t ledNum) mbrightness = LED_MIN_BRIGHTNESS; mHue = 0; mSaturation = 0; - +#ifdef LIGHT_SELECT_RGB if (ledNum == LIGHT_RGB_GREEN) { #ifdef CFG_PLF_RV32 @@ -103,6 +91,11 @@ void LEDWidget::Init(uint8_t ledNum) #endif init_pwm(&pwm_led, ledNum, LED_MIN_BRIGHTNESS); } +#else + gpio.port = ledNum; + gpio.config = DUET_OUTPUT_PUSH_PULL; + duet_gpio_init(&gpio); +#endif } void LEDWidget::Invert(void) @@ -153,11 +146,16 @@ void LEDWidget::DoSet(bool state) { if (mState != state) { +#ifdef LIGHT_SELECT_RGB (state) ? PWM_start() : PWM_stop(); +#else + (state) ? duet_gpio_output_low(&gpio) : duet_gpio_output_high(&gpio); +#endif } mState = state; } +#ifdef LIGHT_SELECT_RGB void LEDWidget::RGB_init() { Init(LIGHT_RGB_RED); // red light of RGB @@ -175,7 +173,6 @@ void LEDWidget::PWM_start() ASR_LOG("PWM failed to start!"); } -#if (LIGHT_SELECT == LIGHT_SELECT_RGB) /* Start PWM to turn the LED on */ if (0 != duet_pwm_start(&pwm_led_g)) { @@ -187,7 +184,6 @@ void LEDWidget::PWM_start() { ASR_LOG("PWM failed to start!"); } -#endif mState = 1; } } @@ -272,9 +268,8 @@ void LEDWidget::showRGB(uint8_t red, uint8_t green, uint8_t blue) { show_pwm(&pwm_led, red); -#if (LIGHT_SELECT == LIGHT_SELECT_RGB) show_pwm(&pwm_led_g, green); show_pwm(&pwm_led_b, blue); -#endif } +#endif diff --git a/examples/platform/asr/LEDWidget.h b/examples/platform/asr/LEDWidget.h old mode 100644 new mode 100755 index 028a852fba1933..99ae3d4d623877 --- a/examples/platform/asr/LEDWidget.h +++ b/examples/platform/asr/LEDWidget.h @@ -20,10 +20,37 @@ #include #ifdef CFG_PLF_RV32 +#include "asr_gpio.h" +#include "asr_pinmux.h" #include "asr_pwm.h" #define duet_pwm_dev_t asr_pwm_dev_t -#else +#define duet_pwm_config_t asr_pwm_config_t +#define duet_pwm_para_chg asr_pwm_para_chg +#define duet_pwm_init asr_pwm_init +#define duet_pwm_start asr_pwm_start +#define duet_gpio_dev_t asr_gpio_dev_t +#define duet_gpio_init asr_gpio_init +#define duet_gpio_output_low asr_gpio_output_low +#define duet_gpio_output_high asr_gpio_output_high +#define DUET_OUTPUT_PUSH_PULL ASR_OUTPUT_PUSH_PULL +#elif defined CFG_PLF_DUET +#include "duet_gpio.h" +#include "duet_pinmux.h" #include "duet_pwm.h" +#else +#include "lega_gpio.h" +#include "lega_pinmux.h" +#include "lega_pwm.h" +#define duet_pwm_dev_t lega_pwm_dev_t +#define duet_pwm_config_t lega_pwm_config_t +#define duet_pwm_para_chg lega_pwm_para_chg +#define duet_pwm_init lega_pwm_init +#define duet_pwm_start lega_pwm_start +#define duet_gpio_dev_t lega_gpio_dev_t +#define duet_gpio_init lega_gpio_init +#define duet_gpio_output_low lega_gpio_output_low +#define duet_gpio_output_high lega_gpio_output_high +#define DUET_OUTPUT_PUSH_PULL LEGA_OUTPUT_PUSH_PULL #endif #ifdef __cplusplus extern "C" { @@ -33,10 +60,6 @@ void RGB_setup_HSB(uint8_t Hue, uint8_t Saturation); } #endif -#define LIGHT_SELECT_LED 1 -#define LIGHT_SELECT_RGB 2 -#define LIGHT_SELECT LIGHT_SELECT_RGB - #define LIGHT_RGB_RED PWM_OUTPUT_CH6 #define LIGHT_RGB_GREEN PWM_OUTPUT_CH4 #define LIGHT_RGB_BLUE PWM_OUTPUT_CH1 @@ -45,10 +68,12 @@ void RGB_setup_HSB(uint8_t Hue, uint8_t Saturation); #define LIGHT_RGB_GREEN_PAD PAD6 #define LIGHT_RGB_BLUE_PAD PAD10 +#define LIGHT_LED GPIO6_INDEX +#define STATE_LED GPIO7_INDEX + class LEDWidget { public: - static void InitGpio(void); void Init(uint8_t port); void Set(bool state); bool Get(void); @@ -58,12 +83,13 @@ class LEDWidget void Animate(); void PWM_start(); void PWM_stop(); +#ifdef LIGHT_SELECT_RGB void RGB_init(); void SetBrightness(uint8_t brightness); void SetColor(uint8_t Hue, uint8_t Saturation); void HSB2rgb(uint16_t Hue, uint8_t Saturation, uint8_t brightness, uint8_t & red, uint8_t & green, uint8_t & blue); void showRGB(uint8_t red, uint8_t green, uint8_t blue); - +#endif private: uint64_t mLastChangeTimeMS = 0; uint32_t mBlinkOnTimeMS = 0; @@ -73,8 +99,12 @@ class LEDWidget uint8_t mHue; uint8_t mSaturation; +#ifdef LIGHT_SELECT_RGB duet_pwm_dev_t pwm_led; duet_pwm_dev_t pwm_led_g; duet_pwm_dev_t pwm_led_b; +#else + duet_gpio_dev_t gpio; +#endif void DoSet(bool state); }; diff --git a/examples/platform/asr/init_asrPlatform.cpp b/examples/platform/asr/init_asrPlatform.cpp old mode 100644 new mode 100755 index b91419812b88a9..2992015c1abd97 --- a/examples/platform/asr/init_asrPlatform.cpp +++ b/examples/platform/asr/init_asrPlatform.cpp @@ -36,15 +36,22 @@ #include "asr_pinmux.h" #include "asr_sec_hw_common.h" #include "asr_uart.h" -#else +#elif defined CFG_PLF_DUET #include "duet_flash_kv.h" #include "duet_pinmux.h" #include "duet_uart.h" #include "duet_version.h" +#else +#include "lega_flash_kv.h" +#include "lega_pinmux.h" +#include "lega_uart.h" +#include "lega_version.h" #endif #include "lega_ota_utils.h" #include "lega_rtos_api.h" +#if defined(CFG_PLF_RV32) || defined(CFG_PLF_DUET) #include "printf_uart.h" +#endif #include "tcpip.h" #if (CFG_EASY_LOG_ENABLE == 1) #include "elog.h" @@ -58,10 +65,15 @@ #define duet_pinmux_config asr_pinmux_config #define duet_uart_init printf_uart_init #define duet_flash_kv_init alto_flash_kv_init -#else +#elif defined CFG_PLF_DUET #define LEGA_UART0_INDEX DUET_UART0_INDEX #define LEGA_UART1_INDEX DUET_UART1_INDEX #define LEGA_UART2_INDEX DUET_UART2_INDEX +#else +#define duet_pinmux_config lega_pinmux_config +#define duet_uart_init lega_uart_init +#define duet_flash_kv_init lega_flash_kv_init +#define UART1_INDEX LEGA_UART1_INDEX #endif #define UART1_TX_PIN PAD2 @@ -69,8 +81,10 @@ #ifdef CFG_PLF_RV32 extern asr_uart_dev_t lega_at_uart; -#else +#elif defined CFG_PLF_DUET extern duet_uart_dev_t lega_at_uart; +#else +extern lega_uart_dev_t lega_at_uart; #endif #ifdef __cplusplus @@ -102,10 +116,10 @@ void at_uart_init(void) lega_at_uart.config.stop_bits = STOP_1BIT; lega_at_uart.config.mode = TX_RX_MODE; lega_at_uart.port = UART1_INDEX; - +#if defined CFG_PLF_RV32 || defined CFG_PLF_DUET duet_pinmux_config(UART1_TX_PIN, PF_UART1); duet_pinmux_config(UART1_RX_PIN, PF_UART1); - +#endif // register uart callback func for receiving at command lega_at_uart.priv = (void *) (at_handle_uartirq); duet_uart_init(&lega_at_uart); @@ -144,13 +158,13 @@ void init_asrPlatform(void) elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME); elog_start(); #endif - +#if defined CFG_PLF_RV32 || defined CFG_PLF_DUET lega_wlan_efuse_read(); lega_sram_rf_pta_init(); lega_recovery_phy_fsm_config(); - +#endif asr_security_engine_init(); #if !CONFIG_ENABLE_CHIP_SHELL lega_at_init(); diff --git a/examples/temperature-measurement-app/asr/BUILD.gn b/examples/temperature-measurement-app/asr/BUILD.gn index 6a8e4f76990449..12806d35bd46f4 100755 --- a/examples/temperature-measurement-app/asr/BUILD.gn +++ b/examples/temperature-measurement-app/asr/BUILD.gn @@ -89,7 +89,6 @@ asr_executable("temperature_measurement_app") { sources = [ "${examples_plat_dir}/CHIPDeviceManager.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", "${examples_plat_dir}/init_asrPlatform.cpp", "${examples_plat_dir}/shell/matter_shell.cpp", diff --git a/examples/temperature-measurement-app/asr/README.md b/examples/temperature-measurement-app/asr/README.md index 4151259686e80a..72c01f8973dcdd 100755 --- a/examples/temperature-measurement-app/asr/README.md +++ b/examples/temperature-measurement-app/asr/README.md @@ -6,19 +6,11 @@ temperature sensor. --- - [Matter ASR Temperature Measurement Example](#matter-asr-temperature-measurement-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Cluster Control](#cluster-control) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer diff --git a/examples/temperature-measurement-app/asr/include/AppConfig.h b/examples/temperature-measurement-app/asr/include/AppConfig.h old mode 100644 new mode 100755 index 4955ee049d07ad..ba7a287d466d73 --- a/examples/temperature-measurement-app/asr/include/AppConfig.h +++ b/examples/temperature-measurement-app/asr/include/AppConfig.h @@ -19,14 +19,6 @@ #pragma once -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#include "asr_pinmux.h" -#define duet_gpio_dev_t asr_gpio_dev_t -#else -#include "duet_gpio.h" -#include "duet_pinmux.h" -#endif // ---- Lock Example App Config ---- #define APP_TASK_NAME "APP" @@ -35,20 +27,6 @@ #define MATTER_DEVICE_NAME "ASR-Temperature" -#define APP_LOCK_BUTTON_IDX 0 -#define APP_FUNCTION_BUTTON_IDX 1 - -#define APP_LOCK_BUTTON GPIO10_INDEX -#define APP_FUNCTION_BUTTON GPIO11_INDEX - -#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50 - -#define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - -#define SYSTEM_STATE_LED GPIO12_INDEX -#define LOCK_STATE_LED GPIO13_INDEX - // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/temperature-measurement-app/asr/src/AppTask.cpp b/examples/temperature-measurement-app/asr/src/AppTask.cpp old mode 100644 new mode 100755 index bdb37a20e6c7fd..4d0fd57f527bb6 --- a/examples/temperature-measurement-app/asr/src/AppTask.cpp +++ b/examples/temperature-measurement-app/asr/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" -#include "LEDWidget.h" #include "qrcodegen.h" #include #include @@ -39,8 +38,6 @@ namespace { TaskHandle_t sAppTaskHandle; } // namespace -LEDWidget lightLED; - using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; @@ -97,7 +94,11 @@ void AppTask::AppTaskMain(void * pvParameter) ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ /* Delete task */ vTaskDelete(NULL); diff --git a/examples/thermostat/asr/BUILD.gn b/examples/thermostat/asr/BUILD.gn index cc972b5b162163..3b782253cab086 100755 --- a/examples/thermostat/asr/BUILD.gn +++ b/examples/thermostat/asr/BUILD.gn @@ -90,7 +90,6 @@ asr_executable("thermostat") { sources = [ "${examples_plat_dir}/CHIPDeviceManager.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_Matter.cpp", "${examples_plat_dir}/init_asrPlatform.cpp", "${examples_plat_dir}/shell/matter_shell.cpp", diff --git a/examples/thermostat/asr/README.md b/examples/thermostat/asr/README.md index f582c1b97e045e..0392b82086ca2d 100755 --- a/examples/thermostat/asr/README.md +++ b/examples/thermostat/asr/README.md @@ -6,19 +6,11 @@ temperature from local sensor. --- - [Matter ASR Thermostat Example](#matter-asr-thermostat-example) - - [Supported Chips](#supported-chips) - [Building and Commissioning](#building-and-commissioning) - [Cluster Control](#cluster-control) --- -## Supported Chips - -The Matter demo application is supported on: - -- ASR582X -- ASR595X - ## Building and Commissioning Please refer diff --git a/examples/thermostat/asr/include/AppConfig.h b/examples/thermostat/asr/include/AppConfig.h old mode 100644 new mode 100755 index 86c67695c016bc..1a8d5f871cbc2f --- a/examples/thermostat/asr/include/AppConfig.h +++ b/examples/thermostat/asr/include/AppConfig.h @@ -19,15 +19,6 @@ #pragma once -#ifdef CFG_PLF_RV32 -#include "asr_gpio.h" -#include "asr_pinmux.h" -#define duet_gpio_dev_t asr_gpio_dev_t -#else -#include "duet_gpio.h" -#include "duet_pinmux.h" -#endif - // ---- Lock Example App Config ---- #define APP_TASK_NAME "APP" @@ -37,20 +28,6 @@ #define MATTER_DEVICE_NAME "ASR-Thermostat" -#define APP_LOCK_BUTTON_IDX 0 -#define APP_FUNCTION_BUTTON_IDX 1 - -#define APP_LOCK_BUTTON GPIO10_INDEX -#define APP_FUNCTION_BUTTON GPIO11_INDEX - -#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50 - -#define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - -#define SYSTEM_STATE_LED GPIO12_INDEX -#define LOCK_STATE_LED GPIO13_INDEX - // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/thermostat/asr/src/AppTask.cpp b/examples/thermostat/asr/src/AppTask.cpp old mode 100644 new mode 100755 index 544c3c42108be2..dbdf8a853b3d75 --- a/examples/thermostat/asr/src/AppTask.cpp +++ b/examples/thermostat/asr/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" -#include "LEDWidget.h" #include "init_Matter.h" #include "qrcodegen.h" @@ -66,7 +65,6 @@ void NetWorkCommissioningInstInit() AppTask AppTask::sAppTask; static DeviceCallbacks EchoCallbacks; -LEDWidget lightLED; CHIP_ERROR AppTask::StartAppTask() { @@ -101,7 +99,11 @@ CHIP_ERROR AppTask::Init() ConfigurationMgr().LogDeviceConfig(); // Print setup info +#if CONFIG_NETWORK_LAYER_BLE PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ CHIP_ERROR err; err = SensorMgr().Init(); diff --git a/src/lib/shell/streamer_asr.cpp b/src/lib/shell/streamer_asr.cpp old mode 100644 new mode 100755 index ffc48c7df2e317..dc5244c40ad7d8 --- a/src/lib/shell/streamer_asr.cpp +++ b/src/lib/shell/streamer_asr.cpp @@ -26,9 +26,15 @@ #include "asr_uart.h" #define duet_uart_set_callback asr_uart_set_callback #define duet_uart_callback_func asr_uart_callback_func_t -#else +#elif defined CFG_PLF_DUET #include "duet_uart.h" +#else +#include "lega_uart.h" +#define duet_uart_set_callback lega_uart_set_callback +#define duet_uart_callback_func lega_uart_callback_func +#define UART1_INDEX LEGA_UART1_INDEX #endif + namespace chip { namespace Shell { namespace { diff --git a/src/platform/ASR/BUILD.gn b/src/platform/ASR/BUILD.gn index b1de3eaf3c2af9..8931e3ebd5f664 100755 --- a/src/platform/ASR/BUILD.gn +++ b/src/platform/ASR/BUILD.gn @@ -29,8 +29,6 @@ static_library("ASR") { "ASRFactoryDataProvider.cpp", "ASRUtils.cpp", "ASRUtils.h", - "BLEManagerImpl.cpp", - "BLEManagerImpl.h", "BlePlatformConfig.h", "CHIPDevicePlatformConfig.h", "CHIPDevicePlatformEvent.h", @@ -59,6 +57,8 @@ static_library("ASR") { sources += [ "BLEAppSvc.cpp", "BLEAppSvc.h", + "BLEManagerImpl.cpp", + "BLEManagerImpl.h", ] } diff --git a/src/platform/ASR/CHIPDevicePlatformConfig.h b/src/platform/ASR/CHIPDevicePlatformConfig.h old mode 100644 new mode 100755 index e1f2e25ef23c30..581267440fee87 --- a/src/platform/ASR/CHIPDevicePlatformConfig.h +++ b/src/platform/ASR/CHIPDevicePlatformConfig.h @@ -31,7 +31,13 @@ #define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY 1 #define CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS 1 +#if defined(CFG_PLF_RV32) || defined(CFG_PLF_DUET) +// ASR582X/ASR595X support Wi-Fi and BLE #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 +#else +// ASR550X support Wi-Fi only +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0 +#endif #define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE 25 diff --git a/src/platform/ASR/ConfigurationManagerImpl.cpp b/src/platform/ASR/ConfigurationManagerImpl.cpp old mode 100644 new mode 100755 index 0704a9ddadbb92..aa4a58eca6f958 --- a/src/platform/ASR/ConfigurationManagerImpl.cpp +++ b/src/platform/ASR/ConfigurationManagerImpl.cpp @@ -27,8 +27,10 @@ #include #ifdef CFG_PLF_RV32 #include "alto_common.h" +#elif defined CFG_PLF_DUET +#include "duet.h" #else -#include +#include "lega_cm4.h" #endif namespace chip { namespace DeviceLayer { diff --git a/src/platform/ASR/DiagnosticDataProviderImpl.cpp b/src/platform/ASR/DiagnosticDataProviderImpl.cpp old mode 100644 new mode 100755 index 735c6476b803ed..e5a14da8a5a1cd --- a/src/platform/ASR/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ASR/DiagnosticDataProviderImpl.cpp @@ -24,8 +24,11 @@ #ifdef CFG_PLF_RV32 #include "asr_alto_boot.h" #define duet_get_boot_type asr_get_boot_type -#else +#elif defined CFG_PLF_DUET #include "duet_boot.h" +#else +#include "lega_boot.h" +#define duet_get_boot_type lega_get_boot_type #endif #ifdef __cplusplus diff --git a/src/platform/ASR/KeyValueStoreManagerImpl.cpp b/src/platform/ASR/KeyValueStoreManagerImpl.cpp old mode 100644 new mode 100755 index 546cdea029592b..5cb3d9225cad31 --- a/src/platform/ASR/KeyValueStoreManagerImpl.cpp +++ b/src/platform/ASR/KeyValueStoreManagerImpl.cpp @@ -25,10 +25,18 @@ #define duet_flash_kv_get alto_flash_kv_get #define duet_flash_kv_del alto_flash_kv_del #define duet_flash_erase asr_flash_erase -#else +#elif defined CFG_PLF_DUET #include "duet_cm4.h" #include "duet_flash.h" #include "duet_flash_kv.h" +#else +#include "lega_cm4.h" +#include "lega_flash.h" +#include "lega_flash_kv.h" +#define duet_flash_kv_set lega_flash_kv_set +#define duet_flash_kv_get lega_flash_kv_get +#define duet_flash_kv_del lega_flash_kv_del +#define duet_flash_erase lega_flash_erase #endif #include "string.h"