Low Power Callback

group group_sar_functions_power

This set of functions is for Deep Sleep entry and exit.

Functions

cy_en_syspm_status_t Cy_SAR_DeepSleepCallback(const cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)

Callback to prepare the SAR before entering Deep Sleep and to re-enable the SAR after exiting Deep Sleep.

    
    /* Scenario: Before putting the device into Deep Sleep mode,
     * the SAR Deep Sleep callback must be registered to ensure
     * proper Deep Sleep entry and exit. */
    
    /* Set the base address pointer to the SAR hardware block. */
    static cy_stc_syspm_callback_params_t SARDeepSleepCallbackParams =
    {
        /* .base    */ SAR,
        /* .context */ NULL
    };
    
    /* Attach the Cy_SAR_DeepSleepCallback function and set the callback parameters. */
    static cy_stc_syspm_callback_t SARDeepSleepCallbackStruct =
    {
        /* .callback        */ (Cy_SysPmCallback)(&Cy_SAR_DeepSleepCallback),
        /* .type            */ CY_SYSPM_DEEPSLEEP,
        /* .skipMode        */ 0UL,
        /* .callbackParams  */ &SARDeepSleepCallbackParams,
        /* .prevItm         */ NULL,
        /* .nextItm         */ NULL,
        /* .order           */ 0
    };
    
    /* Register the callback before entering Deep Sleep mode. */
    Cy_SysPm_RegisterCallback(&SARDeepSleepCallbackStruct);
    
    /* Put the device into Deep Sleep mode and wait for an interrupt to wake up. */
    Cy_SysPm_DeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
Return

See cy_en_syspm_status_t

Function Usage

Parameters

void Cy_SAR_DeepSleep(SAR_Type *base)

This is the preferred routine to prepare the hardware for Deep Sleep.

It will call Cy_SAR_StopConvert to disable continuous conversions and wait for SAR conversions to stop before entering Deep Sleep. If the SARMUX is not configured for Deep Sleep operation, the entire SAR hardware block will be turned off.

This function is used in the

Cy_SAR_DeepSleepCallback. There is no need to call this function directly.
Return

None

Function Usage

Parameters
  • base: Pointer to structure describing registers

void Cy_SAR_Wakeup(SAR_Type *base)

This is the preferred routine to restore the hardware to the state after calling Cy_SAR_DeepSleep.

Restoring the hardware involves re-enabling the hardware, the reference buffer, and continuous scanning if it was previously enabled before entering sleep.

This function is used in the

Cy_SAR_DeepSleepCallback. There is no need to call this function directly.
Side Effects

Calling this function without previously calling Cy_SAR_DeepSleep can lead to unpredictable results.

Return

None

Function Usage

Parameters
  • base: Pointer to structure describing registers