PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Power Modes
PDL API Reference » SysPm (System Power Management) » Functions

## General Description

## Functions
void | Cy_SysPm_DeepSleepSetup (cy_en_syspm_deep_sleep_mode_t deepSleepMode)
| Sets the startup deepsleep mode of cy_DeepSleepMode variable. More...
void | Cy_SysPm_DeepSleepUpdate (void)
| Gets deepsleep mode and updates cy_DeepSleepMode variable. More...
cy_en_syspm_status_t | Cy_SysPm_CpuEnterSleep (cy_en_syspm_waitfor_t waitFor)
| Sets executing CPU to Sleep mode. More...
void | Cy_SysPm_Init (void)
| Initializes SysPm Driver.
bool | Cy_SysPm_IsLpmReady (void)
| Checks if the system is LPM ready. More...
cy_en_syspm_status_t | Cy_SysPm_SetDeepSleepMode (cy_en_syspm_deep_sleep_mode_t deepSleepMode)
| Allow users to implement any context store required before entering deep sleep in RTOS based builds, It is defined weak to allow callers override the default PDL implementation. More...
cy_en_syspm_status_t | Cy_SysPm_SetSysDeepSleepMode (cy_en_syspm_deep_sleep_mode_t deepSleepMode)
| Set the deepsleep mode for SYS PPU Group- deepsleep or deepsleep-ram or deepsleep-off. More...
cy_en_syspm_status_t | Cy_SysPm_SetAppDeepSleepMode (cy_en_syspm_deep_sleep_mode_t deepSleepMode)
| Set the deepsleep mode for APP PPU Group- deepsleep or deepsleep-ram or deepsleep-off. More...
cy_en_syspm_deep_sleep_mode_t | Cy_SysPm_GetSysDeepSleepMode (void)
| Get the SYS Power domain deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off. More...
cy_en_syspm_deep_sleep_mode_t | Cy_SysPm_GetAppDeepSleepMode (void)
| Get the APP Power domain deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off. More...
cy_en_syspm_status_t | Cy_SysPm_SetSOCMEMDeepSleepMode (cy_en_syspm_deep_sleep_mode_t deepSleepMode)
| Set the deepsleep mode for SOCMEM PPU - deepsleep or deepsleep-ram or deepsleep-off. More...
cy_en_syspm_status_t | Cy_SysPm_SetPPUDeepSleepMode (uint32_t ppu, uint32_t mode)
| Set the deep sleep mode for a particular PPU - ON, FULL_RET, MEM_RET, OFF. More...
cy_en_syspm_status_t | Cy_SysPm_SystemTransitionHpToLp (void)
| Performs system transition from High Performance mode(HP) to Low Power mode(LP) mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemTransitionLpToHp (void)
| Performs system transition from Low Power mode(LP) to High Performance mode(HP) mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemTransitionUlpToLp (void)
| Performs system transition from Ultra Low Power mode(ULP) to Low Power mode(LP) mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemTransitionLpToUlp (void)
| Performs system transition from Low Power mode(LP) to Ultra Low Power mode(ULP) mode. More...
cy_en_syspm_deep_sleep_mode_t | Cy_SysPm_GetDeepSleepMode (void)
| Get the overall system's deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off. More...
cy_en_syspm_boot_mode_t | Cy_SysPm_GetBootMode (void)
| Checks from which Deep Sleep mode the system has woke up. More...
void | Cy_SysPm_TriggerSoftReset (void)
| Triggers the System Soft reset.
void | Cy_SysPm_TriggerXRes (void)
| Triggers the XRES reset.
cy_en_syspm_status_t | Cy_SysPm_CpuEnterDeepSleep (cy_en_syspm_waitfor_t waitFor)
| Sets executing CPU to the Deep Sleep mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemEnterLp (void)
| Sets device into system Low Power mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemEnterUlp (void)
| Sets device into system Ultra Low Power mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemEnterHp (void)
| Sets device into System High Performance mode. More...
void | Cy_SysPm_SetRamTrimsPreDs (void)
| Sets RAM trims before entering Deepsleep.
void | Cy_SysPm_SetRamTrimsPostDs (void)
| Sets RAM trims After exiting Deepsleep.
cy_en_syspm_status_t | Cy_SysPm_SystemEnterHibernate (void)
| Sets the device into system Hibernate mode. More...
void | Cy_SysPm_SetHibernateWakeupSource (uint32_t wakeupSource)
| This function configures sources to wake up the device from the system Hibernate power mode. More...
void | Cy_SysPm_ClearHibernateWakeupSource (uint32_t wakeupSource)
| This function disables a wakeup source that was previously configured to wake up the device from the system Hibernate mode. More...
cy_en_syspm_hibernate_wakeup_source_t | Cy_SysPm_GetHibernateWakeupCause (void)
| This function gets the wakeup cause for Hibernate mode. More...
__STATIC_INLINE void | Cy_SysPm_ClearHibernateWakeupCause (void)
| This function Clears the wakeup cause register.
cy_en_syspm_status_t | Cy_SysPm_SystemSetMinRegulatorCurrent (void)
| Sets the system into minimum core regulator current mode. More...
cy_en_syspm_status_t | Cy_SysPm_SystemSetNormalRegulatorCurrent (void)
| Sets the system to normal regulator current mode. More...
__STATIC_INLINE void | Cy_SysPm_CpuSleepOnExit (bool enable)
| This function configures the sleep-on-exit feature of the CPU. More...
__STATIC_INLINE void | Cy_SysPm_CpuSendWakeupEvent (void)
| Sends the SEV (Send Event) ARM instruction to the system. More...
__STATIC_INLINE bool | Cy_SysPm_SystemIsMinRegulatorCurrentSet (void)
| Check whether the system regulator is set to minimal current mode. More...

## Function Documentation

## ◆ Cy_SysPm_DeepSleepSetup()

void Cy_SysPm_DeepSleepSetup | ( | cy_en_syspm_deep_sleep_mode_t | deepSleepMode | ) |

Sets the startup deepsleep mode of cy_DeepSleepMode variable.

Parameters

  deepSleepMode | CY_SYSPM_MODE_DEEPSLEEP or CY_SYSPM_MODE_DEEPSLEEP_RAM or CY_SYSPM_MODE_DEEPSLEEP_OFF

Note
  This API does not take into account any run-time deepsleep mode updates. Should any updates occur, Cy_SysPm_DeepSleepUpdate must be called afterwards on the CM33_NS and CM55.

## ◆ Cy_SysPm_DeepSleepUpdate()

void Cy_SysPm_DeepSleepUpdate | ( | void |  | ) |

Gets deepsleep mode and updates cy_DeepSleepMode variable.

Updates global variables used by the Cy_SysPm_CpuEnterDeepSleep().

## ◆ Cy_SysPm_CpuEnterSleep()

cy_en_syspm_status_t Cy_SysPm_CpuEnterSleep | ( | cy_en_syspm_waitfor_t | waitFor | ) |

Sets executing CPU to Sleep mode.

Puts the CPU executing this function into CPU Sleep power mode. If callback functions were registered they are also executed.

For more detail about switching into CPU Sleep power mode and debug, refer to the device technical reference manual (TRM).

If at least one callback function with the CY_SYSPM_SLEEP type was registered, the following algorithm is executed: Prior to entering CPU Sleep mode, all callback functions of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_READY parameter are called. This allows the driver to signal whether it is ready to enter the low power mode. If any of the callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_READY parameter returns CY_SYSPM_FAIL, the remaining callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_READY parameter are skipped. After the first CY_SYSPM_FAIL, all the CY_SYSPM_SLEEP callbacks that were previously executed before getting the CY_SYSPM_CHECK_FAIL are executed with the CY_SYSPM_CHECK_FAIL parameter. The CPU Sleep mode is not entered and the Cy_SysPm_CpuEnterSleep() function returns CY_SYSPM_FAIL.

If all of the callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_FAIL parameters calls are skipped. All callbacks of the CY_SYSPM_SLEEP type and then CY_SYSPM_BEFORE_TRANSITION parameter calls are executed, allowing the peripherals to prepare for CPU Sleep. The CPU then enters Sleep mode. This is a CPU-centric power mode. This means that the CPU has entered Sleep mode and its main clock is removed. Any enabled interrupt can cause a CPU wakeup from Sleep mode.

For multi-core devices, CPU wakeup can also be performed using the Send Event (SEV) assembly instruction executed from the other active CPU. Such wakeup is expected only if the CPU Sleep power mode is done with WFE assembly instruction.

After a wakeup from CPU Sleep, all of the registered callbacks of the CY_SYSPM_SLEEP type and with the CY_SYSPM_AFTER_TRANSITION parameter are executed to return the peripherals to CPU active operation. The Cy_SysPm_CpuEnterSleep() function returns CY_SYSPM_SUCCESS. No callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_BEFORE_TRANSITION parameter or callbacks of the CY_SYSPM_SLEEP type and CY_SYSPM_AFTER_TRANSITION parameter callbacks are executed if CPU Sleep mode is not entered.

Note
  The last callback that returns CY_SYSPM_FAIL is not executed with the CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating CY_SYSPM_FAIL is expected to not make any changes that require being undone.

To support control of callback execution order the following method is implemented. Callback function with the CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are registered. Callback function with the CY_SYSPM_CHECK_FAIL and CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they are registered.

The return value from executed callback functions with the CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION modes are ignored.

cy_en_syspm_callback_mode_t, except the CY_SYSPM_CHECK_READY, are ignored

Note
  The Arm BSD assembly instruction is not required in this function because the function implementation ensures the SLEEPDEEP bit of SCS register is settled prior executing WFI/WFE instruction.
  This API is secure aware but when running on the core without TrustZone, there will be no special security-related behavior. See header subsection Secure Aware SYSPM for further details.

Parameters

  waitFor | Selects wait for action. See cy_en_syspm_waitfor_t.

Returns
  Entered status, see cy_en_syspm_status_t.

Side Effects
  For CY8C6xx6, CY8C6xx7 devices this function clears the Event Register of the CM4 CPU after wakeup from WFE.

Function Usage
  /* Scenario: There is a need to put the CPU into Sleep mode */
  /* Prepare the system for CPU Sleep power mode here */
  if(CY_SYSPM_SUCCESS != Cy_SysPm_CpuEnterSleep(CY_SYSPM_WAIT_FOR_INTERRUPT))
  {
  /* The CPU Sleep mode was not entered because a registered
  * Sleep "check ready" callback returned a "not success" status
  */
  }
  else
  {
  /* If the program has reached here, the CPU has just woken up
  * from the CPU Sleep mode
  */
  }
  CY_SYSPM_SUCCESS
  @ CY_SYSPM_SUCCESS
  Successful.
  Definition: cy_syspm.h:1353
  CY_SYSPM_WAIT_FOR_INTERRUPT
  @ CY_SYSPM_WAIT_FOR_INTERRUPT
  Wait for an interrupt.
  Definition: cy_syspm.h:1369
  Cy_SysPm_CpuEnterSleep
  cy_en_syspm_status_t Cy_SysPm_CpuEnterSleep(cy_en_syspm_waitfor_t waitFor)
  Sets executing CPU to Sleep mode.
  Definition: cy_syspm_v4.c:671

## ◆ Cy_SysPm_IsLpmReady()

bool Cy_SysPm_IsLpmReady | ( | void |  | ) |

Checks if the system is LPM ready.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_SRSS_MAIN.

Returns
  - True if the system is LPM Ready.
  - False if the system is not LPM Ready.

## ◆ Cy_SysPm_SetDeepSleepMode()

cy_en_syspm_status_t Cy_SysPm_SetDeepSleepMode | ( | cy_en_syspm_deep_sleep_mode_t | deepSleepMode | ) |

Allow users to implement any context store required before entering deep sleep in RTOS based builds, It is defined weak to allow callers override the default PDL implementation.

Set the deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off

Note
  If mode is set to CY_SYSPM_MODE_DEEPSLEEP_RAM && Application in Flash, user needs to take care of below

Two types of images need to be generated

1. Flash image
   - Contains the actual application.
2. RAM Image(Resides in RAM)
   - Contains Warmboot Entry Point function.
   - SMIF initialization is performed only during coldboot, and not in warmboot, so RAM Image will have the code performing SMIF initialization before jumping to Flash Image.

Before entering CY_SYSPM_MODE_DEEPSLEEP_RAM, user need to take care of below

1. Entry point
   - Set entry point to a function located in RAM Image using
   - Cy_Syslib_SetWarmBootEntryPoint(Syslib Driver)

After waking up from CY_SYSPM_MODE_DEEPSLEEP_RAM, bootrom jumps to entry point function located in RAM image code. Entry point function should take care of below

1. Vector table and Peripheral IP's enabling
   - Set VTOR register with vector table address.
   - Enable all the peripheral IP's using Cy_SysClk_PeriGroupSetSlaveCtl.
2. SMIF Initialization
   - Perform SMIF Initialization.
3. Jump to API in the Flash.

Parameters

  deepSleepMode | CY_SYSPM_MODE_DEEPSLEEP or CY_SYSPM_MODE_DEEPSLEEP_RAM or CY_SYSPM_MODE_DEEPSLEEP_OFF

Returns
  - CY_SYSPM_SUCCESS - Deep sleep mode is set
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.

## ◆ Cy_SysPm_SetSysDeepSleepMode()

cy_en_syspm_status_t Cy_SysPm_SetSysDeepSleepMode | ( | cy_en_syspm_deep_sleep_mode_t | deepSleepMode | ) |

Set the deepsleep mode for SYS PPU Group- deepsleep or deepsleep-ram or deepsleep-off.

Note
  If mode is set to CY_SYSPM_MODE_DEEPSLEEP_RAM && Application in Flash, user needs to take care of below

Two types of images need to be generated

1. Flash image
   - Contains the actual application.
2. RAM Image(Resides in RAM)
   - Contains Warmboot Entry Point function.
   - SMIF initialization is performed only during coldboot, and not in warmboot, so RAM Image will have the code performing SMIF initialization before jumping to Flash Image.

Before entering CY_SYSPM_MODE_DEEPSLEEP_RAM, user need to take care of below

1. Entry point
   - Set entry point to a function located in RAM Image using
   - Cy_Syslib_SetWarmBootEntryPoint(Syslib Driver)

After waking up from CY_SYSPM_MODE_DEEPSLEEP_RAM, bootrom jumps to entry point function located in RAM image code. Entry point function should take care of below

1. Vector table and Peripheral IP's enabling
   - Set VTOR register with vector table address.
   - Enable all the peripheral IP's using Cy_SysClk_PeriGroupSetSlaveCtl.
2. SMIF Initialization
   - Perform SMIF Initialization.
3. Jump to API in the Flash.

Parameters

  deepSleepMode | CY_SYSPM_MODE_DEEPSLEEP or CY_SYSPM_MODE_DEEPSLEEP_RAM or CY_SYSPM_MODE_DEEPSLEEP_OFF

Returns
  - CY_SYSPM_SUCCESS - Deep sleep mode is set
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.

## ◆ Cy_SysPm_SetAppDeepSleepMode()

cy_en_syspm_status_t Cy_SysPm_SetAppDeepSleepMode | ( | cy_en_syspm_deep_sleep_mode_t | deepSleepMode | ) |

Set the deepsleep mode for APP PPU Group- deepsleep or deepsleep-ram or deepsleep-off.

Note
  If mode is set to CY_SYSPM_MODE_DEEPSLEEP_RAM && Application in Flash, user needs to take care of below

Two types of images need to be generated

1. Flash image
   - Contains the actual application.
2. RAM Image(Resides in RAM)
   - Contains Warmboot Entry Point function.
   - SMIF initialization is performed only during coldboot, and not in warmboot, so RAM Image will have the code performing SMIF initialization before jumping to Flash Image.

Before entering CY_SYSPM_MODE_DEEPSLEEP_RAM, user need to take care of below

1. Entry point
   - Set entry point to a function located in RAM Image using
   - Cy_Syslib_SetWarmBootEntryPoint(Syslib Driver)

After waking up from CY_SYSPM_MODE_DEEPSLEEP_RAM, bootrom jumps to entry point function located in RAM image code. Entry point function should take care of below

1. Vector table and Peripheral IP's enabling
   - Set VTOR register with vector table address.
   - Enable all the peripheral IP's using Cy_SysClk_PeriGroupSetSlaveCtl.
2. SMIF Initialization
   - Perform SMIF Initialization.
3. Jump to API in the Flash.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions are PROT_PERI0_PWRMODE_PWRMODE/PROT_PERI1_M55APPCPUSS

Parameters

  deepSleepMode | CY_SYSPM_MODE_DEEPSLEEP or CY_SYSPM_MODE_DEEPSLEEP_RAM or CY_SYSPM_MODE_DEEPSLEEP_OFF

Returns
  - CY_SYSPM_SUCCESS - Deep sleep mode is set
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.

## ◆ Cy_SysPm_GetSysDeepSleepMode()

cy_en_syspm_deep_sleep_mode_t Cy_SysPm_GetSysDeepSleepMode | ( | void |  | ) |

Get the SYS Power domain deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_PWRMODE_PWRMODE.

Returns
  Returns cy_en_syspm_deep_sleep_mode_t

## ◆ Cy_SysPm_GetAppDeepSleepMode()

cy_en_syspm_deep_sleep_mode_t Cy_SysPm_GetAppDeepSleepMode | ( | void |  | ) |

Get the APP Power domain deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off.

Returns
  Returns cy_en_syspm_deep_sleep_mode_t

## ◆ Cy_SysPm_SetSOCMEMDeepSleepMode()

cy_en_syspm_status_t Cy_SysPm_SetSOCMEMDeepSleepMode | ( | cy_en_syspm_deep_sleep_mode_t | deepSleepMode | ) |

Set the deepsleep mode for SOCMEM PPU - deepsleep or deepsleep-ram or deepsleep-off.

Note
  If mode is set to CY_SYSPM_MODE_DEEPSLEEP_RAM && Application in Flash, user needs to take care of below

Two types of images need to be generated

1. Flash image
   - Contains the actual application.
2. RAM Image(Resides in RAM)
   - Contains Warmboot Entry Point function.
   - SMIF initialization is performed only during coldboot, and not in warmboot, so RAM Image will have the code performing SMIF initialization before jumping to Flash Image.

Before entering CY_SYSPM_MODE_DEEPSLEEP_RAM, user need to take care of below

1. Entry point
   - Set entry point to a function located in RAM Image using
   - Cy_Syslib_SetWarmBootEntryPoint(Syslib Driver)

After waking up from CY_SYSPM_MODE_DEEPSLEEP_RAM, bootrom jumps to entry point function located in RAM image code. Entry point function should take care of below

1. Vector table and Peripheral IP's enabling
   - Set VTOR register with vector table address.
   - Enable all the peripheral IP's using Cy_SysClk_PeriGroupSetSlaveCtl.
2. SMIF Initialization
   - Perform SMIF Initialization.
3. Jump to API in the Flash.

Parameters

  deepSleepMode | CY_SYSPM_MODE_DEEPSLEEP or CY_SYSPM_MODE_DEEPSLEEP_RAM or CY_SYSPM_MODE_DEEPSLEEP_OFF

Returns
  - CY_SYSPM_SUCCESS - Deep sleep mode is set
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.

## ◆ Cy_SysPm_SetPPUDeepSleepMode()

cy_en_syspm_status_t Cy_SysPm_SetPPUDeepSleepMode | ( | uint32_t | ppu,
|  | uint32_t | mode
| ) |  |

Set the deep sleep mode for a particular PPU - ON, FULL_RET, MEM_RET, OFF.

Parameters

  ppu | Base address of the PPU that needs to be configured.
  mode | Deep Sleep mode to be set for the PPU.

Returns
  - CY_SYSPM_SUCCESS - Deep sleep mode is set
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.

## ◆ Cy_SysPm_SystemTransitionHpToLp()

cy_en_syspm_status_t Cy_SysPm_SystemTransitionHpToLp | ( | void |  | ) |

Performs system transition from High Performance mode(HP) to Low Power mode(LP) mode.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_SRSS_MAIN.

Returns
  - CY_SYSPM_SUCCESS - Successfully transitioned from HP to LP mode.
  - CY_SYSPM_FAIL - The transition failed.

## ◆ Cy_SysPm_SystemTransitionLpToHp()

cy_en_syspm_status_t Cy_SysPm_SystemTransitionLpToHp | ( | void |  | ) |

Performs system transition from Low Power mode(LP) to High Performance mode(HP) mode.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_SRSS_MAIN.

Returns
  - CY_SYSPM_SUCCESS - Successfully transitioned from LP to HP mode.
  - CY_SYSPM_FAIL - The transition failed.

## ◆ Cy_SysPm_SystemTransitionUlpToLp()

cy_en_syspm_status_t Cy_SysPm_SystemTransitionUlpToLp | ( | void |  | ) |

Performs system transition from Ultra Low Power mode(ULP) to Low Power mode(LP) mode.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_SRSS_MAIN.

Returns
  - CY_SYSPM_SUCCESS - Successfully transitioned from ULP to LP mode.
  - CY_SYSPM_FAIL - The transition failed.

## ◆ Cy_SysPm_SystemTransitionLpToUlp()

cy_en_syspm_status_t Cy_SysPm_SystemTransitionLpToUlp | ( | void |  | ) |

Performs system transition from Low Power mode(LP) to Ultra Low Power mode(ULP) mode.

Note
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_SRSS_MAIN.

Returns
  - CY_SYSPM_SUCCESS - Successfully transitioned from LP to ULP mode.
  - CY_SYSPM_FAIL - The transition failed.

## ◆ Cy_SysPm_GetDeepSleepMode()

cy_en_syspm_deep_sleep_mode_t Cy_SysPm_GetDeepSleepMode | ( | void |  | ) |

Get the overall system's deepsleep mode - deepsleep or deepsleep-ram or deepsleep-off.

Returns
  Returns cy_en_syspm_deep_sleep_mode_t

Note
  In a multi-core/multi-power domain architectures, CY_SYSPM_MODE_DEEPSLEEP_NONE will be returned by the API, if any of the following conditions are met ...

1) Main Power domains(PD0, PD1) are not at all configured for a particular DS.

2) A mix in DS states between power domains, for example PD0 configures deepsleep and PD1 configures deepsleep-RAM.

Note
  This API should only be used after Cy_SysPm_SetDeepSleepMode, as it will give only the mode that is set by Cy_SysPm_SetDeepSleepMode.
  This API is secure aware. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_PWRMODE_PWRMODE.

## ◆ Cy_SysPm_GetBootMode()

cy_en_syspm_boot_mode_t Cy_SysPm_GetBootMode | ( | void |  | ) |

Checks from which Deep Sleep mode the system has woke up.

Returns
  Returns CY_SYSPM_WARM_BOOT_MODE or CY_SYSPM_WARM_COLD_MODE, if system performs warm or cold, else return CY_SYSPM_POR_BOOT_MODE if its a normal(POR) boot.

Note
  Use this API immediately after the boot, before writing any of the PPU registers,because this API depends on the programmed state of the PPU registers, so call it before the PPU registers get overwritten.

## ◆ Cy_SysPm_CpuEnterDeepSleep()

cy_en_syspm_status_t Cy_SysPm_CpuEnterDeepSleep | ( | cy_en_syspm_waitfor_t | waitFor | ) |

Sets executing CPU to the Deep Sleep mode.

Puts the CPU executing the function into CPU Deep Sleep. For a single CPU devices the device will immediately transition to system Deep Sleep. For a dual CPU devices the device will transition to system Deep Sleep only after both CPUs are in CPU Deep Sleep power mode.

Prior to entering the CPU Deep Sleep mode, all callbacks of the CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY parameter registered callbacks are called, allowing the driver to signal whether it is ready to enter the power mode. If any CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY parameter call returns CY_SYSPM_FAIL, the remaining callback CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY parameter are skipped. After the first CY_SYSPM_FAIL, all the CY_SYSPM_DEEPSLEEP callbacks that were previously executed before getting the CY_SYSPM_CHECK_FAIL are executed with the CY_SYSPM_CHECK_FAIL parameter. The CPU Deep Sleep mode is not entered and the Cy_SysPm_CpuEnterDeepSleep() function returns CY_SYSPM_FAIL.

If all callbacks of the CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all callbacks of the CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_FAIL parameter calls are skipped. All callbacks of the CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_BEFORE_TRANSITION parameter calls are then executed, allowing the peripherals to prepare for CPU Deep Sleep. The Deep Sleep mode is then entered. Any enabled interrupt can cause a wakeup from the Deep Sleep mode.

Note
  The last callback that returns CY_SYSPM_FAIL is not executed with the CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating CY_SYSPM_FAIL is expected to not make any changes that require being undone.

For multi-CPU devices (except CY8C6xx6 and CY8C6xx7) there is a possible situation when a syscall operation (for example during flash read or write) is executing. If the CM0+ CPU tries to enter Deep Sleep, it will fail. All the CY_SYSPM_DEEPSLEEP callbacks that were previously executed, are executed with the CY_SYSPM_CHECK_FAIL parameter. Deep Sleep mode is not entered and the Cy_SysPm_CpuEnterDeepSleep() function returns CY_SYSPM_SYSCALL_PENDING.

The return value from executed callback functions with the CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION modes are ignored.

If the firmware attempts to enter this mode before the system is ready (that is, when PWR_CONTROL.LPM_READY = 0), then the CPU(s) will go into the CPU Sleep mode instead and automatically enter system Deep Sleep mode when the system is ready. On dual CPU devices, if one CPU enters CPU Deep Sleep and the other CPU remains active or is in CPU Sleep the first CPU will remain in CPU Deep Sleep. A CPU Deep Sleep is functionally identical to CPU Sleep.

The device enters system Deep Sleep mode when all the CPU(s) are in CPU Deep Sleep, there are no busy peripherals, the debugger is not active, and the Deep Sleep power and reference are ready (PWR_CONTROL.LPM_READY=1).

The peripherals that do not need a clock or that receive a clock from their external interface (e.g. I2C/SPI) may continue operating in system Deep Sleep. All circuits using current from Vccdpslp supply are limited by its maximum current specification of the Deep Sleep regulator.

Wakeup occurs when an interrupt asserts from a Deep Sleep active peripheral. For more detail, see the corresponding peripheral's datasheet.

For multi-core devices, CPU wakeup can also be performed using the Send Event (SEV) assembly instruction executed from the other active CPU. Such wakeup is expected only if the CPU Sleep power mode is done with WFE assembly instruction.

Note
  For multi-CPU devices, the second CPU, if it did not participate in system wakeup, remains in CPU Deep Sleep mode. Any Deep Sleep capable interrupt routed to this CPU can also wake it.

For more detail about switching into the system Deep Sleep power mode and debug, refer to the device TRM.

A normal wakeup from the Deep Sleep power mode returns to either ULP or LP mode, depending on the previous state and programmed behavior for the particular wakeup interrupt. As soon as the system resumes LP or ULP mode the CPU(s) return to CPU Active or CPU Deep Sleep mode, depending on their configured wakeup settings.

After wakeup from CPU Deep Sleep, all of the registered callbacks with CY_SYSPM_DEEPSLEEP type with CY_SYSPM_AFTER_TRANSITION are executed to return peripherals to active operation. The Cy_SysPm_CpuEnterDeepSleep() function returns CY_SYSPM_SUCCESS. No callbacks are executed with CY_SYSPM_DEEPSLEEP type with CY_SYSPM_BEFORE_TRANSITION or CY_SYSPM_AFTER_TRANSITION parameter, if Deep Sleep mode was not entered.

To support control of callback execution order th following method is implemented. Callback function with the CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are registered. Callback function with the CY_SYSPM_CHECK_FAIL and CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they are registered.

Note
  This function clears the reset reason before going to deep sleep
  This API is secure aware but when running on the core without TrustZone, there will be no special security-related behavior. See header subsection Secure Aware SYSPM for further details. The involved PPC regions is PROT_PERI0_SRSS_MAIN.

Parameters

  waitFor | Selects wait for action. See cy_en_syspm_waitfor_t.

Side Effects
  For CY8C6xx6, CY8C6xx7 devices this function clears the Event Register of the CM4 CPU after wakeup from WFE.

Side Effects
  This function changes the slow and fast clock dividers right before entering into system Deep Sleep and restores these dividers after wakeup.

Returns
  Entered status, see cy_en_syspm_status_t.

Note
  The FLL/PLL are not restored right before the CPU(s) start executing the instructions after system Deep Sleep. This can affect the peripheral that is driven by PLL/FLL. Ensure that the PLL/FLL are properly restored (locked) after wakeup from System Deep Sleep. Refer to the SysClk (System Clock) driver documentation for information about how to read the PLL/FLL lock statuses.
  The Arm BSD assembly instruction is not required in this function because the function implementation ensures the SLEEPDEEP bit of SCS register is settled prior executing the WFI/WFE instruction.

Function Usage
  /* Scenario: There is a need to put the CPU into Deep Sleep mode */
  /* Prepare the system for Deep Sleep power mode here */
  if(CY_SYSPM_SUCCESS != Cy_SysPm_CpuEnterDeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT))
  {
  /* CPU did not enter Deep Sleep mode because a registered
  * CPU Deep Sleep "check ready" callback returned a "not success" status
  */
  }
  else
  {
  /* If the program has reached here, the core is just woken up
  * from the CPU Deep Sleep mode
  */
  }
  Cy_SysPm_CpuEnterDeepSleep
  cy_en_syspm_status_t Cy_SysPm_CpuEnterDeepSleep(cy_en_syspm_waitfor_t waitFor)
  Sets executing CPU to the Deep Sleep mode.
  Definition: cy_syspm_v4.c:1333

## ◆ Cy_SysPm_SystemEnterLp()

cy_en_syspm_status_t Cy_SysPm_SystemEnterLp | ( | void |  | ) |

Sets device into system Low Power mode.

Returns the system to the default LP mode by raising the core voltage. In the LP mode, the clock frequencies can be increased to t he LP mode limitations. Refer to the device datasheet for frequency limitations in the LP mode. Approximate LP limit values - LP Limitations.

Prior to entering the system LP mode, all the registered CY_SYSPM_LP callbacks with CY_SYSPM_CHECK_READY parameter are called. This allows the driver to signal that it is not ready to enter the system LP mode. If any CY_SYSPM_LP callbacks with the CY_SYSPM_CHECK_READY parameter call return CY_SYSPM_FAIL, the remaining CY_SYSPM_LP callbacks with the CY_SYSPM_CHECK_READY parameter calls are skipped. All of the CY_SYSPM_LP callbacks with the CY_SYSPM_BEFORE_TRANSITION require to reduce the clock frequency before entering LP mode. All of the CY_SYSPM_LP callbacks with the CY_SYSPM_AFTER_TRANSITION may now increase the Clock frequency to the target for LP mode.

After a CY_SYSPM_FAIL, all of the CY_SYSPM_LP callbacks with CY_SYSPM_CHECK_FAIL parameter are executed that correspond to the CY_SYSPM_LP callbacks with CY_SYSPM_CHECK_READY parameter that occurred up to the point of failure. System LP mode is not entered and the Cy_SysPm_SystemEnterLp() function returns CY_SYSPM_FAIL.

If all CY_SYSPM_LP callbacks with the CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all CY_SYSPM_LP callbacks with CY_SYSPM_CHECK_FAIL are skipped and all CY_SYSPM_LP callbacks with the CY_SYSPM_BEFORE_TRANSITION parameter are executed. This allows the peripherals to prepare for LP mode. The system LP mode is then entered.

After entering the system LP mode, all of the registered CY_SYSPM_LP callbacks with the CY_SYSPM_AFTER_TRANSITION parameter are executed to complete preparing the peripherals for low power operation. The Cy_SysPm_SystemEnterLp() function returns CY_SYSPM_SUCCESS. No CY_SYSPM_LP callbacks with the CY_SYSPM_BEFORE_TRANSITION or CY_SYSPM_AFTER_TRANSITION parameter are executed if the system LP mode is not entered.

Note
  The last callback that returns CY_SYSPM_FAIL is not executed with the CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating CY_SYSPM_FAIL is expected to not make any changes that require being undone.
  It is not possible to transition directly between ULP and HP modes. The device must first be transitioned to LP mode and then to the desired mode.

The return value from executed callback functions with the CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION modes are ignored.

To support control of callback execution order th following method is implemented. Callback function with the CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are registered. Callback function with the CY_SYSPM_CHECK_FAIL and CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they are registered.

Returns
  - CY_SYSPM_SUCCESS - Entered the system LP mode or the device is already in LP mode.
  - CY_SYSPM_INVALID_STATE - The system LP mode was not set. The system LP mode was not set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers (to enter LP mode) via syscall.
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.
  - CY_SYSPM_FAIL - The system LP mode is not entered. For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Function Usage
  /* Scenario: There is a need to put the device to the system LP mode */
  if(CY_SYSPM_SUCCESS != Cy_SysPm_SystemEnterLp())
  {
  /* System did not enter LP mode because a registered
  * LP mode "check ready" callback returned a "not success" status
  */
  }
  /* Reconfigure/switch on the peripherals
  * with relaxed power consumption restrictions
  */
  /* Call Cy_SysLib_SetWaitStates(true, clkMHz);
  * where clkMHz is the current CPU frequency in MHz
  */
  Cy_SysPm_SystemEnterLp
  cy_en_syspm_status_t Cy_SysPm_SystemEnterLp(void)
  Sets device into system Low Power mode.
  Definition: cy_syspm_v4.c:3450

## ◆ Cy_SysPm_SystemEnterUlp()

cy_en_syspm_status_t Cy_SysPm_SystemEnterUlp | ( | void |  | ) |

Sets device into system Ultra Low Power mode.

System ULP mode is similar to system LP mode. The difference is that the system is put under ULP Limitations.

Before entering system ULP mode, the user must configure the system so the maximum clock frequencies are less than the ULP mode specifications presented in the device datasheet. Refer to the device datasheet for the maximum clock limitations in the ULP mode with reduced core supply regulator voltages.

Prior to entering system ULP mode, all the registered CY_SYSPM_ULP callbacks with CY_SYSPM_CHECK_READY parameter are called. This allows the driver to signal if it is not ready to enter system ULP mode. If any CY_SYSPM_ULP callback with the CY_SYSPM_CHECK_READY parameter call returns CY_SYSPM_FAIL, the remaining CY_SYSPM_ULP callbacks with the CY_SYSPM_CHECK_READY parameter are skipped.

All of the CY_SYSPM_ULP callbacks with the CY_SYSPM_BEFORE_TRANSITION require to reduce the clock frequency before entering ULP mode. All of the CY_SYSPM_ULP callbacks with the CY_SYSPM_AFTER_TRANSITION may now increase the Clock frequency to the target for ULP mode.

After a CY_SYSPM_FAIL, all of the CY_SYSPM_ULP callbacks with the CY_SYSPM_CHECK_FAIL parameter are executed that correspond to the CY_SYSPM_ULP callback with CY_SYSPM_CHECK_READY parameter that occurred up to the point of failure. System ULP mode is not entered and the Cy_SysPm_SystemEnterUlp() function returns CY_SYSPM_FAIL.

If all CY_SYSPM_ULP callbacks with the CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all CY_SYSPM_ULP callbacks with CY_SYSPM_CHECK_FAIL calls are skipped and all CY_SYSPM_ULP callbacks with the CY_SYSPM_BEFORE_TRANSITION parameter are executed. This allows preparation for ULP. The system ULP mode is then entered.

After entering system ULP, all of the registered CY_SYSPM_ULP callbacks with the CY_SYSPM_AFTER_TRANSITION parameter are executed to complete preparing the peripherals for ULP operation. The Cy_SysPm_SystemEnterUlp() function returns CY_SYSPM_SUCCESS. No CY_SYSPM_ULP callbacks with the CY_SYSPM_BEFORE_TRANSITION or CY_SYSPM_AFTER_TRANSITION parameter are executed, if ULP mode is not entered.

Note
  The last callback that returns CY_SYSPM_FAIL is not executed with the CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating CY_SYSPM_FAIL is expected to not make any changes that require being undone.
  It is not possible to transition directly between ULP and HP modes. The device must first be transitioned to LP mode and then to the desired mode.

The return value from executed callback functions with the CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION modes are ignored.

To support control of callback execution order th following method is implemented. Callback function with the CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are registered. Callback function with the CY_SYSPM_CHECK_FAIL and CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they are registered.

Returns
  - CY_SYSPM_SUCCESS - Entered the system ULP mode or the device is already in ULP mode.
  - CY_SYSPM_INVALID_STATE - System ULP mode was not set. The ULP mode was not set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers (to enter system ULP mode) via syscall.
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.
  - CY_SYSPM_FAIL - The system ULP mode is not entered. For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Function Usage
  /* Scenario: There is a need to put the device into the ULP mode */
  /* Prepare the device for system ULP entering - reconfigure/switch off
  * some used peripherals to match the current consumption and operating
  * frequency restrictions of ULP mode.
  */
  /* Call Cy_SysLib_SetWaitStates(true, clkMHz);
  * where clkMHz is the CPU frequency in MHz
  */
  if(CY_SYSPM_SUCCESS != Cy_SysPm_SystemEnterUlp())
  {
  /* System did not enter ULP mode because a registered
  * ULP "check ready" callback returned a "not success" status
  */
  }
  /* Device is in system ULP mode */
  Cy_SysPm_SystemEnterUlp
  cy_en_syspm_status_t Cy_SysPm_SystemEnterUlp(void)
  Sets device into system Ultra Low Power mode.
  Definition: cy_syspm_v4.c:3369

## ◆ Cy_SysPm_SystemEnterHp()

cy_en_syspm_status_t Cy_SysPm_SystemEnterHp | ( | void |  | ) |

Sets device into System High Performance mode.

System HP mode is similar to system LP and ULP mode. The difference is that the system is put at voltage which are above LP and ULP.

Before entering system HP mode, the user must configure the system so the maximum clock frequencies are at HP mode specifications presented in the device datasheet. Refer to the device datasheet for the maximum clock limitations in the HP mode with reduced core supply regulator voltages.

Prior to entering system HP mode, all the registered CY_SYSPM_HP callbacks with CY_SYSPM_CHECK_READY parameter are called. This allows the driver to signal if it is not ready to enter system HP mode. If any CY_SYSPM_HP callback with the CY_SYSPM_CHECK_READY parameter call returns CY_SYSPM_FAIL, the remaining CY_SYSPM_HP callbacks with the CY_SYSPM_CHECK_READY parameter are skipped. All of the CY_SYSPM_HP callbacks with the CY_SYSPM_BEFORE_TRANSITION require to reduce the clock frequency before entering HP mode. All of the CY_SYSPM_HP callbacks with the CY_SYSPM_AFTER_TRANSITION may now increase the Clock frequency to the target for HP mode.

After a CY_SYSPM_FAIL, all of the CY_SYSPM_HP callbacks with the CY_SYSPM_CHECK_FAIL parameter are executed that correspond to the CY_SYSPM_HP callback with CY_SYSPM_CHECK_READY parameter that occurred up to the point of failure. System HP mode is not entered and the Cy_SysPm_SystemEnterHp() function returns CY_SYSPM_FAIL.

If all CY_SYSPM_HP callbacks with the CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all CY_SYSPM_HP callbacks with CY_SYSPM_CHECK_FAIL calls are skipped and all CY_SYSPM_HP callbacks with the CY_SYSPM_BEFORE_TRANSITION parameter are executed. This allows preparation for HP. The system HP mode is then entered.

After entering system HP, all of the registered CY_SYSPM_HP callbacks with the CY_SYSPM_AFTER_TRANSITION parameter are executed to complete preparing the peripherals for HP operation. The Cy_SysPm_SystemEnterUlp() function returns CY_SYSPM_SUCCESS. No CY_SYSPM_HP callbacks with the CY_SYSPM_BEFORE_TRANSITION or CY_SYSPM_AFTER_TRANSITION parameter are executed, if HP mode is not entered.

Note
  The last callback that returns CY_SYSPM_FAIL is not executed with the CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating CY_SYSPM_FAIL is expected to not make any changes that require being undone.
  It is not possible to transition directly between ULP and HP modes. The device must first be transitioned to LP mode and then to the desired mode.

The return value from executed callback functions with the CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION modes are ignored.

To support control of callback execution order th following method is implemented. Callback function with the CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are registered. Callback function with the CY_SYSPM_CHECK_FAIL and CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they are registered.

Returns
  - CY_SYSPM_SUCCESS - Entered the system HP mode or the device is already in HP mode.
  - CY_SYSPM_INVALID_STATE - System HP mode was not set. The HP mode was not set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers (to enter system HP mode) via syscall.
  - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS.
  - CY_SYSPM_FAIL - The system HP mode is not entered.

Function Usage
  /* Scenario: There is a need to put the device to the system MF mode */
  #if defined (CY_IP_MXS22SRSS)
  if(CY_SYSPM_SUCCESS != Cy_SysPm_SystemEnterHp())
  {
  /* System did not enter HP mode because a registered
  * HP mode "check ready" callback returned a "not success" status
  */
  }
  #endif
  /* Reconfigure/switch on the peripherals
  * with relaxed power consumption restrictions
  */
  /* Call Cy_SysLib_SetWaitStates(true, clkMHz);
  * where clkMHz is the current CPU frequency in MHz
  */
  Cy_SysPm_SystemEnterHp
  cy_en_syspm_status_t Cy_SysPm_SystemEnterHp(void)
  Sets device into System High Performance mode.
  Definition: cy_syspm_v4.c:3288

## ◆ Cy_SysPm_SystemEnterHibernate()

cy_en_syspm_status_t Cy_SysPm_SystemEnterHibernate | ( | void |  | ) |

Sets the device into system Hibernate mode.

Puts the device into the system Hibernate power mode. Prior to entering Hibernate mode, all callbacks of the CY_SYSPM_HIBERNATE type are executed.

First, callbacks of the CY_SYSPM_HIBERNATE type are called with the CY_SYSPM_CHECK_READY parameter. This allows the callback to signal that the driver is not ready to enter the system Hibernate power mode. If any of the callback return CY_SYSPM_FAIL, the remaining CY_SYSPM_HIBERNATE callbacks are skipped. In this case, all of the callbacks that have already been called are called again with the CY_SYSPM_CHECK_FAIL parameter. System Hibernate mode is not entered and the Cy_SysPm_SystemEnterHibernate() function returns CY_SYSPM_FAIL.

If all CY_SYSPM_HIBERNATE callbacks with the CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all CY_SYSPM_HIBERNATE callbacks with CY_SYSPM_CHECK_FAIL calls are skipped and all CY_SYSPM_HIBERNATE callbacks with CY_SYSPM_BEFORE_TRANSITION parameter are executed allowing the peripherals to prepare for system Hibernate.

The I/O output state is automatically frozen by hardware system and Hibernate mode is then entered. In Hibernate mode, all internal supplies are off and no internal state is retained. The only exception is resources powered by the Vbackup domain continue to operate, if enabled. For multi-CPU devices, there is no handshake with the CPUs and the chip will enter Hibernate power mode immediately.

Note
  The last callback that returns CY_SYSPM_FAIL is not executed with the CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating CY_SYSPM_FAIL is expected to not make any changes that require being undone.

The return value from executed callback functions with the CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION modes are ignored.

Wakeup from system Hibernate is triggered by toggling the wakeup pin(s), WDT match, or back-up domain RTC alarm expiration, depending on how the they are configured. A wakeup causes a normal boot procedure. To configure the wakeup pin(s), a digital input pin must be configured, and resistively pulled up or down to the inverse state of the wakeup polarity. To distinguish a Hibernate mode from a general reset wakeup event, the Cy_SysLib_GetResetReason() function can be used. The wakeup pin and low-power comparators are active-low by default. The wakeup pin or the LPComparators polarity can be changed with the Cy_SysPm_SetHibernateWakeupSource() function. This function call will not return if system Hibernate mode is entered. The CY_SYSPM_HIBERNATE callbacks with the CY_SYSPM_AFTER_TRANSITION parameter are never executed.

This function freezes the I/O pins implicitly. Entering system Hibernate mode before freezing the I/O pins is not possible. The I/O pins remain frozen after waking from Hibernate mode until the firmware unfreezes them with a Cy_SysPm_IoUnfreeze() function call.

Boot firmware should reconfigure the I/O pins as required by the application prior unfreezing them.

To support control of callback execution order the following method is implemented. Callback function with the CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are registered. Callback function with the CY_SYSPM_CHECK_FAIL and CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they are registered.

Note
  This API is secure aware but when running on the core without TrustZone, there will be no special security-related behavior. See header subsection Secure Aware SYSPM for further details. If Secure Aware SYSPM is enabled and the corresponding SYSPM PPC region is secured, we don't allow the CM55 to request hibernate entry on its own, since that is a system-wide impact. The involved PPC regions are PROT_PERI0_SRSS_MAIN/PROT_PERI0_SRSS_HIB_DATA. Both PROT_PERI0_SRSS_MAIN/PROT_PERI0_SRSS_HIB_DATA should be either secure or non-secure.

Returns
  Entered status, see cy_en_syspm_status_t. For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Function Usage
  /* Scenario: There is a need to put the device into the system Hibernate mode */
  /* Prepare the device for system Hibernate mode here */
  if(CY_SYSPM_SUCCESS != Cy_SysPm_SystemEnterHibernate())
  {
  /* System did not enter Hibernate mode because a registered
  * Hibernate "check ready" callback returned a "not success" status
  */
  }
  /* You will never get CY_SYSPM_SUCCESS here because in case of successfully
  * entering system hibernate mode because a wakeup from system Hibernate
  * goes through the system reset.
  */
  Cy_SysPm_SystemEnterHibernate
  cy_en_syspm_status_t Cy_SysPm_SystemEnterHibernate(void)
  Sets the device into system Hibernate mode.
  Definition: cy_syspm_v4.c:1508

Note
  In order to get correct value of hibernate wake up cause at next hibernation, upper layer have to clear the interrupt register first and then clear the hibernate wake up cause Cy_SysPm_ClearHibernateWakeupCause() for the current hibernation.

## ◆ Cy_SysPm_SetHibernateWakeupSource()

void Cy_SysPm_SetHibernateWakeupSource | ( | uint32_t | wakeupSource | ) |

This function configures sources to wake up the device from the system Hibernate power mode.

Sources can be wakeup pins, LPComparators, Watchdog (WDT) interrupt, or a Real-Time clock (RTC) alarm (interrupt). Wakeup from system Hibernate always results in a device reset and normal boot process.

Wakeup pins:

A wakeup is supported by up to two pins with programmable polarity. These pins are typically connected to the GPIO pins or on-chip peripherals under some conditions. See device datasheet for specific pin connections. Setting the wakeup pin to this level will cause a wakeup from system Hibernate mode. The wakeup pins are active-low by default.

LPComparators:

A wakeup is supported by up to two LPComps with programmable polarity. Setting the LPComp to this level will cause a wakeup from system Hibernate mode. The wakeup LPComps are active-low by default.

Note
  The low-power comparators should be configured and enabled before switching to system Hibernate mode. Refer to the LPComp driver description for more detail.

Watchdog Timer:

Note
  The WDT should be configured and enabled before entering to system Hibernate mode.

A wakeup is performed by a WDT interrupt.

Real-time Clock:

A wakeup is performed by the RTC alarm. Refer to the Real-Time Clock (RTC) driver description for more detail.

For information about wakeup sources and their assignment in specific devices, refer to the appropriate device TRM.

Parameters

  wakeupSource | The source to be configured as a wakeup source from the system Hibernate power mode, see cy_en_syspm_hibernate_wakeup_source_t. The input parameter values can be ORed. For example, if you want to enable LPComp0 (active high) and WDT, call this function: Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_HIGH | CY_SYSPM_HIBERNATE_WDT).

Warning
  Do not call this function with different polarity levels for the same wakeup source. For example, do not call a function like this: Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_LOW, CY_SYSPM_HIBERNATE_LPCOMP0_HIGH);

Function Usage
  /* Scenario: There is a need to configure all desired system Hibernate wake up sources */
  Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_PIN0_LOW | CY_SYSPM_HIBERNATE_RTC_ALARM | CY_SYSPM_HIBERNATE_PIN1_HIGH);
  /* Scenario: the PIN0 wake up polarity was Low and there is a need to set it to High */
  Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_PIN0_HIGH);
  CY_SYSPM_HIBERNATE_PIN0_HIGH
  @ CY_SYSPM_HIBERNATE_PIN0_HIGH
  Configure a high logic level for the first wakeup-pin.
  Definition: cy_syspm.h:1403
  CY_SYSPM_HIBERNATE_PIN1_HIGH
  @ CY_SYSPM_HIBERNATE_PIN1_HIGH
  Configure a high logic level for the second wakeup-pin.
  Definition: cy_syspm.h:1409
  CY_SYSPM_HIBERNATE_PIN0_LOW
  @ CY_SYSPM_HIBERNATE_PIN0_LOW
  Configure a low logic level for the first wakeup-pin.
  Definition: cy_syspm.h:1400
  CY_SYSPM_HIBERNATE_RTC_ALARM
  @ CY_SYSPM_HIBERNATE_RTC_ALARM
  Configure the RTC alarm as wakeup source.
  Definition: cy_syspm.h:1394
  Cy_SysPm_SetHibernateWakeupSource
  void Cy_SysPm_SetHibernateWakeupSource(uint32_t wakeupSource)
  This function configures sources to wake up the device from the system Hibernate power mode.
  Definition: cy_syspm_v4.c:1732

## ◆ Cy_SysPm_ClearHibernateWakeupSource()

void Cy_SysPm_ClearHibernateWakeupSource | ( | uint32_t | wakeupSource | ) |

This function disables a wakeup source that was previously configured to wake up the device from the system Hibernate mode.

Parameters

  wakeupSource | For the source to be disabled, see cy_en_syspm_hibernate_wakeup_source_t. The input parameters values can be ORed. For example, if you want to disable LPComp0 (active high) and WDT call this function: Cy_SysPm_ClearHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_HIGH | CY_SYSPM_HIBERNATE_WDT).

Function Usage
  /* Scenario: There is a need to disable the RTC alarm wake up source */
  Cy_SysPm_ClearHibernateWakeupSource(CY_SYSPM_HIBERNATE_RTC_ALARM);
  Cy_SysPm_ClearHibernateWakeupSource
  void Cy_SysPm_ClearHibernateWakeupSource(uint32_t wakeupSource)
  This function disables a wakeup source that was previously configured to wake up the device from the ...
  Definition: cy_syspm_v4.c:1803

## ◆ Cy_SysPm_GetHibernateWakeupCause()

cy_en_syspm_hibernate_wakeup_source_t Cy_SysPm_GetHibernateWakeupCause | ( | void |  | ) |

This function gets the wakeup cause for Hibernate mode.

Returns
  Wakeup Reason cy_en_syspm_hibernate_wakeup_source_t

## ◆ Cy_SysPm_SystemSetMinRegulatorCurrent()

cy_en_syspm_status_t Cy_SysPm_SystemSetMinRegulatorCurrent | ( | void |  | ) |

Sets the system into minimum core regulator current mode.

This mode limits maximum current available for the system core logic.

Minimum regulator current mode modifies operation of the system in LP or ULP modes to further reduce current consumption. If the system current is below datasheet current limits for the active core voltage regulator (LDO or Buck), this mode may be entered. The user is responsible for ensuring the regulator current limit is met in their application.

When in minimum regulator current mode, the following system resources are also set to their LP mode:

- Linear regulator (If LDO is active regulator)
- POR/BOD circuit
- Bandgap reference circuit
- Reference buffer circuit
- Current reference circuit

The LDO and Buck current limits must be met prior to entering this mode. If these are not met, the device may brown out, resulting in an exception or reset. These changes also reduce power supply rejection of the affected system resources, which can result in increased noise or response time. These effects must be evaluated in each application.

Returns
  See cy_en_syspm_status_t.
  - CY_SYSPM_SUCCESS - Minimum regulator current mode was set
  - CY_SYSPM_CANCELED - The power circuits were not ready to enter into minimum current mode. You should call the function again. For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Refer to device datasheet for maximum current value in regulator minimum current mode.

Function Usage
  /* Scenario: There is a need to limit device current consumption. This can
  * be done by setting the regulator minimum current mode
  */
  /* Before setting the regulator minimum current mode ensure that device
  * current consumption is less than the regulator maximum value. If not BOD
  * can occur. Refer to device datasheet for the maximum current value of
  * regulator minimum current mode
  */
  /* Check regulator current mode */
  if (!Cy_SysPm_SystemIsMinRegulatorCurrentSet())
  {
  /* Set regulator minimum current mode */
  Cy_SysPm_SystemSetMinRegulatorCurrent();
  }
  Cy_SysPm_SystemSetMinRegulatorCurrent
  cy_en_syspm_status_t Cy_SysPm_SystemSetMinRegulatorCurrent(void)
  Sets the system into minimum core regulator current mode.
  Definition: cy_syspm_v4.c:1637
  Cy_SysPm_SystemIsMinRegulatorCurrentSet
  __STATIC_INLINE bool Cy_SysPm_SystemIsMinRegulatorCurrentSet(void)
  Check whether the system regulator is set to minimal current mode.
  Definition: cy_syspm.h:3790

## ◆ Cy_SysPm_SystemSetNormalRegulatorCurrent()

cy_en_syspm_status_t Cy_SysPm_SystemSetNormalRegulatorCurrent | ( | void |  | ) |

Sets the system to normal regulator current mode.

Normal regulator current mode modifies operation of the system in LP or ULP modes to provide maximum core current consumption. If the LDO core regulator is in use, the normal mode output current limits may be used. If the buck regulator is in use, its reduced current output limits still apply.

When in normal regulator current mode, the following system resources are set to their normal mode:

- Linear regulator (If LDO is active regulator)
- POR/BOD circuit
- Bandgap reference circuit
- Reference buffer circuit
- Current reference circuit

Returns
  - CY_SYSPM_SUCCESS - Normal regulator current mode was set
  - CY_SYSPM_TIMEOUT - The timeout occurred because device was not ready to enter into the normal regulator current mode For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Function Usage
  /* Scenario: There is a need to increase available core regulator current
  * by setting the to regulator normal current mode
  */
  /* Check regulator current mode */
  if (Cy_SysPm_SystemIsMinRegulatorCurrentSet())
  {
  /* Set regulator to normal current mode */
  Cy_SysPm_SystemSetNormalRegulatorCurrent();
  }
  /* Once the regulator is set to normal current mode, current consumption
  * can be increased to maximum specification
  */
  Cy_SysPm_SystemSetNormalRegulatorCurrent
  cy_en_syspm_status_t Cy_SysPm_SystemSetNormalRegulatorCurrent(void)
  Sets the system to normal regulator current mode.
  Definition: cy_syspm_v4.c:1665

## ◆ Cy_SysPm_CpuSleepOnExit()

__STATIC_INLINE void Cy_SysPm_CpuSleepOnExit | ( | bool | enable | ) |

This function configures the sleep-on-exit feature of the CPU.

This API sets the SLEEPONEXIT bit of the SCR register.

When the sleep-on-exit feature is enabled (the SLEEPONEXIT bit is set), the CPU wakes up to service the interrupt and then immediately goes back to sleep. Because of this, the unstacking process is not carried out, so this feature is useful for interrupt driven application and helps to reduce unnecessary stack push and pop operations. The CPU does not go to sleep if the interrupt handler returns to another interrupt handler (nested interrupt). You can use this feature in applications that require the CPU to only run when an interrupt occurs.

When the sleep-on-exit feature is disabled (the SLEEPONEXIT bit is cleared), the CPU returns back to the main thread after servicing the interrupt without going back to sleep.

Refer to the Arm documentation about the sleep-on-exit feature and SLEEPONEXIT in the SCR register.

Parameters

  enable | True if enable sleep-on-exit feature. False if disable sleep-on-exit feature.

Function Usage
  /* Scenario: There is a need to enable sleep-on-exit feature */
  Cy_SysPm_CpuSleepOnExit(true);
  /* Prepare the device for CPU Sleep */
  if(CY_SYSPM_SUCCESS == Cy_SysPm_CpuEnterSleep(CY_SYSPM_WAIT_FOR_INTERRUPT))
  {
  /* Now the CPU is in Sleep.
  * The CPU wakes up to service the interrupt and then immediately goes
  * back to CPU Sleep.
  */
  }
  /* Scenario: There is a need to disable sleep-on-exit after it was enabled
  * Call Cy_SysPm_CpuSleepOnExit(false) in the interrupt handler
  */
  Cy_SysPm_CpuSleepOnExit
  __STATIC_INLINE void Cy_SysPm_CpuSleepOnExit(bool enable)
  This function configures the sleep-on-exit feature of the CPU.
  Definition: cy_syspm.h:3736

## ◆ Cy_SysPm_CpuSendWakeupEvent()

__STATIC_INLINE void Cy_SysPm_CpuSendWakeupEvent | ( | void |  | ) |

Sends the SEV (Send Event) ARM instruction to the system.

Note
  In secure settings, this API is safe to call from both a secure and non-secure CPU state. See header subsection Secure Aware SYSPM for further details.

Function Usage
  /* Scenario: There is a need wakeup the CM4 CPU in the system using the
  * CM0+ CPU without using interrupts if the CM4 CPU is in CPU Sleep mode.
  */
  /* Check the CM4 CPU status */
  if (Cy_SysPm_Cm4IsSleep())
  {
  /* Wake up the CM4 CPU */
  Cy_SysPm_CpuSendWakeupEvent();
  }
  Cy_SysPm_CpuSendWakeupEvent
  __STATIC_INLINE void Cy_SysPm_CpuSendWakeupEvent(void)
  Sends the SEV (Send Event) ARM instruction to the system.
  Definition: cy_syspm.h:3770

## ◆ Cy_SysPm_SystemIsMinRegulatorCurrentSet()

__STATIC_INLINE bool Cy_SysPm_SystemIsMinRegulatorCurrentSet | ( | void |  | ) |

Check whether the system regulator is set to minimal current mode.

Returns
  - True - system is in regulator minimum current mode.
  - False - system is in normal regulator current mode.

Function Usage
  /* Scenario: There is a need to increase available core regulator current
  * by setting the to regulator normal current mode
  */
  /* Check regulator current mode */
  if (Cy_SysPm_SystemIsMinRegulatorCurrentSet())
  {
  /* Set regulator to normal current mode */
  Cy_SysPm_SystemSetNormalRegulatorCurrent();
  }
  /* Once the regulator is set to normal current mode, current consumption
  * can be increased to maximum specification
  */