Skip to content

Commit

Permalink
[Telink] Disable LEDs for retention board
Browse files Browse the repository at this point in the history
  • Loading branch information
andriy-bilynskyy authored and mishadesh committed Oct 25, 2023
1 parent 0ce9805 commit e187ffb
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 111 deletions.
12 changes: 12 additions & 0 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ config NET_BUF_TX_COUNT
default 16 if PM
default 32

config GPIO
default y

# Bluetooth Low Energy configs

config BT
Expand Down Expand Up @@ -161,6 +164,15 @@ config BOARD_TLSR9X_NON_RETENTION_RAM_CODE

config TELINK_B9x_MATTER_RETENTION_LAYOUT
default y if PM

config PWM
default n
endif

# Board non-retention config
if BOARD_TLSR9528A || BOARD_TLSR9518ADK80D
config PWM
default y
endif

# Config dynamic interrupts to have posibility to switch between BLE/Thread radio drivers
Expand Down
6 changes: 0 additions & 6 deletions examples/air-quality-sensor-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/all-clusters-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/bridge-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/chef/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/contact-sensor-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/light-switch-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
2 changes: 2 additions & 0 deletions examples/light-switch-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
{
if (aEvent->Type == AppEvent::kEventType_Button)
{
LOG_INF("App button pressed");

BindingCommandData * data = chip::Platform::New<BindingCommandData>();
data->commandId = chip::app::Clusters::OnOff::Commands::Toggle::Id;
data->clusterId = chip::app::Clusters::OnOff::Id;
Expand Down
6 changes: 0 additions & 6 deletions examples/lighting-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/lock-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/ota-requestor-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ constexpr uint32_t kIdentifyFinishOffRateMs = 50;
constexpr uint32_t kIdentifyChannelChangeRateMs = 1000;
constexpr uint32_t kIdentifyBreatheRateMs = 1000;

const struct pwm_dt_spec sPwmIdentifySpecGreenLed = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3));
const struct pwm_dt_spec sPwmIdentifySpecGreenLed = PWM_DT_SPEC_GET_OR(DT_ALIAS(pwm_led3), {});
#endif

#if APP_SET_NETWORK_COMM_ENDPOINT_SEC
Expand Down Expand Up @@ -261,7 +261,7 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
// Initialize status LED
#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED
LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler);
sStatusLED.Init(GPIO_DT_SPEC_GET(DT_ALIAS(system_state_led), gpios));
sStatusLED.Init(GPIO_DT_SPEC_GET_OR(DT_ALIAS(system_state_led), gpios, {}));

UpdateStatusLED();
#endif
Expand Down
15 changes: 11 additions & 4 deletions examples/platform/telink/util/src/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ void LEDWidget::Init(gpio_dt_spec gpio)
mGPIO = gpio;
mState = false;

int ret = gpio_pin_configure_dt(&mGPIO, GPIO_OUTPUT_ACTIVE);
if (ret < 0)
{
LOG_ERR("GPIO pin %d configure - fail. Status%d\n", mGPIO.pin, ret);
if (!gpio_is_ready_dt(&mGPIO)) {
LOG_ERR("GPIO device not ready");
} else {
int ret = gpio_pin_configure_dt(&mGPIO, GPIO_OUTPUT_ACTIVE);
if (ret < 0)
{
LOG_ERR("GPIO pin %d configure - fail. Status%d\n", mGPIO.pin, ret);
}
}

k_timer_init(&mLedTimer, &LEDWidget::LedStateTimerHandler, nullptr);
Expand Down Expand Up @@ -88,6 +92,9 @@ void LEDWidget::ScheduleStateChange()

void LEDWidget::DoSet(bool state)
{
if (!gpio_is_ready_dt(&mGPIO)) {
return;
}
mState = state;
int ret = gpio_pin_set_dt(&mGPIO, state);
if (ret < 0)
Expand Down
6 changes: 4 additions & 2 deletions examples/platform/telink/util/src/PWMDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ CHIP_ERROR PWMDevice::Init(const pwm_dt_spec * pwmDevice, uint8_t aMinLevel, uin

if (!device_is_ready(mPwmDevice->dev))
{
LOG_ERR("PWM device %s is not ready", mPwmDevice->dev->name);
return CHIP_ERROR_INCORRECT_STATE;
LOG_ERR("PWM device %s is not ready", mPwmDevice->dev ? mPwmDevice->dev->name : "N/A");
}

k_timer_init(&mPwmLedTimer, &PWMDevice::PwmLedTimerHandler, nullptr);
Expand Down Expand Up @@ -134,6 +133,9 @@ void PWMDevice::Set(bool aOn)

void PWMDevice::UpdateLight(void)
{
if (!device_is_ready(mPwmDevice->dev)) {
return;
}
constexpr uint32_t kPwmWidthUs = 20000u;
const uint8_t maxEffectiveLevel = mMaxLevel - mMinLevel;
const uint8_t effectiveLevel = mState == kState_On ? chip::min<uint8_t>(mLevel - mMinLevel, maxEffectiveLevel) : 0;
Expand Down
6 changes: 0 additions & 6 deletions examples/pump-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/pump-controller-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/resource-monitoring-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/shell/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/smoke-co-alarm-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/temperature-measurement-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/thermostat/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
6 changes: 0 additions & 6 deletions examples/window-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
Expand Down
1 change: 0 additions & 1 deletion src/platform/telink/tlsr9528a_retention.overlay

This file was deleted.

55 changes: 55 additions & 0 deletions src/platform/telink/tlsr9528a_retention.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/ {
/*
* There is no way to keep GPIOs
* during deep-sleep mode so output GPIOs
* and PWM's are useless.
*/

aliases {
/delete-property/ led0;
/delete-property/ led1;
/delete-property/ led2;
/delete-property/ led3;
/delete-property/ mcuboot-led0;
/delete-property/ pwm-led0;
/delete-property/ pwm-0;
};

/delete-node/ leds;
/delete-node/ pwm_leds;

keys {
/delete-node/ button_1;
/delete-node/ button_3;
compatible = "gpio-keys";
key_1: button_1 {
gpios = <&gpiod 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
key_2: button_2 {
gpios = <&gpiod 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
key_3: button_3 {
gpios = <&gpiod 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
key_4: button_4 {
gpios = <&gpiof 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};

key_matrix_col1: key_matrix_col1 {
gpios = <&gpiod 6 GPIO_ACTIVE_HIGH>;
};
key_matrix_col2: key_matrix_col2 {
gpios = <&gpiof 6 GPIO_ACTIVE_HIGH>;
};
key_matrix_row1: key_matrix_row1 {
gpios = <&gpiod 2 GPIO_PULL_DOWN>;
};
key_matrix_row2: key_matrix_row2 {
gpios = <&gpiod 7 GPIO_PULL_DOWN>;
};
};
};

&pwm0 {
status = "disabled";
};

0 comments on commit e187ffb

Please sign in to comment.