Skip to content

Commit 89bd565

Browse files
authored
Merge pull request #13976 from LDong-Arm/cypress_sleep_debug_rework
PSoC 6: rework sleep overrides by Cypress's debug macro
2 parents 8196045 + b1da342 commit 89bd565

File tree

2 files changed

+12
-33
lines changed

2 files changed

+12
-33
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/cy_sleep_api.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626

2727
void hal_sleep(void)
2828
{
29+
// Noop, if the idle mode is active
30+
#if !defined(CY_CFG_PWR_SYS_IDLE_MODE) || (CY_CFG_PWR_SYS_IDLE_MODE != CY_CFG_PWR_MODE_ACTIVE)
2931
cyhal_syspm_sleep();
32+
#endif
3033
}
3134

3235
void hal_deepsleep(void)
3336
{
37+
#if !defined(CY_CFG_PWR_SYS_IDLE_MODE) || (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_DEEPSLEEP)
38+
3439
#if DEVICE_LPTICKER
3540
// A running timer will block DeepSleep, which would normally be
3641
// good because we don't want the timer to accidentally
@@ -41,9 +46,14 @@ void hal_deepsleep(void)
4146
cy_us_ticker_stop();
4247
cyhal_syspm_deepsleep();
4348
cy_us_ticker_start();
44-
#else
49+
#else // DEVICE_LPTICKER
50+
cyhal_syspm_sleep();
51+
#endif // DEVICE_LPTICKER
52+
53+
#elif CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_SLEEP
4554
cyhal_syspm_sleep();
46-
#endif /* DEVICE_LPTICKER */
55+
#endif // CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE
56+
// Noop, if the idle mode is active
4757
}
4858

4959
#endif /* DEVICE_SLEEP */

targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "cyhal_hwmgr.h"
2222
#include "cybsp.h"
2323
#include "cy_mbed_post_init.h"
24-
#include "mbed_power_mgmt.h"
2524
#include "mbed_error.h"
2625
#if MBED_CONF_RTOS_PRESENT
2726
#include "rtos_idle.h"
@@ -35,22 +34,6 @@
3534
#include "cy_serial_flash_qspi.h"
3635
#endif /* defined(MBED_CONF_TARGET_XIP_ENABLE) */
3736

38-
39-
#if (defined(CY_CFG_PWR_SYS_IDLE_MODE) && (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE))
40-
/*******************************************************************************
41-
* Function Name: active_idle_hook
42-
****************************************************************************//**
43-
*
44-
* Empty idle hook function to prevent the system entering sleep mode
45-
* automatically any time the system is idle.
46-
*
47-
*******************************************************************************/
48-
static void active_idle_hook(void)
49-
{
50-
/* Do nothing, so the rtos_idle_loop() performs while(1) */
51-
}
52-
#endif
53-
5437
MBED_WEAK void cy_mbed_post_bsp_init_hook(void)
5538
{
5639
/* By default, do nothing */
@@ -102,18 +85,4 @@ void mbed_sdk_init(void)
10285
/* Enable global interrupts (disabled in CM4 startup assembly) */
10386
__enable_irq();
10487
#endif
105-
106-
#if defined (CY_CFG_PWR_SYS_IDLE_MODE)
107-
/* Configure the lowest power state the system is allowed to enter
108-
* based on the System Idle Power Mode parameter value in the Device
109-
* Configurator. The default value is system deep sleep.
110-
*/
111-
#if (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_ACTIVE)
112-
rtos_attach_idle_hook(&active_idle_hook);
113-
#elif (CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_SLEEP)
114-
sleep_manager_lock_deep_sleep();
115-
#else
116-
/* Deep sleep is default state */
117-
#endif
118-
#endif
11988
}

0 commit comments

Comments
 (0)