Functions

group group_sysclk_pm_funcs

Functions

cy_en_syspm_status_t Cy_SysClk_DeepSleepCallback(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)

Callback function to be used when entering system Deep Sleep mode.

This function is applicable if:

  • The FLL is enabled

  • The PLL is enabled and is driven by ECO

This function performs the following:

  1. Before entering Deep Sleep, the clock configuration is saved in SRAM. If the FLL/PLL source is the ECO, then the FLL/PLL is bypassed and the source is changed to IMO.

    If the FLL is enabled - it is just bypassed.

  2. Upon wakeup from Deep Sleep, the function waits for ECO stabilization, then restores the configuration and waits for the FLL/PLL to regain their frequency locks.

    If ECO is not used and FLL is enabled - it waits for FLL lock and unbypasses it.

The function prevents entry into Deep Sleep mode if the measurement counters are currently counting; see Cy_SysClk_StartClkMeasurementCounters.

This function can be called during execution of Cy_SysPm_CpuEnterDeepSleep. To do so, register this function as a callback before calling Cy_SysPm_CpuEnterDeepSleep - specify CY_SYSPM_DEEPSLEEP as the callback type and call Cy_SysPm_RegisterCallback.

note

This function is recommended to be the last callback that is registered. Doing so minimizes the time spent on low power mode entry and exit.
This function implements all four SysPm callback modes cy_en_syspm_callback_mode_t. So the cy_stc_syspm_callback_t::skipMode must be set to 0UL.
This function does not support such cases as, for example, FLL is enabled but bypassed by user code before entering Deep Sleep.
You can use this callback implementation as an example to design custom low-power callbacks for certain user application.

Return

Error / status code; see cy_en_syspm_status_t. Pass if not doing a clock measurement, otherwise Fail. Timeout if timeout waiting for ECO, FLL or PLL to get stable / regain its frequency lock. CY_SYSCLK_INVALID_STATE - ECO already enabled 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: The application uses FLL/PLL sourced from the ECO. The device
                 needs to enter chip Deep Sleep. The ECO and FLL/PLL must be
                 suitably prepared before entering low power mode. */

    /* Register all the Deep Sleep callbacks for other peripherals.
       The SysClk callback is recommended to be registered last to minimize
       the low power mode entry and wakeup timings. */

    cy_stc_syspm_callback_params_t clkCallbackParams = {
        /*.base       =*/ NULL,
        /*.context    =*/ NULL
    };

    cy_stc_syspm_callback_t clkCallback = {
        /*.callback       =*/ &Cy_SysClk_DeepSleepCallback,
        /*.type           =*/ CY_SYSPM_DEEPSLEEP,
        /*.skipMode       =*/ 0UL,
        /*.callbackParams =*/ &clkCallbackParams,
        /*.prevItm        =*/ NULL,
        /*.nextItm        =*/ NULL,
        /*.order          =*/ 0
    };

    /* Register the clock callback */
    if(!Cy_SysPm_RegisterCallback(&clkCallback))
    {
        /* Could not register callback. Examine the number of registered callbacks */
    }

    /* Ensure that the clock measurement is not running and enter chip Deep Sleep */

Parameters