From 77a0ec5d5ca9ed58e44a5345bc78e9a79b946ded Mon Sep 17 00:00:00 2001 From: Misha Tkachenko Date: Tue, 16 May 2023 17:35:20 +0300 Subject: [PATCH 1/5] [Telink]: Updated button manager to new gpio IRQ system Signed-off-by: Misha Tkachenko --- .../telink/common/include/AppConfigCommon.h | 17 ++++-- .../telink/common/src/AppTaskCommon.cpp | 32 ++++++++--- .../telink/util/include/ButtonManager.h | 14 ++--- .../telink/util/src/ButtonManager.cpp | 55 ++++++++----------- src/platform/telink/tlsr9518adk80d.overlay | 33 ++++++++++- 5 files changed, 98 insertions(+), 53 deletions(-) diff --git a/examples/platform/telink/common/include/AppConfigCommon.h b/examples/platform/telink/common/include/AppConfigCommon.h index 6af3da6bb213cc..6475732bd0ab93 100755 --- a/examples/platform/telink/common/include/AppConfigCommon.h +++ b/examples/platform/telink/common/include/AppConfigCommon.h @@ -19,12 +19,17 @@ #pragma once // Buttons config -#define BUTTON_PORT DEVICE_DT_GET(DT_NODELABEL(gpioc)) - -#define BUTTON_PIN_1 2 -#define BUTTON_PIN_3 3 -#define BUTTON_PIN_4 1 -#define BUTTON_PIN_2 0 +#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)) diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index c6e455b611dc07..45330e8d8e5bfc 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -40,6 +40,22 @@ constexpr int kFactoryResetCalcTimeout = 3000; 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; +#if APP_USE_THREAD_START_BUTTON +const struct gpio_dt_spec sThreadStartButtonDt = BUTTON_THREAD_START; +#endif +#if APP_USE_EXAMPLE_START_BUTTON +const struct gpio_dt_spec sExampleActionButtonDt = BUTTON_EXAMPLE_ACTION; +#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; +#endif + #if APP_USE_IDENTIFY_PWM constexpr uint32_t kIdentifyBlinkRateMs = 200; constexpr uint32_t kIdentifyOkayOnRateMs = 50; @@ -247,28 +263,28 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void) void AppTaskCommon::InitButtons(void) { #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(&sFactoryResetButtonDt, FactoryResetButtonEventHandler); + sBleAdvStartButton.Configure(&sBleStartButtonDt, StartBleAdvButtonEventHandler); #if APP_USE_EXAMPLE_START_BUTTON if (ExampleActionEventHandler) { - sExampleActionButton.Configure(BUTTON_PORT, BUTTON_PIN_2, ExampleActionButtonEventHandler); + sExampleActionButton.Configure(&sExampleActionButtonDt, ExampleActionButtonEventHandler); } #endif #if APP_USE_THREAD_START_BUTTON - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, StartThreadButtonEventHandler); + sThreadStartButton.Configure(&sThreadStartButtonDt, StartThreadButtonEventHandler); #endif #else - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(&sButtonRow1Dt, &sButtonCol1Dt, FactoryResetButtonEventHandler); + sBleAdvStartButton.Configure(&sButtonRow2Dt, &sButtonCol2Dt, StartBleAdvButtonEventHandler); #if APP_USE_EXAMPLE_START_BUTTON if (ExampleActionEventHandler) { - sExampleActionButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, ExampleActionButtonEventHandler); + sExampleActionButton.Configure(&sButtonRow2Dt, &sButtonCol2Dt, ExampleActionButtonEventHandler); } #endif #if APP_USE_THREAD_START_BUTTON - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); + sThreadStartButton.Configure(&sButtonRow2Dt, &sButtonCol1Dt, StartThreadButtonEventHandler); #endif #endif diff --git a/examples/platform/telink/util/include/ButtonManager.h b/examples/platform/telink/util/include/ButtonManager.h index d78837477e1918..5347575c08c8b6 100644 --- a/examples/platform/telink/util/include/ButtonManager.h +++ b/examples/platform/telink/util/include/ButtonManager.h @@ -26,20 +26,20 @@ class Button { public: - void Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, void (*callback)(void)); - void Configure(const struct device * port, gpio_pin_t inPin, void (*callback)(void)); + void Configure(const gpio_dt_spec * input_button_dt, const gpio_dt_spec * output_button_dt, void (*callback)(void)); + void Configure(const gpio_dt_spec * input_button_dt, void (*callback)(void)); void Poll(Button * previous); - void PollIRQ(void); + void PollIRQ(const struct device * dev, uint32_t pins); void SetCallback(void (*callback)(void)); private: int Init(void); int Deinit(void); - const struct device * mPort; - gpio_pin_t mOutPin; - gpio_pin_t mInPin; + const struct gpio_dt_spec * mInput_button; + const struct gpio_dt_spec * mOutput_matrix_pin; int mPreviousState = STATE_LOW; + struct gpio_callback mButton_cb_data; void (*mCallback)(void) = NULL; }; @@ -48,7 +48,7 @@ class ButtonManager public: void Init(void); void Poll(void); - void PollIRQ(void); + void PollIRQ(const struct device * dev, uint32_t pins); void AddButton(Button & button); void SetCallback(unsigned int index, void (*callback)(void)); diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index bdfa0b812a1ad4..37865c77a2ee8f 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -29,20 +29,18 @@ LOG_MODULE_REGISTER(ButtonManager); ButtonManager ButtonManager::sInstance; #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE -static struct gpio_callback button_cb_data; void button_pressed(const struct device * dev, struct gpio_callback * cb, uint32_t pins); #endif -void Button::Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, void (*callback)(void)) +void Button::Configure(const gpio_dt_spec * input_button_dt, const gpio_dt_spec * output_button_dt, void (*callback)(void)) { - if (!device_is_ready(port)) + if (!device_is_ready(input_button_dt->port)) { - LOG_ERR("%s is not ready\n", port->name); + LOG_ERR("Input port %s is not ready\n", input_button_dt->port->name); } - mPort = port; - mOutPin = outPin; - mInPin = inPin; + mInput_button = input_button_dt; + mOutput_matrix_pin = output_button_dt; mCallback = callback; } @@ -51,22 +49,22 @@ int Button::Init(void) int ret = 0; #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE - ret = gpio_pin_configure(mPort, mInPin, GPIO_INPUT | GPIO_PULL_UP); + ret = gpio_pin_configure_dt(mInput_button, GPIO_INPUT); if (ret < 0) { LOG_ERR("Config in pin err: %d", ret); return ret; } - ret = gpio_pin_interrupt_configure(mPort, mInPin, GPIO_INT_EDGE_FALLING); + ret = gpio_pin_interrupt_configure_dt(mInput_button, GPIO_INT_EDGE_TO_ACTIVE); if (ret < 0) { LOG_ERR("Config irq pin err: %d", ret); return ret; } - gpio_init_callback(&button_cb_data, button_pressed, mInPin); - ret = gpio_add_callback(mPort, &button_cb_data); + gpio_init_callback(&mButton_cb_data, button_pressed, BIT(mInput_button->pin)); + ret = gpio_add_callback(mInput_button->port, &mButton_cb_data); if (ret < 0) { LOG_ERR("Config gpio_init_callback err: %d", ret); @@ -74,14 +72,14 @@ int Button::Init(void) } #else - ret = gpio_pin_configure(mPort, mOutPin, GPIO_OUTPUT_ACTIVE); + ret = gpio_pin_configure_dt(mOutput_matrix_pin, GPIO_OUTPUT_ACTIVE); if (ret < 0) { LOG_ERR("Config out pin err: %d", ret); return ret; } - ret = gpio_pin_configure(mPort, mInPin, GPIO_INPUT | GPIO_PULL_DOWN); + ret = gpio_pin_configure_dt(mInput_button, GPIO_INPUT); if (ret < 0) { LOG_ERR("Config in pin err: %d", ret); @@ -97,7 +95,7 @@ int Button::Deinit(void) int ret = 0; /* Reconfigure output key pin to input */ - ret = gpio_pin_configure(mPort, mOutPin, GPIO_INPUT | GPIO_PULL_DOWN); + ret = gpio_pin_configure(mOutput_matrix_pin->port, mOutput_matrix_pin->pin, GPIO_INPUT | GPIO_PULL_DOWN); if (ret < 0) { LOG_ERR("Reconfig out pin err: %d", ret); @@ -120,7 +118,7 @@ void Button::Poll(Button * previous) ret = Init(); assert(ret >= 0); - ret = gpio_pin_get(mPort, mInPin); + ret = gpio_pin_get_dt(mInput_button); assert(ret >= 0); if (ret == STATE_HIGH && ret != mPreviousState) @@ -183,38 +181,33 @@ void ButtonEntry(void * param1, void * param2, void * param3) void button_pressed(const struct device * dev, struct gpio_callback * cb, uint32_t pins) { ButtonManager & sInstance = ButtonManagerInst(); - sInstance.PollIRQ(); + sInstance.PollIRQ(dev, pins); } -void ButtonManager::PollIRQ(void) +void ButtonManager::PollIRQ(const struct device * dev, uint32_t pins) { for (unsigned int i = 0; i < mButtons.size(); i++) { - mButtons[i].PollIRQ(); + mButtons[i].PollIRQ(dev, pins); } } -void Button::PollIRQ() +void Button::PollIRQ(const struct device * dev, uint32_t pins) { - int ret = gpio_pin_get(mPort, mInPin); - if (ret == STATE_LOW) - { - if (mCallback != NULL) - { - mCallback(); - } + if ((BIT(mInput_button->pin) & pins) && (mCallback != NULL) + && (dev == mInput_button->port)) { + mCallback(); } } -void Button::Configure(const struct device * port, gpio_pin_t inPin, void (*callback)(void)) +void Button::Configure(const gpio_dt_spec * input_button_dt, void (*callback)(void)) { - if (!device_is_ready(port)) + if (!device_is_ready(input_button_dt->port)) { - LOG_ERR("%s is not ready\n", port->name); + LOG_ERR("%s is not ready\n", input_button_dt->port->name); } - mPort = port; - mInPin = inPin; + mInput_button = input_button_dt; mCallback = callback; Init(); diff --git a/src/platform/telink/tlsr9518adk80d.overlay b/src/platform/telink/tlsr9518adk80d.overlay index 6a9d70c32fb32c..9ff6b2bc3ebbf1 100644 --- a/src/platform/telink/tlsr9518adk80d.overlay +++ b/src/platform/telink/tlsr9518adk80d.overlay @@ -25,6 +25,37 @@ label = "PWM IDENTIFY LED Green"; }; }; + + keys { + /delete-node/ button_1; + /delete-node/ button_3; + compatible = "gpio-keys"; + key_1: button_1 { + gpios = <&gpioc 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + key_2: button_2 { + gpios = <&gpioc 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + key_3: button_3 { + gpios = <&gpioc 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + key_4: button_4 { + gpios = <&gpioc 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + }; + + key_matrix_col1: key_matrix_col1 { + gpios = <&gpioc 3 GPIO_ACTIVE_HIGH>; + }; + key_matrix_col2: key_matrix_col2 { + gpios = <&gpioc 1 GPIO_ACTIVE_HIGH>; + }; + key_matrix_row1: key_matrix_row1 { + gpios = <&gpioc 2 GPIO_PULL_DOWN>; + }; + key_matrix_row2: key_matrix_row2 { + gpios = <&gpioc 0 GPIO_PULL_DOWN>; + }; + }; }; &pinctrl { @@ -77,4 +108,4 @@ }; /* region <0x1fe000 0x2000> is reserved for Telink B91 SDK's data */ }; -}; +}; \ No newline at end of file From 081ef20beef4de509d5cfeec6f9296f8d8445047 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 24 May 2023 08:46:30 +0000 Subject: [PATCH 2/5] Restyled by whitespace --- examples/platform/telink/util/src/ButtonManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index 37865c77a2ee8f..0110872715b563 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -194,7 +194,7 @@ void ButtonManager::PollIRQ(const struct device * dev, uint32_t pins) void Button::PollIRQ(const struct device * dev, uint32_t pins) { - if ((BIT(mInput_button->pin) & pins) && (mCallback != NULL) + if ((BIT(mInput_button->pin) & pins) && (mCallback != NULL) && (dev == mInput_button->port)) { mCallback(); } From 87f05202405a4cd9b6caf305b51b774c62b91a4b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 24 May 2023 08:46:31 +0000 Subject: [PATCH 3/5] Restyled by clang-format --- .../telink/common/include/AppConfigCommon.h | 16 ++++++++-------- .../platform/telink/common/src/AppTaskCommon.cpp | 2 +- .../platform/telink/util/include/ButtonManager.h | 2 +- .../platform/telink/util/src/ButtonManager.cpp | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) mode change 100755 => 100644 examples/platform/telink/common/include/AppConfigCommon.h diff --git a/examples/platform/telink/common/include/AppConfigCommon.h b/examples/platform/telink/common/include/AppConfigCommon.h old mode 100755 new mode 100644 index 6475732bd0ab93..b8850a76b6301c --- a/examples/platform/telink/common/include/AppConfigCommon.h +++ b/examples/platform/telink/common/include/AppConfigCommon.h @@ -20,15 +20,15 @@ // 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) +#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) +#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 diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 45330e8d8e5bfc..0e9fee7f0c767f 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -42,7 +42,7 @@ 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 sBleStartButtonDt = BUTTON_BLE_START; #if APP_USE_THREAD_START_BUTTON const struct gpio_dt_spec sThreadStartButtonDt = BUTTON_THREAD_START; #endif diff --git a/examples/platform/telink/util/include/ButtonManager.h b/examples/platform/telink/util/include/ButtonManager.h index 5347575c08c8b6..e9ea1b60b17816 100644 --- a/examples/platform/telink/util/include/ButtonManager.h +++ b/examples/platform/telink/util/include/ButtonManager.h @@ -38,7 +38,7 @@ class Button const struct gpio_dt_spec * mInput_button; const struct gpio_dt_spec * mOutput_matrix_pin; - int mPreviousState = STATE_LOW; + int mPreviousState = STATE_LOW; struct gpio_callback mButton_cb_data; void (*mCallback)(void) = NULL; }; diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index 0110872715b563..3805a2640e193c 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -39,9 +39,9 @@ void Button::Configure(const gpio_dt_spec * input_button_dt, const gpio_dt_spec LOG_ERR("Input port %s is not ready\n", input_button_dt->port->name); } - mInput_button = input_button_dt; + mInput_button = input_button_dt; mOutput_matrix_pin = output_button_dt; - mCallback = callback; + mCallback = callback; } int Button::Init(void) @@ -194,8 +194,8 @@ void ButtonManager::PollIRQ(const struct device * dev, uint32_t pins) void Button::PollIRQ(const struct device * dev, uint32_t pins) { - if ((BIT(mInput_button->pin) & pins) && (mCallback != NULL) - && (dev == mInput_button->port)) { + if ((BIT(mInput_button->pin) & pins) && (mCallback != NULL) && (dev == mInput_button->port)) + { mCallback(); } } @@ -208,7 +208,7 @@ void Button::Configure(const gpio_dt_spec * input_button_dt, void (*callback)(vo } mInput_button = input_button_dt; - mCallback = callback; + mCallback = callback; Init(); } From a1d135c50a4ebda149f2659f58ee8ccca9ab0603 Mon Sep 17 00:00:00 2001 From: Misha Tkachenko Date: Thu, 25 May 2023 11:39:23 +0300 Subject: [PATCH 4/5] [Telink]: Fixed window app build Signed-off-by: Misha Tkachenko --- .../telink/common/src/AppTaskCommon.cpp | 2 +- examples/window-app/telink/src/AppTask.cpp | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 0e9fee7f0c767f..637aaf0e620612 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -280,7 +280,7 @@ void AppTaskCommon::InitButtons(void) #if APP_USE_EXAMPLE_START_BUTTON if (ExampleActionEventHandler) { - sExampleActionButton.Configure(&sButtonRow2Dt, &sButtonCol2Dt, ExampleActionButtonEventHandler); + sExampleActionButton.Configure(&sButtonRow1Dt, &sButtonCol2Dt, ExampleActionButtonEventHandler); } #endif #if APP_USE_THREAD_START_BUTTON diff --git a/examples/window-app/telink/src/AppTask.cpp b/examples/window-app/telink/src/AppTask.cpp index e79e03cc5b4058..1cc63e27c6f267 100644 --- a/examples/window-app/telink/src/AppTask.cpp +++ b/examples/window-app/telink/src/AppTask.cpp @@ -27,6 +27,19 @@ 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 + +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; +#endif + Button sOpenButton; Button sCloseButton; @@ -40,11 +53,11 @@ CHIP_ERROR AppTask::Init(void) InitCommonParts(); #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE - sOpenButton.Configure(BUTTON_PORT, BUTTON_PIN_2, OpenActionAndToggleMoveTypeButtonEventHandler); - sCloseButton.Configure(BUTTON_PORT, BUTTON_PIN_3, CloseActionButtonEventHandler); + sOpenButton.Configure(&sOpenWindowButtonDt, OpenActionAndToggleMoveTypeButtonEventHandler); + sCloseButton.Configure(&sCloseWindowButtonDt, CloseActionButtonEventHandler); #else - sOpenButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, OpenActionAndToggleMoveTypeButtonEventHandler); - sCloseButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, CloseActionButtonEventHandler); + sOpenButton.Configure(&sButtonRow1Dt, &sButtonCol2Dt, OpenActionAndToggleMoveTypeButtonEventHandler); + sCloseButton.Configure(&sButtonRow2Dt, &sButtonCol1Dt, CloseActionButtonEventHandler); #endif ButtonManagerInst().AddButton(sOpenButton); ButtonManagerInst().AddButton(sCloseButton); From 7d74b13de2eebc00ea946dd82b7826d3fc8ac0f2 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 25 May 2023 08:39:46 +0000 Subject: [PATCH 5/5] Restyled by clang-format --- examples/window-app/telink/src/AppTask.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/window-app/telink/src/AppTask.cpp b/examples/window-app/telink/src/AppTask.cpp index 1cc63e27c6f267..12415839b6425c 100644 --- a/examples/window-app/telink/src/AppTask.cpp +++ b/examples/window-app/telink/src/AppTask.cpp @@ -28,11 +28,11 @@ 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 BUTTON_EXAMPLE_ACTION +#define CLOSE_WINDOW_BUTTON BUTTON_THREAD_START -const struct gpio_dt_spec sOpenWindowButtonDt = OPEN_WINDOW_BUTTON; -const struct gpio_dt_spec sCloseWindowButtonDt = CLOSE_WINDOW_BUTTON; +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;