Skip to content

Commit

Permalink
[Telink] Ability to disable/enable PM during BLE operation (#25769)
Browse files Browse the repository at this point in the history
* [Telink] Remove tlsr9518adk80d.overlay

* [Telink] Ability to disable Zephyr PM during BLE
  • Loading branch information
serhiiSalamakha authored and pull[bot] committed Oct 18, 2023
1 parent d309238 commit 2445896
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 9 deletions.
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

0 comments on commit 2445896

Please sign in to comment.