refactor(core): update power API to Zephyr v2.5.0
See: https://github.com/zephyrproject-rtos/zephyr/pull/29410 PR: https://github.com/zmkfirmware/zmk/pull/736
This commit is contained in:
parent
71a85a0c8e
commit
ad981c3bbd
2 changed files with 5 additions and 14 deletions
|
@ -263,11 +263,8 @@ config ZMK_SLEEP
|
||||||
|
|
||||||
if ZMK_SLEEP
|
if ZMK_SLEEP
|
||||||
|
|
||||||
config SYS_POWER_DEEP_SLEEP_STATES
|
|
||||||
default y
|
|
||||||
|
|
||||||
choice SYS_PM_POLICY
|
choice SYS_PM_POLICY
|
||||||
default SYS_PM_POLICY_APP
|
default PM_POLICY_APP
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config DEVICE_POWER_MANAGEMENT
|
config DEVICE_POWER_MANAGEMENT
|
||||||
|
|
|
@ -23,18 +23,12 @@ bool is_usb_power_present() {
|
||||||
#endif /* CONFIG_USB */
|
#endif /* CONFIG_USB */
|
||||||
}
|
}
|
||||||
|
|
||||||
enum power_states sys_pm_policy_next_state(int32_t ticks) {
|
struct pm_state_info pm_policy_next_state(int32_t ticks) {
|
||||||
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
|
|
||||||
#ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1
|
|
||||||
if (zmk_activity_get_state() == ZMK_ACTIVITY_SLEEP && !is_usb_power_present()) {
|
if (zmk_activity_get_state() == ZMK_ACTIVITY_SLEEP && !is_usb_power_present()) {
|
||||||
return SYS_POWER_STATE_DEEP_SLEEP_1;
|
return (struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0};
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 */
|
|
||||||
#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */
|
|
||||||
|
|
||||||
return SYS_POWER_STATE_ACTIVE;
|
return (struct pm_state_info){PM_STATE_ACTIVE, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sys_pm_policy_low_power_devices(enum power_states pm_state) {
|
__weak bool pm_policy_low_power_devices(enum pm_state state) { return pm_is_sleep_state(state); }
|
||||||
return sys_pm_is_sleep_state(pm_state);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue