Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Telink] Ability to disable/enable PM during BLE operation #25769

Merged
merged 4 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/telink/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,9 @@ config CHIP_ENABLE_APPLICATION_STATUS_LED
default y
help
Enable application status LED.

config CHIP_ENABLE_PM_DURING_BLE
bool "Enable PM during BLE operation"
default y
help
Enable PM during BLE operation.
1 change: 1 addition & 0 deletions examples/all-clusters-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n

This file was deleted.

1 change: 1 addition & 0 deletions examples/contact-sensor-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n

This file was deleted.

1 change: 1 addition & 0 deletions examples/light-switch-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n
1 change: 1 addition & 0 deletions examples/lighting-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n

# Custom RF power values
CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n
1 change: 1 addition & 0 deletions examples/ota-requestor-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n
1 change: 1 addition & 0 deletions examples/pump-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n
1 change: 1 addition & 0 deletions examples/pump-controller-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n
1 change: 1 addition & 0 deletions examples/temperature-measurement-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n

# Custom RF power values
CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y
Expand Down
3 changes: 0 additions & 3 deletions examples/thermostat/telink/boards/tlsr9518adk80d.overlay

This file was deleted.

1 change: 1 addition & 0 deletions examples/thermostat/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n
1 change: 1 addition & 0 deletions examples/window-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y
# Enable Power Management
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CHIP_ENABLE_PM_DURING_BLE=n

# Custom RF power values
CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y
Expand Down
11 changes: 11 additions & 0 deletions src/platform/telink/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/util.h>

#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE)
#include <zephyr/pm/policy.h>
#endif

#include <array>

// Includes for ieee802154 switchings
Expand Down Expand Up @@ -316,6 +320,9 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
VerifyOrReturnError(err == 0, MapErrorZephyr(err));
(void) bt_set_name(bt_dev_name);
BLERadioInitialized = true;
#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE)
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
#endif
}

// Prepare advertising request
Expand Down Expand Up @@ -959,6 +966,10 @@ void BLEManagerImpl::SwitchToIeee802154(void)
// irq_disable(IRQ1_SYSTIMER);
BLERadioInitialized = false;

#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE)
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
#endif

const struct device * radio_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_ieee802154));
__ASSERT(radio_dev != NULL, "Get radio_dev fail");

Expand Down