From 2667970a55696542066fefcff9755a4ac8ddf253 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Sat, 3 Jun 2023 11:40:31 +0300 Subject: [PATCH] [Telink] LEDs & Buttons DTS improvements (#27034) Co-authored-by: Andrei Litvin --- .../telink/include/AppConfig.h | 4 +- .../telink/include/AppConfig.h | 4 +- .../bridge-app/telink/include/AppConfig.h | 6 +-- examples/bridge-app/telink/src/AppTask.cpp | 2 +- .../telink/include/AppConfig.h | 6 +-- .../contact-sensor-app/telink/src/AppTask.cpp | 2 +- .../telink/include/AppConfig.h | 4 +- .../lighting-app/telink/include/AppConfig.h | 10 +---- examples/lighting-app/telink/src/AppTask.cpp | 6 +-- examples/lock-app/telink/include/AppConfig.h | 6 +-- examples/lock-app/telink/src/AppTask.cpp | 2 +- .../telink/include/AppConfig.h | 4 +- .../telink/common/include/AppConfigCommon.h | 39 ------------------- .../telink/common/src/AppTaskCommon.cpp | 21 +++++----- .../platform/telink/util/include/LEDWidget.h | 6 +-- .../telink/util/src/ButtonManager.cpp | 2 +- .../platform/telink/util/src/LEDWidget.cpp | 22 +++-------- examples/pump-app/telink/include/AppConfig.h | 5 +-- examples/pump-app/telink/src/AppTask.cpp | 2 +- .../telink/include/AppConfig.h | 5 +-- .../telink/src/AppTask.cpp | 2 +- .../telink/include/AppConfig.h | 4 +- .../thermostat/telink/include/AppConfig.h | 4 +- .../window-app/telink/include/AppConfig.h | 8 +--- examples/window-app/telink/src/AppTask.cpp | 12 +++--- .../window-app/telink/src/WindowCovering.cpp | 4 +- src/platform/telink/tlsr9518adk80d.overlay | 1 + 27 files changed, 49 insertions(+), 144 deletions(-) delete mode 100644 examples/platform/telink/common/include/AppConfigCommon.h diff --git a/examples/all-clusters-app/telink/include/AppConfig.h b/examples/all-clusters-app/telink/include/AppConfig.h index 880f3aa7b98c50..bf3fcd959f86e2 100644 --- a/examples/all-clusters-app/telink/include/AppConfig.h +++ b/examples/all-clusters-app/telink/include/AppConfig.h @@ -23,6 +23,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/all-clusters-minimal-app/telink/include/AppConfig.h b/examples/all-clusters-minimal-app/telink/include/AppConfig.h index 10d4d5f281d67a..0575d9a70693a3 100644 --- a/examples/all-clusters-minimal-app/telink/include/AppConfig.h +++ b/examples/all-clusters-minimal-app/telink/include/AppConfig.h @@ -24,6 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 0 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1 -#define APP_USE_IDENTIFY_PWM 0 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 0 diff --git a/examples/bridge-app/telink/include/AppConfig.h b/examples/bridge-app/telink/include/AppConfig.h index 3f7cccb6807d10..bb380991b813a4 100644 --- a/examples/bridge-app/telink/include/AppConfig.h +++ b/examples/bridge-app/telink/include/AppConfig.h @@ -24,8 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" - -#define LIGHTING_PWM_SPEC_RGB_BLUE PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)) +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index 8f6bf092a61649..afef82f187c1fc 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -26,7 +26,7 @@ LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); namespace { -const struct pwm_dt_spec sPwmRgbSpecBlueLed = LIGHTING_PWM_SPEC_RGB_BLUE; +const struct pwm_dt_spec sPwmRgbSpecBlueLed = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)); } // namespace AppTask AppTask::sAppTask; diff --git a/examples/contact-sensor-app/telink/include/AppConfig.h b/examples/contact-sensor-app/telink/include/AppConfig.h index 2ab155cd590a67..e124b65eddd2fc 100644 --- a/examples/contact-sensor-app/telink/include/AppConfig.h +++ b/examples/contact-sensor-app/telink/include/AppConfig.h @@ -23,8 +23,4 @@ #define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" - -#define CONTACT_STATE_LED 6 +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/contact-sensor-app/telink/src/AppTask.cpp b/examples/contact-sensor-app/telink/src/AppTask.cpp index 3486995097d668..3ee4cd19d30a60 100644 --- a/examples/contact-sensor-app/telink/src/AppTask.cpp +++ b/examples/contact-sensor-app/telink/src/AppTask.cpp @@ -41,7 +41,7 @@ CHIP_ERROR AppTask::Init(void) InitCommonParts(); #if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED - sContactSensorLED.Init(CONTACT_STATE_LED); + sContactSensorLED.Init(GPIO_DT_SPEC_GET(DT_ALIAS(led2), gpios)); sContactSensorLED.Set(ContactSensorMgr().IsContactClosed()); #endif diff --git a/examples/light-switch-app/telink/include/AppConfig.h b/examples/light-switch-app/telink/include/AppConfig.h index 05c6957a92e399..4a9877dea54768 100644 --- a/examples/light-switch-app/telink/include/AppConfig.h +++ b/examples/light-switch-app/telink/include/AppConfig.h @@ -24,6 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/lighting-app/telink/include/AppConfig.h b/examples/lighting-app/telink/include/AppConfig.h index eaf1933669106c..883935907a474e 100644 --- a/examples/lighting-app/telink/include/AppConfig.h +++ b/examples/lighting-app/telink/include/AppConfig.h @@ -24,15 +24,7 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 // Lighting LED config #define USE_RGB_PWM 0 - -#define LIGHTING_PWM_SPEC_RGB_BLUE PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)) -#if USE_RGB_PWM -#define LIGHTING_PWM_SPEC_RGB_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)) -#define LIGHTING_PWM_SPEC_RGB_RED PWM_DT_SPEC_GET(DT_ALIAS(pwm_led2)) -#endif diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 1f512e322dc188..6bee2963f81696 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -26,10 +26,10 @@ LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); namespace { -const struct pwm_dt_spec sPwmRgbSpecBlueLed = LIGHTING_PWM_SPEC_RGB_BLUE; +const struct pwm_dt_spec sPwmRgbSpecBlueLed = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)); #if USE_RGB_PWM -const struct pwm_dt_spec sPwmRgbSpecGreenLed = LIGHTING_PWM_SPEC_RGB_GREEN; -const struct pwm_dt_spec sPwmRgbSpecRedLed = LIGHTING_PWM_SPEC_RGB_RED; +const struct pwm_dt_spec sPwmRgbSpecGreenLed = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)); +const struct pwm_dt_spec sPwmRgbSpecRedLed = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led2)); uint8_t sBrightness; PWMDevice::Action_t sColorAction = PWMDevice::INVALID_ACTION; diff --git a/examples/lock-app/telink/include/AppConfig.h b/examples/lock-app/telink/include/AppConfig.h index ae4c9d5b4fc9c5..a2bddab66cecef 100644 --- a/examples/lock-app/telink/include/AppConfig.h +++ b/examples/lock-app/telink/include/AppConfig.h @@ -24,8 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" - -#define LOCK_STATE_LED 6 +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/lock-app/telink/src/AppTask.cpp b/examples/lock-app/telink/src/AppTask.cpp index ca73a27eda6dd1..589354f1a53aa8 100644 --- a/examples/lock-app/telink/src/AppTask.cpp +++ b/examples/lock-app/telink/src/AppTask.cpp @@ -41,7 +41,7 @@ CHIP_ERROR AppTask::Init(void) InitCommonParts(); #if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED - sLockLED.Init(LOCK_STATE_LED); + sLockLED.Init(GPIO_DT_SPEC_GET(DT_ALIAS(led2), gpios)); sLockLED.Set(BoltLockMgr().IsLocked()); #endif diff --git a/examples/ota-requestor-app/telink/include/AppConfig.h b/examples/ota-requestor-app/telink/include/AppConfig.h index ff96590c376749..9e44f45a989c25 100644 --- a/examples/ota-requestor-app/telink/include/AppConfig.h +++ b/examples/ota-requestor-app/telink/include/AppConfig.h @@ -24,6 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/platform/telink/common/include/AppConfigCommon.h b/examples/platform/telink/common/include/AppConfigCommon.h deleted file mode 100644 index b8850a76b6301c..00000000000000 --- a/examples/platform/telink/common/include/AppConfigCommon.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright (c) 2022-2023 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 - -// Buttons config -#if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE -#define BUTTON_FACTORY_RESET GPIO_DT_SPEC_GET(DT_NODELABEL(key_1), gpios) -#define BUTTON_BLE_START GPIO_DT_SPEC_GET(DT_NODELABEL(key_2), gpios) -#define BUTTON_THREAD_START GPIO_DT_SPEC_GET(DT_NODELABEL(key_3), gpios) -#define BUTTON_EXAMPLE_ACTION GPIO_DT_SPEC_GET(DT_NODELABEL(key_4), gpios) -#else -#define BUTTON_COL_1 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col1), gpios) -#define BUTTON_COL_2 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col2), gpios) -#define BUTTON_ROW_1 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row1), gpios) -#define BUTTON_ROW_2 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row2), gpios) -#endif - -// LEDs config -#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) -#define SYSTEM_STATE_LED 7 -#if APP_USE_IDENTIFY_PWM -#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)) -#endif diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index bb97871883187e..aa9b38bb7fdeb4 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -54,19 +54,19 @@ constexpr int kFactoryResetTriggerCntr = 3; constexpr int kAppEventQueueSize = 10; #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE -const struct gpio_dt_spec sFactoryResetButtonDt = BUTTON_FACTORY_RESET; -const struct gpio_dt_spec sBleStartButtonDt = BUTTON_BLE_START; +const struct gpio_dt_spec sFactoryResetButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_1), gpios); +const struct gpio_dt_spec sBleStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_2), gpios); #if APP_USE_THREAD_START_BUTTON -const struct gpio_dt_spec sThreadStartButtonDt = BUTTON_THREAD_START; +const struct gpio_dt_spec sThreadStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_3), gpios); #endif #if APP_USE_EXAMPLE_START_BUTTON -const struct gpio_dt_spec sExampleActionButtonDt = BUTTON_EXAMPLE_ACTION; +const struct gpio_dt_spec sExampleActionButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_4), gpios); #endif #else -const struct gpio_dt_spec sButtonCol1Dt = BUTTON_COL_1; -const struct gpio_dt_spec sButtonCol2Dt = BUTTON_COL_2; -const struct gpio_dt_spec sButtonRow1Dt = BUTTON_ROW_1; -const struct gpio_dt_spec sButtonRow2Dt = BUTTON_ROW_2; +const struct gpio_dt_spec sButtonCol1Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col1), gpios); +const struct gpio_dt_spec sButtonCol2Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col2), gpios); +const struct gpio_dt_spec sButtonRow1Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row1), gpios); +const struct gpio_dt_spec sButtonRow2Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row2), gpios); #endif #if APP_USE_IDENTIFY_PWM @@ -78,7 +78,7 @@ constexpr uint32_t kIdentifyFinishOffRateMs = 50; constexpr uint32_t kIdentifyChannelChangeRateMs = 1000; constexpr uint32_t kIdentifyBreatheRateMs = 1000; -const struct pwm_dt_spec sPwmIdentifySpecGreenLed = LIGHTING_PWM_SPEC_IDENTIFY_GREEN; +const struct pwm_dt_spec sPwmIdentifySpecGreenLed = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)); #endif #if APP_SET_NETWORK_COMM_ENDPOINT_SEC @@ -247,9 +247,8 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void) // Initialize status LED #if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED - LEDWidget::InitGpio(LEDS_PORT); LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); - sStatusLED.Init(SYSTEM_STATE_LED); + sStatusLED.Init(GPIO_DT_SPEC_GET(DT_ALIAS(system_state_led), gpios)); UpdateStatusLED(); #endif diff --git a/examples/platform/telink/util/include/LEDWidget.h b/examples/platform/telink/util/include/LEDWidget.h index de15216a1a8174..3829e7ac5628ea 100644 --- a/examples/platform/telink/util/include/LEDWidget.h +++ b/examples/platform/telink/util/include/LEDWidget.h @@ -26,10 +26,8 @@ class LEDWidget public: typedef void (*LEDWidgetStateUpdateHandler)(LEDWidget * ledWidget); - static void InitGpio(const device * port); static void SetStateUpdateCallback(LEDWidgetStateUpdateHandler stateUpdateCb); - const static struct device * mPort; - void Init(gpio_pin_t gpioNum); + void Init(gpio_dt_spec gpio); void Set(bool state); void Invert(void); void Blink(uint32_t changeRateMS); @@ -39,7 +37,7 @@ class LEDWidget private: uint32_t mBlinkOnTimeMS; uint32_t mBlinkOffTimeMS; - gpio_pin_t mGPIONum; + gpio_dt_spec mGPIO; bool mState; k_timer mLedTimer; diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index 3805a2640e193c..a4c5e73c590120 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -95,7 +95,7 @@ int Button::Deinit(void) int ret = 0; /* Reconfigure output key pin to input */ - ret = gpio_pin_configure(mOutput_matrix_pin->port, mOutput_matrix_pin->pin, GPIO_INPUT | GPIO_PULL_DOWN); + ret = gpio_pin_configure_dt(mOutput_matrix_pin, GPIO_INPUT | GPIO_PULL_DOWN); if (ret < 0) { LOG_ERR("Reconfig out pin err: %d", ret); diff --git a/examples/platform/telink/util/src/LEDWidget.cpp b/examples/platform/telink/util/src/LEDWidget.cpp index 3e63c5e9e9d429..0ea31d5d1b9eee 100644 --- a/examples/platform/telink/util/src/LEDWidget.cpp +++ b/examples/platform/telink/util/src/LEDWidget.cpp @@ -23,35 +23,25 @@ LOG_MODULE_REGISTER(LEDWidget); -const struct device * LEDWidget::mPort = NULL; static LEDWidget::LEDWidgetStateUpdateHandler sStateUpdateCallback; -void LEDWidget::InitGpio(const device * port) -{ - mPort = port; - if (!device_is_ready(mPort)) - { - LOG_ERR("%s is not ready\n", mPort->name); - } -} - void LEDWidget::SetStateUpdateCallback(LEDWidgetStateUpdateHandler stateUpdateCb) { if (stateUpdateCb) sStateUpdateCallback = stateUpdateCb; } -void LEDWidget::Init(gpio_pin_t gpioNum) +void LEDWidget::Init(gpio_dt_spec gpio) { mBlinkOnTimeMS = 0; mBlinkOffTimeMS = 0; - mGPIONum = gpioNum; + mGPIO = gpio; mState = false; - int ret = gpio_pin_configure(mPort, mGPIONum, GPIO_OUTPUT_ACTIVE); + int ret = gpio_pin_configure_dt(&mGPIO, GPIO_OUTPUT_ACTIVE); if (ret < 0) { - LOG_ERR("GPIO pin %d configure - fail. Status%d\n", mGPIONum, ret); + LOG_ERR("GPIO pin %d configure - fail. Status%d\n", mGPIO.pin, ret); } k_timer_init(&mLedTimer, &LEDWidget::LedStateTimerHandler, nullptr); @@ -99,10 +89,10 @@ void LEDWidget::ScheduleStateChange() void LEDWidget::DoSet(bool state) { mState = state; - int ret = gpio_pin_set(mPort, mGPIONum, state); + int ret = gpio_pin_set_dt(&mGPIO, state); if (ret < 0) { - LOG_ERR("GPIO pin %d set -fail. Status: %d\n", mGPIONum, ret); + LOG_ERR("GPIO pin %d set -fail. Status: %d\n", mGPIO.pin, ret); } } diff --git a/examples/pump-app/telink/include/AppConfig.h b/examples/pump-app/telink/include/AppConfig.h index a661fd8c3f25e6..6701222f76151a 100644 --- a/examples/pump-app/telink/include/AppConfig.h +++ b/examples/pump-app/telink/include/AppConfig.h @@ -24,10 +24,7 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 -#include "AppConfigCommon.h" - -#define PUMP_STATE_LED 6 // Time it takes in ms for the simulated pump to move from one state to another. #define PUMP_START_PERIOS_MS 2000 diff --git a/examples/pump-app/telink/src/AppTask.cpp b/examples/pump-app/telink/src/AppTask.cpp index 30aeaf3828badb..22396317f9e799 100644 --- a/examples/pump-app/telink/src/AppTask.cpp +++ b/examples/pump-app/telink/src/AppTask.cpp @@ -42,7 +42,7 @@ CHIP_ERROR AppTask::Init(void) InitCommonParts(); #if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED - sPumpStateLED.Init(PUMP_STATE_LED); + sPumpStateLED.Init(GPIO_DT_SPEC_GET(DT_ALIAS(led2), gpios)); sPumpStateLED.Set(!PumpMgr().IsStopped()); #endif diff --git a/examples/pump-controller-app/telink/include/AppConfig.h b/examples/pump-controller-app/telink/include/AppConfig.h index 5dd793da63e67e..7fbff9ffb73eff 100644 --- a/examples/pump-controller-app/telink/include/AppConfig.h +++ b/examples/pump-controller-app/telink/include/AppConfig.h @@ -24,10 +24,7 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 -#include "AppConfigCommon.h" - -#define PUMP_STATE_LED 6 // Time it takes in ms for the simulated pump to move from one state to another. #define PUMP_START_PERIOS_MS 2000 diff --git a/examples/pump-controller-app/telink/src/AppTask.cpp b/examples/pump-controller-app/telink/src/AppTask.cpp index 13bb753fe0d759..4cdb7c2cbba420 100644 --- a/examples/pump-controller-app/telink/src/AppTask.cpp +++ b/examples/pump-controller-app/telink/src/AppTask.cpp @@ -40,7 +40,7 @@ CHIP_ERROR AppTask::Init(void) InitCommonParts(); #if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED - sPumpStateLED.Init(PUMP_STATE_LED); + sPumpStateLED.Init(GPIO_DT_SPEC_GET(DT_ALIAS(led2), gpios)); sPumpStateLED.Set(!PumpMgr().IsStopped()); #endif diff --git a/examples/temperature-measurement-app/telink/include/AppConfig.h b/examples/temperature-measurement-app/telink/include/AppConfig.h index c2955144027fb2..caa9762240f74d 100644 --- a/examples/temperature-measurement-app/telink/include/AppConfig.h +++ b/examples/temperature-measurement-app/telink/include/AppConfig.h @@ -24,6 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 0 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 0 diff --git a/examples/thermostat/telink/include/AppConfig.h b/examples/thermostat/telink/include/AppConfig.h index 4b74db57e3091d..d3131fb3e32c69 100644 --- a/examples/thermostat/telink/include/AppConfig.h +++ b/examples/thermostat/telink/include/AppConfig.h @@ -24,6 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/window-app/telink/include/AppConfig.h b/examples/window-app/telink/include/AppConfig.h index 261c67234d043c..f729f0a018d8d9 100644 --- a/examples/window-app/telink/include/AppConfig.h +++ b/examples/window-app/telink/include/AppConfig.h @@ -24,10 +24,4 @@ #define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 -#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h" - -#include "AppConfigCommon.h" -#define LIGHTING_PWM_SPEC_RGB_BLUE PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)) - -// NOTE: pwm_led1 by default DTS is used by PE0, so get an external LED connected to that pin -#define LIGHTING_PWM_SPEC_RGB_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)) +#define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/window-app/telink/src/AppTask.cpp b/examples/window-app/telink/src/AppTask.cpp index 12415839b6425c..c95e0bc5ae8c0b 100644 --- a/examples/window-app/telink/src/AppTask.cpp +++ b/examples/window-app/telink/src/AppTask.cpp @@ -28,16 +28,16 @@ constexpr int kToggleMoveTypeTriggerTimeout = 700; k_timer sToggleMoveTypeTimer; #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE -#define OPEN_WINDOW_BUTTON BUTTON_EXAMPLE_ACTION -#define CLOSE_WINDOW_BUTTON BUTTON_THREAD_START +#define OPEN_WINDOW_BUTTON GPIO_DT_SPEC_GET(DT_NODELABEL(key_4), gpios) +#define CLOSE_WINDOW_BUTTON GPIO_DT_SPEC_GET(DT_NODELABEL(key_3), gpios) const struct gpio_dt_spec sOpenWindowButtonDt = OPEN_WINDOW_BUTTON; const struct gpio_dt_spec sCloseWindowButtonDt = CLOSE_WINDOW_BUTTON; #else -const struct gpio_dt_spec sButtonCol1Dt = BUTTON_COL_1; -const struct gpio_dt_spec sButtonCol2Dt = BUTTON_COL_2; -const struct gpio_dt_spec sButtonRow1Dt = BUTTON_ROW_1; -const struct gpio_dt_spec sButtonRow2Dt = BUTTON_ROW_2; +const struct gpio_dt_spec sButtonCol1Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col1), gpios); +const struct gpio_dt_spec sButtonCol2Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col2), gpios); +const struct gpio_dt_spec sButtonRow1Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row1), gpios); +const struct gpio_dt_spec sButtonRow2Dt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row2), gpios); #endif Button sOpenButton; diff --git a/examples/window-app/telink/src/WindowCovering.cpp b/examples/window-app/telink/src/WindowCovering.cpp index 77889418abef3b..a8cae9d37e597b 100644 --- a/examples/window-app/telink/src/WindowCovering.cpp +++ b/examples/window-app/telink/src/WindowCovering.cpp @@ -31,8 +31,8 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; using namespace chip::app::Clusters::WindowCovering; -static const struct pwm_dt_spec sLiftPwmDevice = LIGHTING_PWM_SPEC_RGB_BLUE; -static const struct pwm_dt_spec sTiltPwmDevice = LIGHTING_PWM_SPEC_RGB_GREEN; +static const struct pwm_dt_spec sLiftPwmDevice = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)); +static const struct pwm_dt_spec sTiltPwmDevice = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)); static constexpr uint32_t sMoveTimeoutMs{ 200 }; constexpr uint16_t sPercentDelta = 500; diff --git a/src/platform/telink/tlsr9518adk80d.overlay b/src/platform/telink/tlsr9518adk80d.overlay index 9ff6b2bc3ebbf1..22b5ac801ac974 100644 --- a/src/platform/telink/tlsr9518adk80d.overlay +++ b/src/platform/telink/tlsr9518adk80d.overlay @@ -1,5 +1,6 @@ / { aliases { + system-state-led = &led_red; pwm-led0 = &pwm_led0; pwm-led1 = &pwm_led1; pwm-led2 = &pwm_led2;