cy_syspm_8h

Provides the function definitions for the power management API.

Version

5.50

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Copyright

Copyright 2016-2020 Cypress Semiconductor Corporation SPDX-License-Identifier: Apache-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defines

CY_SYSPM_DRV_VERSION_MAJOR

Driver major version.

CY_SYSPM_DRV_VERSION_MINOR

Driver minor version.

CY_SYSPM_ID

SysPm driver identifier.

CY_SYSPM_STATUS_CM4_ACTIVE

The CM4 is in CPU Active mode.

CY_SYSPM_STATUS_CM4_SLEEP

The CM4 is in CPU Sleep mode.

CY_SYSPM_STATUS_CM4_DEEPSLEEP

The CM4 is in CPU Deep Sleep mode.

CY_SYSPM_STATUS_CM0_ACTIVE

The CM0p is CPU Active mode.

CY_SYSPM_STATUS_CM0_SLEEP

The CM0p is in CPU Sleep mode.

CY_SYSPM_STATUS_CM0_DEEPSLEEP

The CM0p is in CPU Deep Sleep mode.

CY_SYSPM_STATUS_SYSTEM_LP

The system is Low Power mode.

CY_SYSPM_STATUS_SYSTEM_ULP

The system is in Ultra Low Power mode.

CY_SYSPM_SKIP_CHECK_READY

Define to skip check ready mode in the syspm callback.

CY_SYSPM_SKIP_CHECK_FAIL

Define to skip check fail mode in the syspm callback.

CY_SYSPM_SKIP_BEFORE_TRANSITION

Define to skip before transition mode in the syspm callback.

CY_SYSPM_SKIP_AFTER_TRANSITION

Define to skip after transition mode in the syspm callback.

Typedefs

typedef cy_en_syspm_status_t (*Cy_SysPmCallback)(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)

The type for syspm callbacks.

Enums

enum cy_en_syspm_status_t

cy_en_syspm_status_t: The SysPm function return value status definitions.

Values:

enumerator CY_SYSPM_SUCCESS

Successful.

enumerator CY_SYSPM_BAD_PARAM

One or more invalid parameters.

enumerator CY_SYSPM_TIMEOUT

A time-out occurred.

enumerator CY_SYSPM_INVALID_STATE

The operation is not setup or is in an improper state.

enumerator CY_SYSPM_CANCELED

Operation canceled.

enumerator CY_SYSPM_SYSCALL_PENDING

Canceled due syscall operation pending.

enumerator CY_SYSPM_FAIL

Unknown failure.

enum cy_en_syspm_waitfor_t

cy_en_syspm_waitfor_t: This enumeration is used to initialize the functions wait action.

The wait actions can be - an interrupt or an event. Refer to the CMSIS for WFE and WFI instruction explanations.

Values:

enumerator CY_SYSPM_WAIT_FOR_INTERRUPT

Wait for an interrupt.

enumerator CY_SYSPM_WAIT_FOR_EVENT

Wait for an event.

enum cy_en_syspm_hibernate_wakeup_source_t

cy_en_syspm_hibernate_wakeup_source_t: This enumeration is used to configure wakeup sources for the System Hibernate power mode.

Values:

enumerator CY_SYSPM_HIBERNATE_LPCOMP0_LOW

Wake on a low logic level for the LPComp0.

enumerator CY_SYSPM_HIBERNATE_LPCOMP0_HIGH

Wake on a high logic level for the LPComp0.

enumerator CY_SYSPM_HIBERNATE_LPCOMP1_LOW

Wake on a low logic level for the LPComp1.

enumerator CY_SYSPM_HIBERNATE_LPCOMP1_HIGH

Wake on a high logic level for the LPComp1.

enumerator CY_SYSPM_HIBERNATE_RTC_ALARM

Configure the RTC alarm as wakeup source.

enumerator CY_SYSPM_HIBERNATE_WDT

Configure the WDT interrupt as wakeup source.

enumerator CY_SYSPM_HIBERNATE_PIN0_LOW

Configure a low logic level for the first wakeup-pin.

See device datasheet for specific pin.

enumerator CY_SYSPM_HIBERNATE_PIN0_HIGH

Configure a high logic level for the first wakeup-pin.

See device datasheet for specific pin.

enumerator CY_SYSPM_HIBERNATE_PIN1_LOW

Configure a low logic level for the second wakeup-pin.

See device datasheet for specific pin.

enumerator CY_SYSPM_HIBERNATE_PIN1_HIGH

Configure a high logic level for the second wakeup-pin.

See device datasheet for specific pin.

enum cy_en_syspm_ldo_voltage_t

cy_en_syspm_ldo_voltage_t: This enumeration is used to select LDO regulator output voltage.

Values:

enumerator CY_SYSPM_LDO_VOLTAGE_ULP

System ULP nominal LDO voltage.

See device datasheet for specific voltage.

enumerator CY_SYSPM_LDO_VOLTAGE_LP

System LP nominal LDO voltage.

See device datasheet for specific voltage.

enumerator CY_SYSPM_LDO_VOLTAGE_0_9V

0.9 V nominal LDO voltage

enumerator CY_SYSPM_LDO_VOLTAGE_1_1V

1.1 V nominal LDO voltage

enum cy_en_syspm_ldo_mode_t

cy_en_syspm_ldo_mode_t: This enumeration is used to select the LDO regulator operating mode.

Values:

enumerator CY_SYSPM_LDO_MODE_DISABLED

Disables the LDO.

enumerator CY_SYSPM_LDO_MODE_NORMAL

Sets normal current mode.

See device datasheet for specific maximum current limit.

enumerator CY_SYSPM_LDO_MODE_MIN

Sets minimum current mode.

See device datasheet for specific current limit.

enum cy_en_syspm_buck_voltage1_t

cy_en_syspm_buck_voltage1_t: This enumeration is used to select the output voltage for the Buck regulator output 1.

Values:

enumerator CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP

System ULP nominal Buck voltage.

See device datasheet for specific voltage.

enumerator CY_SYSPM_BUCK_OUT1_VOLTAGE_LP

LP nominal Buck voltage.

See device datasheet for specific voltage.

enumerator CY_SYSPM_BUCK_OUT1_VOLTAGE_0_9V

0.9 V nominal Buck voltage

enumerator CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V

1.1 V nominal Buck voltage

enum cy_en_syspm_buck_out_t

cy_en_syspm_buck_out_t: This enumeration is used to select the Buck regulator outputs.

Values:

enumerator CY_SYSPM_BUCK_VBUCK_1

Buck output 1 Voltage (Vbuck1).

Typically used to supply the PSoC digital core logic.

enumerator CY_SYSPM_BUCK_VRF

Buck out 2 Voltage (Vbuckrf).

Typically used to supply the BLE radio logic.

enum cy_en_syspm_buck_voltage2_t

cy_en_syspm_buck_voltage2_t: This enumeration is used to select the output voltage for the Buck regulator output 2, which can source the BLE radio.

Values:

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_15V

1.15 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_2V

1.20 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_25V

1.25 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_3V

1.3 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_35V

1.35 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_4V

1.4 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_45V

1.45 V nominal voltage.

enumerator CY_SYSPM_BUCK_OUT2_VOLTAGE_1_5V

1.5 V nominal voltage.

enum cy_en_syspm_pmic_wakeup_polarity_t

cy_en_syspm_pmic_wakeup_polarity_t: This enumeration is used to set the polarity for the PMIC input.

The PMIC output is automatically enabled when the configured polarity of the PMIC input and the logic level driven to the pmic_wakeup_in pin match.

warning

Do not use CY_SYSPM_PMIC_POLARITY_LOW as it is not supported by hardware.

Values:

enumerator CY_SYSPM_PMIC_POLARITY_LOW

Set active low logic level for the PMIC input.

enumerator CY_SYSPM_PMIC_POLARITY_HIGH

Set active high logic level for the PMIC input.

enum cy_en_syspm_vddbackup_control_t

cy_en_syspm_vddbackup_control_t: This enumeration selects Vbackup or Vddd to supply Vddbackup.

Values:

enumerator CY_SYSPM_VDDBACKUP_DEFAULT

Logic automatically selects Vddd if present or Vbackup if Vddd is not present to supply Vddbackup.

enumerator CY_SYSPM_VDDBACKUP_VBACKUP

Sets only Vbackup to supply Vddbackup.

enum cy_en_syspm_sc_charge_key_t

cy_en_syspm_sc_charge_key_t: This enumeration enables supercapacitor charging.

Values:

enumerator CY_SYSPM_SC_CHARGE_ENABLE

Enables supercapacitor charging.

enumerator CY_SYSPM_SC_CHARGE_DISABLE

Disables supercapacitor charging.

enum cy_en_syspm_flash_voltage_bit_t

cy_en_syspm_flash_voltage_bit_t: This enumeration configures the flash voltage bit for different system power modes.

Values:

enumerator CY_SYSPM_FLASH_VOLTAGE_BIT_LP

Set the flash voltage bit for system LP mode.

enumerator CY_SYSPM_FLASH_VOLTAGE_BIT_ULP

Set the flash voltage bit for system ULP mode.

enum cy_en_syspm_callback_type_t

cy_en_syspm_callback_type_t: This enumeration is used to select the low power mode for which the appropriate registered callback handler will be executed.

For example, the registered callback of the type CY_SYSPM_SLEEP will be executed while switching into the Sleep power mode.

Values:

enumerator CY_SYSPM_SLEEP

The Sleep enum callback type.

enumerator CY_SYSPM_DEEPSLEEP

The Deep Sleep enum callback type.

enumerator CY_SYSPM_HIBERNATE

The Hibernate enum callback type.

enumerator CY_SYSPM_LP

The Low Power enum callback type.

enumerator CY_SYSPM_ULP

The Ultra Low Power enum callback type.

enum cy_en_syspm_callback_mode_t

cy_en_syspm_callback_mode_t: This enumeration specifies the associated callback mode.

This enum defines the callback mode.

Values:

enumerator CY_SYSPM_CHECK_READY

Callbacks with this mode are executed before entering into the low power mode.

The purpose of his callback function is to check if the device is ready to enter the low power mode.

enumerator CY_SYSPM_CHECK_FAIL

Callbacks with this mode are executed after the CY_SYSPM_CHECK_READY callbacks execution returns CY_SYSPM_FAIL.

The callback with the CY_SYSPM_CHECK_FAIL mode should roll back the actions performed in the previously executed callback with CY_SYSPM_CHECK_READY

enumerator CY_SYSPM_BEFORE_TRANSITION

Callbacks with this mode are executed after the CY_SYSPM_CHECK_READY callbacks execution returns CY_SYSPM_SUCCESS.

Performs the actions to be done before entering into the low power mode.

enumerator CY_SYSPM_AFTER_TRANSITION

Performs the actions to be done after exiting the low power mode if entered.

enum cy_en_syspm_sram_index_t

cy_en_syspm_sram_index_t: This enumeration is used to select a particular SRAM.

note

This macro is available for CAT1A devices.

Values:

enumerator CY_SYSPM_SRAM0_MEMORY

SRAM0 Memory Area.

enumerator CY_SYSPM_SRAM1_MEMORY

SRAM1 Memory Area.

enumerator CY_SYSPM_SRAM2_MEMORY

SRAM2 Memory Area.

enum cy_en_syspm_sram_pwr_mode_t

cy_en_syspm_sram_pwr_mode_t: This enumeration is used to select a particular SRAM Power Mode.

Values:

enumerator CY_SYSPM_SRAM_PWR_MODE_OFF

SRAM Power Mode OFF.

enumerator CY_SYSPM_SRAM_PWR_MODE_INVALID

Invalid SRAM Power Mode.

enumerator CY_SYSPM_SRAM_PWR_MODE_RET

SRAM Power Mode RET.

enumerator CY_SYSPM_SRAM_PWR_MODE_ON

SRAM Power Mode ON.

Functions

cy_en_syspm_status_t Cy_SysPm_SetSRAMMacroPwrMode(cy_en_syspm_sram_index_t sramNum, uint32_t sramMacroNum, cy_en_syspm_sram_pwr_mode_t sramPwrMode)

Function to set Power Mode for each of the Macro in a particular SRAM.

note

If SRAM1 and SRAM2 consists of single power partition, power mode will be applied to whole SRAM region, so 0 must be passed for sramMacroNum parameter.

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

  • CY_SYSPM_SUCCESS - SRAM MACRO power mode is set.

  • CY_SYSPM_BAD_PARAM - Input parameters are out of range. See cy_en_syspm_status_t.

Parameters
  • sramNum: SRAM’s index number has to be passed ex: CY_SYSPM_SRAM0_MEMORY or CY_SYSPM_SRAM1_MEMORY or CY_SYSPM_SRAM2_MEMORY See cy_en_syspm_sram_index_t.

  • sramMacroNum: Macro number of a particular SRAM.

Parameters
  • sramPwrMode: Power Mode that needs to be set.

note

This API is available for CAT1A devices.

cy_en_syspm_sram_pwr_mode_t Cy_SysPm_GetSRAMMacroPwrMode(cy_en_syspm_sram_index_t sramNum, uint32_t sramMacroNum)

Function to get Power Mode for each of the Macro in a particular SRAM.

note

If SRAM1 and SRAM2 consists of single power partition, power mode will be applied to whole SRAM region, so 0 must be passed for sramMacroNum parameter, and the power mode obtained will be for whole SRAM.

note

This API is available for CAT1A devices.

Return

Returns SRAM power mode. See cy_en_syspm_sram_pwr_mode_t.

Parameters
  • sramNum: SRAM’s index number has to be passed ex: CY_SYSPM_SRAM0_MEMORY or CY_SYSPM_SRAM1_MEMORY or CY_SYSPM_SRAM2_MEMORY See cy_en_syspm_sram_index_t.

  • sramMacroNum: Macro number of a particular SRAM.

cy_en_syspm_status_t Cy_SysPm_SetSRAMPwrMode(cy_en_syspm_sram_index_t sramNum, cy_en_syspm_sram_pwr_mode_t sramPwrMode)

Function to set Power Mode for all the Macros for a particular SRAM.

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

  • CY_SYSPM_SUCCESS - SRAM power mode is set.

  • CY_SYSPM_BAD_PARAM - Input parameters are out of range. See cy_en_syspm_status_t.

Parameters
  • sramNum: SRAM’s index number has to be passed ex: CY_SYSPM_SRAM0_MEMORY or CY_SYSPM_SRAM1_MEMORY or CY_SYSPM_SRAM2_MEMORY See cy_en_syspm_sram_index_t.

  • sramPwrMode: Power Mode that needs to be set.

note

This API is available for CAT1A devices.

cy_en_syspm_status_t Cy_SysPm_WriteVoltageBitForFlash(cy_en_syspm_flash_voltage_bit_t value)

Function that changes the voltage setting for flash.

note

Call this function before system enters ULP mode. Call this function after the system enters LP mode.

Return

  • CY_SYSPM_SUCCESS - The voltage is set.

  • CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS. See cy_en_syspm_status_t.

Function Usage

    
    /* The system may continue operating while the voltage on Vccd 
    * discharges to the new voltage. The time it takes to reach the 
    * new voltage depends on operating conditions, including the load current
    * on Vccd and external capacitor size.
    */
    SRSS_PWR_BUCK_CTL = 
    _CLR_SET_FLD32U((SRSS_PWR_BUCK_CTL), SRSS_PWR_BUCK_CTL_BUCK_OUT1_SEL, (uint32_t) CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP);

Parameters

void Cy_SysPm_SaveRegisters(cy_stc_syspm_backup_regs_t *regs)

note

Behavior of this API is IP dependent.
On CAT1A devices:
Saves non-retained UDB registers and the slow and fast clock dividers before system entering system Deep Sleep. Must be called if programmable logic or function are implemented in the UDB array. Cypress ID #280370, #1451. On CAT1B devices:
Saves non-retained UDB registers before system entering system Deep Sleep. Must be called if programmable logic or function are implemented in the UDB array. Cypress ID #280370.

warning

Only one CPU on dual CPU devices should call this function. If both CPUs call this function the UDB state restored may be inconsistent with the expected state when restored.

Function Usage

    /* Scenario: There is a need to save the non-retained UDB registers while 
    *  in system Deep Sleep routine.
    */
    static cy_stc_syspm_backup_regs_t regs;
    
    /* Save non-retained UDB registers */
    Cy_SysPm_SaveRegisters(&regs);
    
    SCB_SCR |= SCB_SCR_SLEEPDEEP_Msk;

    __WFI();

    /* Restore non-retained UDB registers after system Deep Sleep */
    Cy_SysPm_RestoreRegisters(&regs);

Parameters
  • regs: The structure where the registers are saved.

void Cy_SysPm_RestoreRegisters(cy_stc_syspm_backup_regs_t const *regs)

note

Behavior of this API is IP dependent.
On CAT1A devices: \ Restores non-retained UDB registers and the slow and fast clock dividers before system entering system Deep Sleep. Must be called if programmable logic or function are implemented in the UDB array. Cypress ID #280370, #1451. On CAT1B devices: \ Restores non-retained UDB registers before system entering system Deep Sleep. Must be called if programmable logic or function are implemented in the UDB array. Cypress ID #280370.

warning

Only one CPU on dual CPU devices should call this function. If both CPUs call this function the UDB state restored may be inconsistent with the expected state when restored.

note

CAT1B devices, registers are non-retained type.

Function Usage

    /* Scenario: There is a need to save the non-retained UDB registers while 
    *  in system Deep Sleep routine.
    */
    static cy_stc_syspm_backup_regs_t regs;
    
    /* Save non-retained UDB registers */
    Cy_SysPm_SaveRegisters(&regs);
    
    SCB_SCR |= SCB_SCR_SLEEPDEEP_Msk;

    __WFI();

    /* Restore non-retained UDB registers after system Deep Sleep */
    Cy_SysPm_RestoreRegisters(&regs);

Parameters

uint32_t Cy_SysPm_ReadStatus(void)

Reads the power modes status of the system and CPU(s).

Return

The current power mode. See The Power Mode Status Defines.

Function Usage

    /* Scenario: There is a need to check the system current power mode and CPU 
    *  power mode
    */
    if(CY_SYSPM_STATUS_SYSTEM_ULP == (CY_SYSPM_STATUS_SYSTEM_ULP & Cy_SysPm_ReadStatus()))
    {
        /* The system is currently in ULP mode */
    }

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.

Return

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
         */
    }

Parameters

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

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.

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 the WFI/WFE instruction.

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.

Return

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 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
         */
    }

Parameters

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.

Return

  • 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_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.

Return

  • 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_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.

Return

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

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.

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_LPCOMP0_LOW | CY_SYSPM_HIBERNATE_RTC_ALARM | CY_SYSPM_HIBERNATE_PIN1_HIGH);
    
    /* Scenario: the LPComp0 wake up polarity was Low and there is a need to set it to High */
    Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_HIGH);

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

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.

Function Usage

    /* Scenario: There is a need to disable the LPComp0 wake up source */
    Cy_SysPm_ClearHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_HIGH);

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

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.

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

Return

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.

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_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

Return

  • 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
    */
    

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.

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 
    */
        

Parameters
  • enable:

    • True if enable sleep-on-exit feature.

    • False if disable sleep-on-exit feature.

void Cy_SysPm_IoUnfreeze(void)

This function unfreezes the I/O cells that are automatically frozen when Hibernate is entered with the call to Cy_SysPm_SystemEnterHibernate().

I/O cells remain frozen after a wakeup from Hibernate mode until the firmware unfreezes them by calling this function.

If the firmware must retain the data value on the pin, then the value must be read and re-written to the pin’s port data register before calling this function. Furthermore, the drive mode must be re-programmed before the pins are unfrozen. If this is not done, the pin will change to the default state the moment the freeze is removed.

Note that I/O cell configuration can be changed while frozen. The new configuration becomes effective only after the pins are unfrozen.

Function Usage

    
    /* Scenario: There is a need to use Hibernate power mode and retain the 
    *  the I/O state after the a wake-up from Hibernate
    */

    /* Check the I/O freeze status after the boot.
    *  If the I/O is frozen it means we have returned from Hibernate.
    */
    if(Cy_SysPm_IoIsFrozen())
    {
        /* Restore the I/O configuration before unfreezing.
        *  Use configuration data programmed into firmware stored in S
        *  RSS->PWR_HIB_DATA[] or BACKUP->BREG[] 
        *  before the Hibernate was entered. Th emost common use case is to
        *  restore from GPIO driver the firmware initialization structures.
        */
        Cy_SysPm_IoUnfreeze();
    }

    /* Save the I/O before entering Hibernate. You can store the
    *  the I/O configuration into SRSS->PWR_HIB_DATA[] or 
    *  BACKUP->BREG[] registers.
    */
    
    /* Enter Hibernate mode */
    Cy_SysPm_SystemEnterHibernate();
    

cy_en_syspm_status_t Cy_SysPm_LdoSetVoltage(cy_en_syspm_ldo_voltage_t voltage)

Set output voltage on the core LDO regulator.

When changing from a higher voltage to a lower voltage as when the device enters system ULP mode, ensure that:

  • The device maximum operating frequency for all the Clk_HF paths, peripheral, and slow clock are under the ULP Limitations.

  • The total current consumption is under the ULP Limitations.

  • The appropriate wait states values are set for the flash using The Cy_SysLib_SetWaitStates() function as explained below.

Setting wait states values for flash

The flash access time when the core voltage is 0.9 V (nominal) is longer than at 1.1 V (nominal). Therefore, the number of the wait states must be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate wait state values for flash.

To change from a higher voltage to a lower voltage 0.9 V (nominal), call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.

To change from a lower voltage to a higher voltage 1.1 V (nominal), calling the Cy_SysLib_SetWaitStates(false, hfClkFreqMz) function to set the wait states is optional, but can be done to improve performance. The clock frequency may now be increased up to LP Limitations.

note

1. The output is set to 0.9 V (nominal) - the system is in ULP mode and flash works for read-only operation.

note

2. The output is set to 1.1 V (nominal) - the system is in LP mode and flash works for read and write operations.

note

3. The actual device Vccd voltage can be different from the nominal voltage because the actual voltage value depends on conditions including the load current.

For more detail, refer to the

Switching the System into Ultra Low Power and Switching the System into Low Power sections. Refer to the SysLib (System Library) driver for more detail about setting the wait states.

Return

  • CY_SYSPM_SUCCESS - The voltage is set.

  • CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers via syscall.

  • CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS. 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 increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

Parameters

cy_en_syspm_status_t Cy_SysPm_LdoSetMode(cy_en_syspm_ldo_mode_t mode)

Configures the core LDO regulator operating mode to one of three modes.

Disabled - turns off the LDO regulator and should be selected only after the Buck regulator is operating. Normal mode configures the LDO for operation at the maximum output current limit. Minimal current mode optimizes the LDO at a reduced output current limit. Specific device current limits can be found in the device datasheet.

Return

  • CY_SYSPM_SUCCESS - Requested regulator current mode was set

  • CY_SYSPM_CANCELED - The power circuits were not ready to enter into minimum current mode. You should try to call the function again

  • CY_SYSPM_TIMEOUT - Timeout occurred because of active reference was not ready to enter into the normal regulator current mode

  • CY_SYSPM_FAIL - incorrect mode value was passed 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.

Side Effects

For PSoC 64 series devices CY_SYSPM_LDO_MODE_DISABLED mode is not supported. Use Cy_SysPm_BuckEnable() instead.

Parameters

cy_en_syspm_ldo_mode_t Cy_SysPm_LdoGetMode(void)

Returns the current core LDO regulator operating mode.

Return

The LDO regulator operating mode. See cy_en_syspm_ldo_mode_t mode

cy_en_syspm_status_t Cy_SysPm_BuckEnable(cy_en_syspm_buck_voltage1_t voltage)

Switch the core supply regulator to Buck core regulator instead of the LDO regulator.

The Buck core regulator provides output voltage(s) using one external inductor and can supply Vccd with higher efficiency than the LDO under some conditions, such as high external supply voltage.

Before changing from LDO to Buck, ensure that the circuit board has connected Vccbuck1 to Vccd and also populated the necessary external components for the Buck regulator, including an inductor and a capacitor for each output. Refer to the device TRM for more detail.

When changing from a higher voltage to a lower voltage (from system LP = LDO 1.1 V (nominal) to system ULP = Buck 0.9 V (nominal)), ensure that:

  • The device maximum operating frequency for all the Clk_HF paths, peripheral, and slow clock are under the ULP Limitations.

  • The total current consumption is under the ULP Limitations.

  • The appropriate wait states values are set for the flash using the Cy_SysLib_SetWaitStates() function as explained below.

Setting wait states values for flash

The flash access time when the core output voltage is 0.9 V (nominal) is longer than at 1.1 V (nominal). Therefore, the number of the wait states must be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate wait state values for flash.

To change from a higher voltage (LDO 1.1 V) to a lower voltage (Buck 0.9 V), call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.

To change from a lower voltage (LDO 0.9 V (nominal) to a higher voltage (Buck 1.1 V (nominal)), call the Cy_SysLib_SetWaitStates(false, hfClkFreqMz) function to set the wait states after the voltage change. It is optional, but can be done to improve performance. The clock frequency may now be increased up to system LP mode limits for the new voltage.

note

1. If the final Buck output is set to 0.9 V (nominal) - the system is in ULP mode and flash allows read-only operations.

note

2. If the final Buck output is set to 1.1 V (nominal) - the system is in LP mode flash allows the read and write operations.

note

3. The actual device Vccd voltage can be different from the nominal voltage because the actual voltage value depends on conditions including the load current.

warning

There is no safe way to go back to the LDO after the Buck regulator supplies a core. The function enabling the Buck regulator switches off the LDO.

warning

Buck converter requires additional external components populated on dedicated pins. Refer to device datasheet for details.

For more detail, refer to the

Switching the System into Ultra Low Power and Switching the System into Low Power sections. Refer to the SysLib (System Library) driver for more detail about setting wait states.

note

The function is applicable only for devices with a Buck regulator.

Function uses a critical section to prevent interrupting the regulators switch.

Return

  • CY_SYSPM_SUCCESS - The voltage is set as requested. (There is no change if the new voltage is the same as the previous voltage.)

  • CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers via syscall.

  • CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS. 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.

Parameters

Function Usage

    /* Scenario: There is a need to switch the power supply regulator to Buck regulator */
    cy_en_syspm_status_t retVal;

    uint32_t triesToSetVoltage = 10u;
    
    /* Need to parse the error value. The function can return two types of error.
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 
    do
    {
        /* Call the function until the operation is finished */
        retVal = Cy_SysPm_BuckEnable(CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP);
        --triesToSetVoltage;
    } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
    
    if (triesToSetVoltage == 0)
    {
        /* The operation was not performed */
    }

cy_en_syspm_status_t Cy_SysPm_BuckSetVoltage1(cy_en_syspm_buck_voltage1_t voltage)

Sets the output 1 voltage for the Buck regulator that can supply the device core.

This output can supply the device core instead of the LDO regulator.

When changing from a higher voltage 1.1 V (nominal) to a lower voltage 0.9 V (nominal), ensure that:

  • The device maximum operating frequency for all the Clk_HF paths, peripheral, and slow clock are under the ULP Limitations.

  • The total current consumption is under the ULP Limitations.

  • The appropriate wait states values are set for the flash using the Cy_SysLib_SetWaitStates() function as explained below.

Setting wait states values for flash

The flash access time when the core output voltage is 0.9 V (nominal) is longer than at 1.1 V (nominal). Therefore, the number of the wait states must be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate wait state values for flash.

To change from a higher voltage to a lower voltage 0.9 V (nominal), call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.

To change from a lower voltage to a higher voltage 1.1 V (nominal), call the Cy_SysLib_SetWaitStates(false, hfClkFreqMz) function to set the wait states. It is optional, but can be done to improve the performance. The clock frequency may now be increased up to LP Limitations for a new voltage.

note

1. The output is set to 0.9 V (nominal) - the system is in ULP mode flash allows read-only operations.

note

2. The output is set to 1.1 V (nominal) - the system is in LP mode and flash allows the read and write operations.

note

3. The actual device Vccd voltage can be different from the nominal voltage because the actual voltage value depends on the conditions including the load current.

warning

Buck converter requires additional external components populated on dedicated pins. Refer to device datasheet for details.

For more detail, refer to the

Switching the System into Ultra Low Power and Switching the System into Low Power sections. Refer to the SysLib (System Library) driver for more detail about setting the wait states.

Return

  • CY_SYSPM_SUCCESS - The voltage is set.

  • CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers via syscall.

  • CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS. 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 increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

Side Effects

For PSoC 64 series devices Cy_SysPm_BuckSetVoltage1() has the same functional behavior as Cy_SysPm_BuckEnable() function.

Parameters

void Cy_SysPm_BuckSetVoltage2(cy_en_syspm_buck_voltage2_t voltage, bool waitToSettle)

This function sets output voltage 2 (Vbuckrf) of the SIMO Buck regulator.

warning

You must enable the delay (waitToSettle = true) while changing from a lower voltage to a higher voltage.

note

The 200 us delay is required only when changing from a lower voltage to a higher voltage. When changing from a higher voltage to a lower one, the delay is not required.

warning

The function works only on devices with the SIMO Buck regulator. Refer to the device datasheet for information on whether the device contains SIMO Buck.

warning

Buck converter requires additional external components populated on dedicated pins. Refer to device datasheet for details.

Function Usage

    /* Scenario: There is a need to set the SIMO Buck output 2 voltage to 1.35 V */
    Cy_SysPm_BuckSetVoltage2(CY_SYSPM_BUCK_OUT2_VOLTAGE_1_35V, true);

Parameters
  • voltage: The voltage of the Buck regulator output 2 (Vbuckrf). See cy_en_syspm_buck_voltage2_t.

  • waitToSettle:

    • True to enable the 200 us delay after setting a higher voltage.

    • False to disable the 200 us delay after setting a higher voltage.

void Cy_SysPm_BuckEnableVoltage2(void)

Enable the output 2 voltage (Vbuckrf) of the SIMO Buck regulator.

The output 2 voltage (Vbuckrf) of the Buck regulator is typically used to supply the BLE radio. This function does following actions, when the Buck regulator does not supply the core:

  • Enables the Buck regulator

  • Enables the output 2, but do not enables the output 1.

note

The function does not affect Buck output 1 that typically supplies core.

warning

The function does not select the Buck output 2 voltage and does not set/clear the HW-controlled bit for Buck output 2. Call Cy_SysPm_BuckSetVoltage2() or Cy_SysPm_BuckSetVoltage2HwControl() to configure the Buck output 2.

warning

The function works only on devices with the SIMO Buck regulator. Refer to the device datasheet for information on whether the device contains the SIMO Buck.

warning

Buck converter requires additional external components populated on dedicated pins. Refer to device datasheet for details.

Function Usage

    /* Scenario: There is a need to enable the SIMO Buck output 2 */
    Cy_SysPm_BuckEnableVoltage2();

bool Cy_SysPm_BuckIsOutputEnabled(cy_en_syspm_buck_out_t output)

This function gets the current output status of the Buck outputs.

Return

  • True if the requested output is enabled.

  • False if the requested output is disabled.

Function Usage

    /* Scenario: There is a need to check the status of the SIMO Buck output 2 (Vbuckrf) */
    if (Cy_SysPm_BuckIsOutputEnabled(CY_SYSPM_BUCK_VRF))
    {
        /* The SIMO Buck output 2 is enabled */
    }

Parameters

bool Cy_SysPm_RegisterCallback(cy_stc_syspm_callback_t *handler)

Registers a new syspm callback.

A callback is a function called after an event in the driver or middleware module has occurred. The handler callback API will be executed if the specific event occurs. SysPm callbacks are called when changing power modes. See cy_stc_syspm_callback_t.

note

The registered callbacks are executed in two orders, based on callback mode cy_en_syspm_callback_mode_t. For modes CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION, the order is same order as callbacks were registered. For modes CY_SYSPM_AFTER_TRANSITION and CY_SYSPM_CHECK_FAIL, the order is reverse as the order callbacks were registered.

note

Do not modify the registered structure in run-time.

warning

After being registered, the SysPm callback structures must be allocated during power mode transition.

Return

  • True if a callback was registered.

  • False if a callback was not registered.

Function Usage

/* Scenario: There is a need to have three callbacks for the CPU Deep Sleep 
*  mode. DeepSleepFunc1 and DeepSleepFunc2 callback function skip 
*  CY_SYSPM_BEFORE_TRANSITION mode.
*  DeepSleepFunc3 executes all four modes. 
*  Note that for the multi-CPU devices the another CPU must be in CPU 
*  Deep Sleep power mode. 
*/

/******************************************************************************
*  Callback prototypes
******************************************************************************/
cy_en_syspm_status_t DeepSleepFunc1(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
cy_en_syspm_status_t DeepSleepFunc2(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
cy_en_syspm_status_t DeepSleepFunc3(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
/******************************************************************************
*  Parameter structures for callback functions
******************************************************************************/
cy_stc_syspm_callback_params_t deepSleepParam1 = 
{
    NULL,
    NULL
};

cy_stc_syspm_callback_params_t deepSleepParam2 = 
{
    &HW1_address,
    &context
};

cy_stc_syspm_callback_params_t deepSleepParam3 = 
{
    &HW2_address,
    NULL
};
/******************************************************************************
*  Callbacks structures
******************************************************************************/
cy_stc_syspm_callback_t myDeepSleep1 = 
{
    &DeepSleepFunc1, 
    CY_SYSPM_DEEPSLEEP,
    CY_SYSPM_SKIP_BEFORE_TRANSITION,
    &deepSleepParam1,
    NULL,
    NULL,
    0
};

cy_stc_syspm_callback_t myDeepSleep2 = 
{
    &DeepSleepFunc2, 
    CY_SYSPM_DEEPSLEEP,
    CY_SYSPM_SKIP_BEFORE_TRANSITION,
    &deepSleepParam2,
    NULL,
    NULL,
    0
};

cy_stc_syspm_callback_t myDeepSleep3 = 
{
    &DeepSleepFunc3, 
    CY_SYSPM_DEEPSLEEP,
    0U,
    &deepSleepParam3,
    NULL,
    NULL,
    0
};
    
/******************************************************************************
*  DeepSleepFunc1 implementation
******************************************************************************/
cy_en_syspm_status_t DeepSleepFunc1(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)
{
    cy_en_syspm_status_t retVal = CY_SYSPM_FAIL;
    
    
    if (callbackParams != NULL)
    {
        /* In this use case we do not need to use HW address or context
        * So, need to add code to some switch case with callbackParams to avoid 
        * compiler warnings
        */
    }
    
    switch(mode)
    {
        /* In this case ensure that firmware/hardware is ready for CPU
        *  Deep Sleep mode */
        case CY_SYSPM_CHECK_READY:
            if(true/* system is ready */)
            {
                /* Process the "check ready" condition */
                retVal = CY_SYSPM_SUCCESS;
            }
            break;
        
        /* One of the registered callback that was executed after this callback 
        *  returned CY_SYSPM_FAIL, need to revert changes (if any) performed in 
        *  the CY_SYSPM_CHECK_READY case.
        */
        case CY_SYSPM_CHECK_FAIL:
            {
                /* Revert changes done in the CY_SYSPM_CHECK_READY case */
                retVal = CY_SYSPM_SUCCESS;
            }
            break;
            
        /* This case will be skipped during callbacks execution */
        case CY_SYSPM_BEFORE_TRANSITION:
            break;
            
        /* This case is executed after wakeup from system Deep Sleep */
        case CY_SYSPM_AFTER_TRANSITION:
            {
                /* Perform actions, if required, after wakeup from the  
                *  system Deep Sleep mode */
                retVal = CY_SYSPM_SUCCESS;
            }
            break;
        
        default:
            break;
    }
    
    return (retVal);
}


/******************************************************************************
*  DeepSleepFunc2 implementation
******************************************************************************/
cy_en_syspm_status_t DeepSleepFunc2(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)
{
    CySCB_Type *hwBase = (CySCB_Type *) callbackParams->base;
    cy_stc_scb_spi_context_t *context = (cy_stc_scb_spi_context_t *) callbackParams->context;
    
    cy_en_syspm_status_t retVal = CY_SYSPM_FAIL;

    switch(mode)
    {
        /* Check is the HW1 ready to enter CPU Deep Sleep */
        case CY_SYSPM_CHECK_READY:
        {
            /* ... */
            if (0UL == (CY_SCB_SPI_TRANSFER_ACTIVE & Cy_SCB_SPI_GetTransferStatus(hwBase, context)))
            {
                /* There are no active actions so we can enter CPU Deep Sleep */
                retVal = CY_SYSPM_SUCCESS;
            }
            break;
        }

        default:
            retVal = CY_SYSPM_FAIL;
            break;
    }
    
    return (retVal);
}

    
/******************************************************************************
*  DeepSleepFunc3 implementation
******************************************************************************/
cy_en_syspm_status_t DeepSleepFunc3(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)
{
    CySCB_Type *hwBase = (CySCB_Type *) callbackParams->base;

    cy_en_syspm_status_t retVal = CY_SYSPM_FAIL;

    switch(mode)
    {
        /* Check is the HW2 ready to enter into CPU Deep Sleep */
        case CY_SYSPM_CHECK_READY:
        {
            if (!Cy_SCB_SPI_IsBusBusy(hwBase))
            {
                /* Process the "check ready" condition */
                retVal = CY_SYSPM_SUCCESS;
            }
        
            break;
        }

        case CY_SYSPM_BEFORE_TRANSITION:
        {
            /* Switch - Turn off SCB SPI */
            retVal = CY_SYSPM_SUCCESS;
            break;
        }
        
        
        case CY_SYSPM_AFTER_TRANSITION:
        {
            /* Switch - Turn on SCB SPI */
            retVal = CY_SYSPM_SUCCESS;
            break;
        }

        case CY_SYSPM_CHECK_FAIL:
        {
            /* Revert changes made in CY_SYSPM_CHECK_READY switch case (if any) */
            break;
        }

        default:
            break;
    }
    
    return (retVal);
}
    /* Register myDeepSleep1 */
    if (true != Cy_SysPm_RegisterCallback(&myDeepSleep1))
    {
        /* Insert error handling */
    }
    
    /* Register myDeepSleep2 */
    if (true != Cy_SysPm_RegisterCallback(&myDeepSleep2))
    {
        /* Insert error handling */
    }
    
    /* Register myDeepSleep3 */
    if (true != Cy_SysPm_RegisterCallback(&myDeepSleep3))
    {
        /* Insert error handling */
    }

Parameters

bool Cy_SysPm_UnregisterCallback(cy_stc_syspm_callback_t const *handler)

This function unregisters a callback.

The registered callback can be unregistered and the function returns true. Otherwise, false is returned.

Return

  • True if callback was unregistered.

  • False if it was not unregistered or no callbacks are registered.

Function Usage

    /* Scenario: There is a need to unregister a previously registered callback */
    if (true != Cy_SysPm_UnregisterCallback(&myDeepSleep2))
    {
        /* Insert error handler */
    }

Parameters

cy_en_syspm_status_t Cy_SysPm_ExecuteCallback(cy_en_syspm_callback_type_t type, cy_en_syspm_callback_mode_t mode)

The function executes all registered callbacks with provided type and mode.

note

This low-level function is being used by Cy_SysPm_CpuEnterSleep, Cy_SysPm_CpuEnterDeepSleep, Cy_SysPm_SystemEnterHibernate, Cy_SysPm_SystemEnterUlp and Cy_SysPm_SystemEnterLp API functions. However, it might be also useful as an independent API function in some custom applications.

note

The registered callbacks will be executed in order based on cy_en_syspm_callback_type_t value. There are two possible callback execution orders:

  • From first registered to last registered. This order applies to callbacks with mode CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION.

  • Backward flow execution:

    • From last registered to the first registered. This order applies to callbacks with mode CY_SYSPM_AFTER_TRANSITION.

    • From last called to the first registered callback. This order applies to callbacks with mode CY_SYSPM_CHECK_FAIL. Note that, the last called callback function that generated the CY_SYSPM_CHECK_FAIL is skipped when mode CY_SYSPM_CHECK_FAIL. This is because the callback that returns CY_SYSPM_FAIL already knows that it failed and will not take any action that requires correction.

If no callbacks are registered, returns CY_SYSPM_SUCCESS.

Return

  • CY_SYSPM_SUCCESS if callback successfully completed or nor callbacks registered.

  • CY_SYSPM_FAIL one of the executed callback(s) returned fail.

Function Usage

    /* Scenario: There is a need to execute all the registered callbacks for 
    *  CPU Sleep mode and Check Ready condition
    */
    if (CY_SYSPM_SUCCESS != Cy_SysPm_ExecuteCallback(CY_SYSPM_SLEEP, CY_SYSPM_CHECK_READY))
    {
        /* Insert error handling */
    }

Parameters

cy_stc_syspm_callback_t *Cy_SysPm_GetFailedCallback(cy_en_syspm_callback_type_t type)

Reads the result of the callback execution after the power mode functions execution.

This function reads the value of the pointer that stores the result of callback execution. It takes power mode as the parameter and returns the address of the callback configuration structure in the case of failure or NULL in the case of success. This address of the failed callback allows finding the callback that blocks entering power mode.

Return

  • The address of the callback configuration structure if the callback handler function failed.

  • NULL if the callback skipped or executed successfully.

Function Usage

    /* Scenario: There is a need to put the CPU into Deep Sleep mode, and in the case
    *  of failure - to trace failed callback
    */

    /* Prepare the system for Deep Sleep power mode */
    if(CY_SYSPM_SUCCESS != Cy_SysPm_CpuEnterDeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT))
    {
        /* CPU did not enter Deep Sleep mode because one of executed callback 
        *  returned a "fail" status
        */

        /* Call Cy_SysPm_GetFailedCallback to get the address of the failed callback */
        cy_stc_syspm_callback_t* failedCallbackPtr = Cy_SysPm_GetFailedCallback(CY_SYSPM_DEEPSLEEP);

        /* Find out which callback failed */
        if(failedCallbackPtr == (&myDeepSleep1))
        {
            /* myDeepSleep1 callback failed */
        }
        else if(failedCallbackPtr == (&myDeepSleep2))
        {
            /* myDeepSleep2 callback failed */
        }
        else if(failedCallbackPtr == (&myDeepSleep3))
        {
            /* myDeepSleep3 callback failed */
        }
        else 
        {
            /* In this case, the address of the failed callback was not compared
            *  with the address returned by Cy_SysPm_GetFailedCallback
            */
        }
    }
    else
    {
        /* If the program has reached here, the core is just woken up
         * from the CPU Deep Sleep mode
         */
    }

Parameters
  • type: Power mode for which a callback execution result is required.

bool Cy_SysPm_Cm4IsActive(void)

Checks if CM4 is in CPU Active mode.

Return

  • True if CM4 is in CPU Active mode.

  • False if the CM4 is not in CPU Active mode.

Function Usage

    /* Scenario: There is a need to check if CM4 is in CPU Active mode */
    if (Cy_SysPm_Cm4IsActive())
    {
        /* CM4 is in CPU Active mode */
    }

bool Cy_SysPm_Cm4IsSleep(void)

Checks if the CM4 is in CPU Sleep mode.

Return

  • True if the CM4 is in CPU Sleep mode.

  • False if the CM4 is not in CPU Sleep mode.

Function Usage

    /* Scenario: There is a need to check if CM4 is in CPU Sleep mode */
    if (Cy_SysPm_Cm4IsSleep())
    {
        /* CM4 is in CPU Sleep mode */
    }

bool Cy_SysPm_Cm4IsDeepSleep(void)

Checks if the CM4 is in the CPU Deep Sleep mode.

Return

  • True if CM4 is in CPU Deep Sleep mode.

  • False if the CM4 is not CPU in Deep Sleep mode.

Function Usage

    /* Scenario: There is a need to check if CM4 is in CPU Deep Sleep mode */
    if (Cy_SysPm_Cm4IsDeepSleep())
    {
        /* CM4 is in CPU Deep Sleep mode */
    }

bool Cy_SysPm_Cm0IsActive(void)

Checks if the CM0+ is in CPU Active mode.

Return

  • True if the CM0+ is in CPU Sleep mode.

  • False if the CM0+ is not in CPU Sleep mode.

Function Usage

    /* Scenario: There is a need to check if CM0+ is in CPU Active mode */
    if (Cy_SysPm_Cm0IsActive())
    {
        /* CM0+ is in CPU Active mode */
    }

bool Cy_SysPm_Cm0IsSleep(void)

Checks if the CM0+ is in CPU Sleep mode.

Return

  • True if the CM0+ is in CPU Sleep mode.

  • False if the CM0+ is not in CPU Sleep mode.

Function Usage

    /* Scenario: There is a need to check if CM0+ is in CPU Sleep mode */
    if (Cy_SysPm_Cm0IsSleep())
    {
        /* CM0+ is in CPU Sleep mode */
    }

bool Cy_SysPm_Cm0IsDeepSleep(void)

Checks if the CM0+ is in CPU Deep Sleep mode.

Return

  • True if the CM0+ is in CPU Deep Sleep mode

  • False if the CM0+ is not in CPU Deep Sleep mode

Function Usage

    /* Scenario: There is a need to check if CM0+ is in CPU Deep Sleep mode */
    if (Cy_SysPm_Cm0IsDeepSleep())
    {
        /* CM0+ is in CPU Deep Sleep mode */
    }

bool Cy_SysPm_IsSystemLp(void)

Checks if the system is in LP mode.

Return

  • True the system is in LP mode.

  • False the system is not in LP mode.

Function Usage

    /* Scenario: There is a need to check if the system is in Low Power
    *  mode
    */
    if (Cy_SysPm_IsSystemLp())
    {
        /* The system is in LP mode */
    }

bool Cy_SysPm_IsSystemUlp(void)

Checks if the system is in ULP mode.

Return

  • True the system is in ULP mode.

  • False the system is is not ULP mode.

Function Usage

    /* Scenario: There is a need to check if the system is in Ultra Low Power
    *  mode
    */
    if (Cy_SysPm_IsSystemUlp())
    {
        /* The system is in ULP */
    }

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 */
    if (Cy_SysPm_Cm4IsSleep())
    {
        /* Wake up the CM4 CPU */
        Cy_SysPm_CpuSendWakeupEvent();
    }

bool Cy_SysPm_SystemIsMinRegulatorCurrentSet(void)

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

note

CAT1B devices, function always returns 0.

Return

  • 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
    */
    

bool Cy_SysPm_BuckIsEnabled(void)

Get the current status of the Buck regulator.

Return

  • True if the Buck regulator is enabled.

  • False if it is disabled.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

cy_en_syspm_buck_voltage1_t Cy_SysPm_BuckGetVoltage1(void)

Gets the current nominal output 1 voltage (Vccbuck1) of the Buck regulator.

note

The actual device output 1 voltage (Vccbuck1) can be different from the nominal voltage because the actual voltage value depends on conditions including load current.

note

CAT1B devices, function always returns 0.

Return

The nominal output voltage 1 (Vccbuck1) of the Buck regulator. See cy_en_syspm_buck_voltage1_t.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

cy_en_syspm_buck_voltage2_t Cy_SysPm_BuckGetVoltage2(void)

Gets the current output 2 nominal voltage (Vbuckrf) of the SIMO Buck regulator.

note

The actual device output 2 voltage (Vbuckrf) can be different from the nominal voltage because the actual voltage value depends on conditions including load current.

note

Function returns zero for devices without a SIMO Buck regulator. Refer to the device datasheet about information on whether device contains a SIMO Buck.

Return

The nominal output voltage of the Buck SIMO regulator output 2 voltage (Vbuckrf). See cy_en_syspm_buck_voltage2_t.

Function Usage

    /* Scenario: There is a need to get the nominal output 2 voltage of the SIMO Buck regulator */
    cy_en_syspm_simo_buck_voltage2_t voltage = Cy_SysPm_BuckGetVoltage2();

void Cy_SysPm_BuckDisableVoltage2(void)

Disables the output 2 voltage (Vbuckrf) of the SIMO Buck regulator.

The output 2 voltage (Vbuckrf) of the Buck regulator is typically used to supply the BLE radio.

note

The function does not have effect, if the Buck regulator is switched off.

note

If you are switching the voltage supply source for BLE radio, ensure that the new voltage supply for the BLE HW block is settled and is stable before calling the Cy_SysPm_BuckDisableVoltage2() function.

This function is applicable for devices with the SIMO Buck regulator. Refer to the device datasheet for information about whether the device contains a SIMO Buck.

Function Usage

    /* Scenario: There is a need to disable the output 2 voltage of the SIMO Buck regulator */
    Cy_SysPm_BuckDisableVoltage2();

void Cy_SysPm_BuckSetVoltage2HwControl(bool hwControl)

Sets the hardware control for SIMO Buck output 2 (Vbuckrf).

When hardware control is enabled for the Vbuckrf output, the firmware controlled enable register setting is ignored and the hardware signal is used instead. If the product has supporting hardware like BLE radio, it can directly control the enable signal for Vbuckrf.

Function does not have an effect if SIMO Buck regulator is disabled.

Parameters
  • hwControl: Enables/disables hardware control for the SIMO Buck output 2.

The function is applicable for devices with the SIMO Buck regulator. Refer to the device datasheet for information about whether the device contains a SIMO Buck.

Function Usage

    /* Scenario: There is a need to enable the hardware control for the SIMO Buck output 2 */
    Cy_SysPm_BuckSetVoltage2HwControl(true);
    
    /* Scenario: There is a need to disable the hardware control for the SIMO Buck output 2 */
    Cy_SysPm_BuckSetVoltage2HwControl(false);

bool Cy_SysPm_BuckIsVoltage2HwControlled(void)

Returns the hardware control state for Buck output 2 (Vbuckrf).

When hardware control is enabled for the Vbuckrf output, the firmware controlled enable register setting is ignored and the hardware signal is used instead. If the product has supporting hardware like BLE radio, it can directly control the enable signal for Vbuckrf.

The function is applicable for devices with the SIMO Buck regulator. Refer to device datasheet about information if device contains SIMO Buck.

Return

  • True if HW control is set.

  • False if FW control is set for the Buck output 2.

Function Usage

    /* Scenario: There is a need to check if the hardware control for 
    *  Buck output 2 (Vbuckrf) is enabled
    */
    if (Cy_SysPm_BuckIsVoltage2HwControlled())
    {
        /* The hardware control for Vbuckrf is enabled */
    }

cy_en_syspm_ldo_voltage_t Cy_SysPm_LdoGetVoltage(void)

Gets the current output voltage value of the core LDO regulator.

note

The actual device Vccd voltage can be different from the nominal voltage because the actual voltage value depends on conditions including the load current.

note

CAT1B devices, function always returns 0.

Return

The nominal output voltage of the LDO. See cy_en_syspm_ldo_voltage_t.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

bool Cy_SysPm_LdoIsEnabled(void)

Reads the current status of the core LDO regulator.

note

For CAT1B devices IP, function always returns 0.

Return

  • True means the LDO is enabled.

  • False means it is disabled.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

bool Cy_SysPm_IoIsFrozen(void)

Checks whether IOs are frozen.

Return

  • True if IOs are frozen.

  • False if IOs are unfrozen.

Function Usage

    
    /* Scenario: There is a need to use Hibernate power mode and retain the 
    *  the I/O state after the a wake-up from Hibernate
    */

    /* Check the I/O freeze status after the boot.
    *  If the I/O is frozen it means we have returned from Hibernate.
    */
    if(Cy_SysPm_IoIsFrozen())
    {
        /* Restore the I/O configuration before unfreezing.
        *  Use configuration data programmed into firmware stored in S
        *  RSS->PWR_HIB_DATA[] or BACKUP->BREG[] 
        *  before the Hibernate was entered. Th emost common use case is to
        *  restore from GPIO driver the firmware initialization structures.
        */
        Cy_SysPm_IoUnfreeze();
    }

    /* Save the I/O before entering Hibernate. You can store the
    *  the I/O configuration into SRSS->PWR_HIB_DATA[] or 
    *  BACKUP->BREG[] registers.
    */
    
    /* Enter Hibernate mode */
    Cy_SysPm_SystemEnterHibernate();
    

void Cy_SysPm_PmicEnable(void)

Enable the external PMIC controller that supplies Vddd (if present).

For information about the PMIC controller input and output pins and their assignment in specific devices, refer to the appropriate device TRM.

This function is not effective when the PMIC controller is locked. Call Cy_SysPm_PmicUnlock() before enabling the PMIC.

Function Usage

    /* Scenario: There is a need to enable the external PMIC while the PMIC 
    *  controller is already locked
    */
    Cy_SysPm_PmicUnlock();
    Cy_SysPm_PmicEnable();
    Cy_SysPm_PmicLock();

void Cy_SysPm_PmicDisable(cy_en_syspm_pmic_wakeup_polarity_t polarity)

Disable the external PMIC controller that supplies Vddd (if present).

This function does not affect the PMIC controller output pin. The PMIC controller input pin has programmable polarity to enable the external PMIC using different input polarities. The PMIC controller is automatically enabled when the input pin polarity and configured polarity match. This function is not effective when the active level of PMIC controller input pin is equal to the configured PMIC controller polarity.

The function is not effective when the PMIC controller is locked. Call Cy_SysPm_PmicUnlock() before enabling the PMIC controller.

The PMIC controller will be enabled automatically by any of RTC alarm or PMIC wakeup events, regardless of the PMIC controller lock state.

Parameters
  • polarity: Configures the PMIC controller wakeup input pin to be active low or active high. The PMIC will be automatically enabled when the set polarity and the active level of PMIC input pin match. See cy_en_syspm_pmic_wakeup_polarity_t.

note

Before disabling the PMIC controller, ensure that PMIC input and PMIC output pins are configured correctly to enable expected PMIC operation.

warning

The PMIC is enabled automatically when you call Cy_SysPm_PmicLock(). To keep the external PMIC disabled, the PMIC controller must remain unlocked.

warning

Do not call Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_LOW) because this is not supported by hardware.

For information about the PMIC controller input and output pins and their assignment in the specific devices, refer to the appropriate device TRM.

Function Usage

    /* Scenario: There is a need to disable the external PMIC with an active 
    *  high state is detected on the PMIC controller input.
    */
    
    /* Configure the PMIC controller input pin to be active logic high after 
    *  the PMIC controller is disabled
    */
    Cy_GPIO_SetDrivemode(P0_4_PORT, P0_4_PIN, CY_GPIO_DM_PULLUP);
    Cy_GPIO_Set(P0_4_PORT, P0_4_PIN);
    
    /* Configure the PMIC controller output pin to be active logic low 
    *  after the PMIC is disabled */
    Cy_GPIO_SetDrivemode(P0_5_PORT, P0_5_PIN, CY_GPIO_DM_STRONG_IN_OFF);
    Cy_GPIO_Clr(P0_5_PORT, P0_5_PIN);
    
    
    if (Cy_SysPm_PmicIsOutputEnabled())
    {
        Cy_SysPm_PmicUnlock();
        Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_HIGH);
    }

void Cy_SysPm_PmicAlwaysEnable(void)

Enable the external PMIC controller that supplies Vddd (if present) and force active.

This is a Write once API. It ensures that the PMIC controller cannot be disabled or polarity changed until a next device reset.

For information about the PMIC controller input and output pins and their assignment in the specific devices, refer to the appropriate device TRM.

Function Usage

    /* Scenario: There is a need to enable the signal through the PMIC 
    *  controller output pin
    */
    Cy_SysPm_PmicUnlock();
    Cy_SysPm_PmicAlwaysEnable();

void Cy_SysPm_PmicEnableOutput(void)

Enables the PMIC controller output pin.

The function is not effective when the PMIC controller is locked. Call Cy_SysPm_PmicUnlock() before enabling the PMIC controller.

For information about the PMIC controller output pin and its assignment in specific devices, refer to the appropriate device TRM.

Function Usage

    /* Scenario: There is a need to enable the PMIC controller output.
    * Note that the output logic state of the pmic_output is ignored once 
    * the Cy_SysPm_PmicEnableOutput() is called.
    */
    Cy_SysPm_PmicUnlock();
    Cy_SysPm_PmicEnableOutput();
    Cy_SysPm_PmicLock();

void Cy_SysPm_PmicDisableOutput(void)

Disables the PMIC controller output pin.

When the PMIC controller output pin is disabled and is unlocked, the PMIC controller output pin can be used for the another purpose.

The function has no effect when the PMIC is locked. Call Cy_SysPm_PmicUnlock() before enabling the PMIC.

For information about the PMIC controller output pin and its assignment in specific devices, refer to the appropriate device TRM.

note

After the PMIC controller output is disabled, the PMIC output pin returns to its GPIO configured state.

warning

The PMIC controller output is enabled automatically when you call Cy_SysPm_PmicLock(). To keep the PMIC controller output disabled, the PMIC controller must remain unlocked.

Function Usage

    /* Scenario: There is a need to disable the PMIC controller output. Note 
    *  that once the Cy_SysPm_PmicDisableOutput() is called, the pmic_output pin
    *  returns to its GPIO configuration.
    */
    
    /* Configure the pmic_output pin GPIO configuration to Strong Drive, Input 
    * buffer off and have output active logic state low. This GPIO configuration
    * applies after Cy_SysPm_PmicDisableOutput() is called.
    */
    Cy_GPIO_SetDrivemode(P0_5_PORT, P0_5_PIN, CY_GPIO_DM_STRONG_IN_OFF);
    Cy_GPIO_Clr(P0_5_PORT, P0_5_PIN);
    
    Cy_SysPm_PmicUnlock();
    Cy_SysPm_PmicDisableOutput();

void Cy_SysPm_PmicLock(void)

Locks the PMIC control controller register so that no changes can be made.

The changes are related to PMIC enabling/disabling and PMIC output pin enabling/disabling.

warning

The PMIC controller and/or the PMIC output are enabled automatically when you call Cy_SysPm_PmicLock(). To keep the PMIC or PMIC controller output disabled, the PMIC controller must remain unlocked.

Function Usage

    /* Scenario: There is a need to lock and enable the PMIC controller */
    if (!Cy_SysPm_PmicIsLocked() && Cy_SysPm_PmicIsEnabled())
    {
        Cy_SysPm_PmicLock();
    }

void Cy_SysPm_PmicUnlock(void)

Unlocks the PMIC control register so that changes can be made.

The changes are related to the PMIC controller enabling/disabling and PMIC output pin enabling/disabling.

warning

The PMIC controller and/or the PMIC output are enabled automatically when you call Cy_SysPm_PmicLock(). To keep the PMIC controller or PMIC output disabled, the PMIC must remain unlocked.

Function Usage

    /* Scenario: There is a need to enable the external PMIC while the PMIC 
    *  controller is already locked
    */
    Cy_SysPm_PmicUnlock();
    Cy_SysPm_PmicEnable();
    Cy_SysPm_PmicLock();

bool Cy_SysPm_PmicIsEnabled(void)

This function returns the status of the PMIC controller.

Return

  • True if the PMIC is enabled.

  • False if the PMIC is disabled.

Function Usage

    /* Scenario: There is a need to lock and enable the PMIC controller */
    if (!Cy_SysPm_PmicIsLocked() && Cy_SysPm_PmicIsEnabled())
    {
        Cy_SysPm_PmicLock();
    }

bool Cy_SysPm_PmicIsOutputEnabled(void)

This function returns the status of the PMIC controller output.

Return

  • True if the PMIC output is enabled.

  • False if the PMIC output is disabled.

Function Usage

    /* Scenario: There is a need to disable the external PMIC with an active 
    *  high state is detected on the PMIC controller input.
    */
    
    /* Configure the PMIC controller input pin to be active logic high after 
    *  the PMIC controller is disabled
    */
    Cy_GPIO_SetDrivemode(P0_4_PORT, P0_4_PIN, CY_GPIO_DM_PULLUP);
    Cy_GPIO_Set(P0_4_PORT, P0_4_PIN);
    
    /* Configure the PMIC controller output pin to be active logic low 
    *  after the PMIC is disabled */
    Cy_GPIO_SetDrivemode(P0_5_PORT, P0_5_PIN, CY_GPIO_DM_STRONG_IN_OFF);
    Cy_GPIO_Clr(P0_5_PORT, P0_5_PIN);
    
    
    if (Cy_SysPm_PmicIsOutputEnabled())
    {
        Cy_SysPm_PmicUnlock();
        Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_HIGH);
    }

bool Cy_SysPm_PmicIsLocked(void)

Returns the PMIC controller lock status.

Return

  • True if the PMIC is locked.

  • False if the PMIC is unlocked.

Function Usage

    /* Scenario: There is a need to lock and enable the PMIC controller */
    if (!Cy_SysPm_PmicIsLocked() && Cy_SysPm_PmicIsEnabled())
    {
        Cy_SysPm_PmicLock();
    }

void Cy_SysPm_BackupSetSupply(cy_en_syspm_vddbackup_control_t vddBackControl)

Sets the backup supply (Vddback) operation mode.

Refer to device TRM for more detail about backup supply modes.

Parameters

Function Usage

    /* Scenario: There is a need to set only Vbackup to supply Vddbackup */
    /* Ensure there is a valid power connection on backup pin */
    Cy_SysPm_BackupSetSupply(CY_SYSPM_VDDBACKUP_VBACKUP);

cy_en_syspm_vddbackup_control_t Cy_SysPm_BackupGetSupply(void)

Returns the current backup supply (Vddback) operation mode.

Refer to device TRM for more detail about backup supply modes.

Return

The current backup supply (Vddback) operation mode, see cy_en_syspm_status_t.

Function Usage

    /* Scenario: There is a need to get the current backup supply (Vddback) operation mode */
    cy_en_syspm_vddbackup_control_t mode = Cy_SysPm_BackupGetSupply();

void Cy_SysPm_BackupEnableVoltageMeasurement(void)

This function enables Vbackup supply measurement by the ADC.

The function connects the Vbackup supply to AMuxBusA. The ADC input can then be connected to AMuxBusA. Note that the measured signal is scaled by 10% to allow full range measurement by the ADC.

Refer to device TRM for more detail about Vbackup supply measurement.

Function Usage

    /* Scenario: There is a need to enable Vbackup supply measurement
    * via AMuxBusA, e.g. by the internal ADC.  
    */
    /* Connect amuxbus_sar to amuxbus_main */
    HSIOM->AMUX_SPLIT_CTL[6] = HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk;

    /* Connect amuxbus_adft0_vddd to amuxbus_main */
    HSIOM->AMUX_SPLIT_CTL[0] = HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk;

    /* Connect Vddbackmeasure to AMuxBus */
    Cy_SysPm_BackupEnableVoltageMeasurement();

void Cy_SysPm_BackupDisableVoltageMeasurement(void)

The function disables Vbackup supply measurement by the ADC by disconnecting the Vbackup supply from AMuxBusA.

Refer to device TRM for more detail about Vbackup supply measurement.

Function Usage

    /* Scenario: There is a need to disable the Vbackup supply measurement by the ADC */
    Cy_SysPm_BackupDisableVoltageMeasurement();

void Cy_SysPm_BackupSuperCapCharge(cy_en_syspm_sc_charge_key_t key)

Configures the supercapacitor charger circuit.

warning

This function is used only for charging the supercapacitor. Do not use this function to charge a battery. Refer to device TRM for more detail.

Function Usage

    /* Scenario: There is a need to charge the supercapacitor which will
     * supply the RTC during Hibernate mode for a few hours
     */
    Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE);

Parameters

struct cy_stc_syspm_callback_params_t
#include <cy_syspm.h>

The structure contains syspm callback parameters.

Public Members

void *base

Base address of a HW instance, matches name of the driver in the API for the base address.

Can be undefined if not required. Base address is not required for the SysPm driver as the device has only one set of power modes

void *context

Context for the handler function.

This item can be skipped if not required. Can be undefined if not required.

struct cy_stc_syspm_callback_t
#include <cy_syspm.h>

Structure with syspm callback configuration elements.

Public Members

Cy_SysPmCallback callback

The callback handler function.

cy_en_syspm_callback_type_t type

The callback type, see cy_en_syspm_callback_type_t.

uint32_t skipMode

The mask of modes to be skipped during callback execution, see Defines to skip the callbacks modes.

The corresponding callback mode won’t execute if the appropriate define is set. These values can be ORed. If all modes are required to be executed this element should be equal to zero. Skipping unneeded callback modes speeds up power mode transitions by skipping unneeded operations.

cy_stc_syspm_callback_params_t *callbackParams

The address of a cy_stc_syspm_callback_params_t, the callback is executed with these parameters.

struct cy_stc_syspm_callback *prevItm

The previous list item.

This element should not be defined, or defined as NULL. It is for internal usage to link this structure to the next registered structure. It will be updated during callback registration. Do not modify this element at run-time.

struct cy_stc_syspm_callback *nextItm

The next list item.

This element should not be defined, or defined as NULL. It is for internal usage to link this structure to the previous registered structure. It will be updated during callback registration. Do not modify this element at run-time.

uint8_t order

Holds the callback execution order value.

Range: 0-255. While entering low power mode, callbacks with lower order values are executed first. While exiting low power mode, the callbacks are executed in the opposite order. Callbacks with the same order value are executed in the order they are registered in the application.

struct cy_stc_syspm_backup_regs_t
#include <cy_syspm.h>

This internal structure stores non-retained registers in the system Deep Sleep power mode.

On wakeup from system Deep Sleep, these registers are restored.

Public Members

uint32_t CY_SYSPM_UDB_UDBIF_BANK_CTL_REG

UDB interface control register.

uint32_t CY_SYSPM_UDB_BCTL_MDCLK_EN_REG

UDB bank MDCLK_EN register.

uint32_t CY_SYSPM_UDB_BCTL_MBCLK_EN_REG

UDB bank MBCLK_EN register.

uint32_t CY_SYSPM_UDB_BCTL_BOTSEL_L_REG

UDB bank BOTSEL_L register.

uint32_t CY_SYSPM_UDB_BCTL_BOTSEL_U_REG

UDB bank BOTSEL_U register.

uint32_t CY_SYSPM_UDB_BCTL_QCLK_EN0_REG

UDB bank QCLK_EN0 register.

uint32_t CY_SYSPM_UDB_BCTL_QCLK_EN1_REG

UDB bank QCLK_EN1 register.

uint32_t CY_SYSPM_UDB_BCTL_QCLK_EN2_REG

UDB bank QCLK_EN2 register.

uint32_t CY_SYSPM_CM0_CLOCK_CTL_REG

CPUSS CM0+ clock control register.

note

This parameter is available for CAT1A devices.

uint32_t CY_SYSPM_CM4_CLOCK_CTL_REG

CPUSS CM4 clock control register.

note

This parameter is available for CAT1A devices.