PSoC 6 Peripheral Driver Library

General Description

Functions

cy_en_syspm_status_t Cy_SysPm_CpuEnterSleep (cy_en_syspm_waitfor_t waitFor)
 Sets executing CPU to Sleep mode. More...
 
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_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_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 bool Cy_SysPm_SystemIsMinRegulatorCurrentSet (void)
 Check whether the system regulator is set to minimal current mode. More...
 
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...
 

Function Documentation

◆ 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 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.

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.
Parameters
waitForSelects 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 */
{
/* 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_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.

Parameters
waitForSelects 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. 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.
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 */
{
/* 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_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.

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.

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 */
{
/* 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_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.

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.

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
*/
{
/* 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_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 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
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 */
{
/* 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_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
wakeupSourceThe 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 */
/* Scenario: the LPComp0 wake up polarity was Low and there is a need to set it to High */

◆ 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
wakeupSourceFor 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 LPComp0 wake up source */

◆ 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 */
{
/* Set regulator minimum current mode */
}

◆ 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 */
{
/* Set regulator to normal current mode */
}
/* Once the regulator is set to normal current mode, current consumption
* can be increased to maximum specification
*/

◆ 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 */
{
/* Set regulator to normal current mode */
}
/* Once the regulator is set to normal current mode, current consumption
* can be increased to maximum specification
*/

◆ Cy_SysPm_CpuSleepOnExit()

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 */
/* Prepare the device for CPU Sleep */
{
/* 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_CpuSendWakeupEvent()

__STATIC_INLINE void Cy_SysPm_CpuSendWakeupEvent ( void  )

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

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 */
{
/* Wake up the CM4 CPU */
}