From 7f0c98d9775e45a79ae1cf7cf04274d9130262a6 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Fri, 27 Nov 2020 17:06:50 +0000 Subject: [PATCH 1/2] PSoC 6: remove debug sleep lock and hook from mbed_sdk_init --- .../TARGET_PSOC6/mbed_overrides.c | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c index 4d84800c47..c64406d2e6 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c @@ -21,7 +21,6 @@ #include "cyhal_hwmgr.h" #include "cybsp.h" #include "cy_mbed_post_init.h" -#include "mbed_power_mgmt.h" #include "mbed_error.h" #if MBED_CONF_RTOS_PRESENT #include "rtos_idle.h" @@ -35,22 +34,6 @@ #include "cy_serial_flash_qspi.h" #endif /* defined(MBED_CONF_TARGET_XIP_ENABLE) */ - -#if (defined(CY_CFG_PWR_SYS_IDLE_MODE) && (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE)) -/******************************************************************************* -* Function Name: active_idle_hook -****************************************************************************//** -* -* Empty idle hook function to prevent the system entering sleep mode -* automatically any time the system is idle. -* -*******************************************************************************/ -static void active_idle_hook(void) -{ - /* Do nothing, so the rtos_idle_loop() performs while(1) */ -} -#endif - MBED_WEAK void cy_mbed_post_bsp_init_hook(void) { /* By default, do nothing */ @@ -102,18 +85,4 @@ void mbed_sdk_init(void) /* Enable global interrupts (disabled in CM4 startup assembly) */ __enable_irq(); #endif - -#if defined (CY_CFG_PWR_SYS_IDLE_MODE) - /* Configure the lowest power state the system is allowed to enter - * based on the System Idle Power Mode parameter value in the Device - * Configurator. The default value is system deep sleep. - */ -#if (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE) - rtos_attach_idle_hook(&active_idle_hook); -#elif (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_SLEEP) - sleep_manager_lock_deep_sleep(); -#else - /* Deep sleep is default state */ -#endif -#endif } From b1da3429df6d2a5275917019784e893d634ef313 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Fri, 27 Nov 2020 17:03:27 +0000 Subject: [PATCH 2/2] PSoC 6: enable/disable sleep modes based on CY_CFG_PWR_SYS_IDLE_MODE --- targets/TARGET_Cypress/TARGET_PSOC6/cy_sleep_api.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/cy_sleep_api.c b/targets/TARGET_Cypress/TARGET_PSOC6/cy_sleep_api.c index 6ceb994fec..0b8f3dd98f 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/cy_sleep_api.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/cy_sleep_api.c @@ -26,11 +26,16 @@ void hal_sleep(void) { + // Noop, if the idle mode is active +#if !defined(CY_CFG_PWR_SYS_IDLE_MODE) || (CY_CFG_PWR_SYS_IDLE_MODE != CY_CFG_PWR_MODE_ACTIVE) cyhal_syspm_sleep(); +#endif } void hal_deepsleep(void) { +#if !defined(CY_CFG_PWR_SYS_IDLE_MODE) || (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_DEEPSLEEP) + #if DEVICE_LPTICKER // A running timer will block DeepSleep, which would normally be // good because we don't want the timer to accidentally @@ -41,9 +46,14 @@ void hal_deepsleep(void) cy_us_ticker_stop(); cyhal_syspm_deepsleep(); cy_us_ticker_start(); -#else +#else // DEVICE_LPTICKER cyhal_syspm_sleep(); -#endif /* DEVICE_LPTICKER */ +#endif // DEVICE_LPTICKER + +#elif CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_SLEEP + cyhal_syspm_sleep(); +#endif // CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE + // Noop, if the idle mode is active } #endif /* DEVICE_SLEEP */