CAT2 Peripheral Driver Library

Functions

__STATIC_INLINE void Cy_SysClk_RegisterCallback (cy_cb_sysclk_t callback, cy_stc_sysclk_context_t *context)
 Registers a callback function that notifies that the timeout occurred in the Cy_SysClk_DeepSleepCallback. More...
 
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. More...
 

Detailed Description

Function Documentation

◆ Cy_SysClk_RegisterCallback()

__STATIC_INLINE void Cy_SysClk_RegisterCallback ( cy_cb_sysclk_t  callback,
cy_stc_sysclk_context_t context 
)

Registers a callback function that notifies that the timeout occurred in the Cy_SysClk_DeepSleepCallback.

Parameters
callbackThe pointer to a callback function. See cy_cb_sysclk_t for the function prototype.
contextThe pointer to context structure cy_stc_sysclk_context_t allocated by the user. The user should not modify anything in this structure.
Note
To remove/unregister the callback, pass NULL as the pointer to the callback function.
Function Usage
/* Scenario: The application uses PLL or ECO as clock sources for HFCLK.
* The device needs to enter chip Deep Sleep.
* The ECO and/or PLL should be properly prepared before entering low power mode.
*/
void SysClk_WakeUpTimeOut(uint32_t event)
{
/* Handle the wake up ECO/PLL error here */
CY_UNUSED_PARAMETER(event);
}
cy_stc_syspm_callback_params_t sysClkCallbackParams =
{
.base = NULL,
.context = (void*)&sysClkContext
};
cy_stc_syspm_callback_t sysClkCallback =
{
.skipMode = 0UL,
.callbackParams = &sysClkCallbackParams,
.prevItm = NULL,
.nextItm = NULL,
.order = 0
};
Function Usage
/* 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 wake up timings.
*/
/* Register the wake up timeout callback */
Cy_SysClk_RegisterCallback(&SysClk_WakeUpTimeOut, &sysClkContext);
/* Register the sysClk deep sleep callback */
bool regCbStatus = Cy_SysPm_RegisterCallback(&sysClkCallback);
if(!regCbStatus)
{
/* Could not register callback. Examine the number of registered callbacks */
}
/* Ensure that the clock measurement is not running and enter chip Deep Sleep */

◆ Cy_SysClk_DeepSleepCallback()

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 needed if PLL and/or ECO are enabled and used as a source for HFCLK.

This function performs the following:

  1. Before entering Deep Sleep, the clock configuration is saved in SRAM. If the HFCLK is clocked by EXCO (PLL/ECO) - the HFCLK source is changed to IMO (with it current frequency, also IMO is being enabled in case it was disabled).
  2. Upon wakeup from Deep Sleep, the function waits for ECO/PLL stabilization/locking, then restores the clock chain configuration.
  3. It performs unlocking IMO (in case if it was locked with WCO) before falling asleep and correspondingly locks it after waking up (it it was locked before).
  4. It interacts with the ILO calibrating API: the Cy_SysClk_IloStartMeasurement will not work after the CY_SYSPM_CHECK_READY, or falling asleep will be cancelled in case of the ILO measurement is already in progress.

The function prevents entry into Deep Sleep mode if the ILO measurement is currently performing; see Cy_SysClk_IloStartMeasurement.

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.
Also, after this callback execution before falling asleep and before this callback execution after waking up the HFCLK speed may be not as usual (it is switched to IMO), so it may affect other peripherals.
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.
You can use this callback implementation as an example to design custom low-power callbacks for certain user application.
There is a non-zero possibility of the ECO/PLL startup timeout at wakeup, therefore there is a user callback feature to indicate that, see Cy_SysClk_RegisterCallback and Callback Timeout Events. In case of ECO/PLL timeout, the HFCLK is not restored to the state as it was before the Deep Sleep, so user should either try to reconfigure the HFCLK clocking chain or adapt other periphery to the new HFCLK frequency (reconfigure peripheral clock dividers to restore the communication speed, etc.).
Parameters
callbackParamsstructure with the syspm callback parameters, see cy_stc_syspm_callback_params_t.
modeCallback mode, see cy_en_syspm_callback_mode_t
Returns
Error / status code; see cy_en_syspm_status_t. Pass if not doing an ILO measurement, otherwise - Fail.
Function Usage
/* Scenario: The application uses PLL or ECO as clock sources for HFCLK.
* The device needs to enter chip Deep Sleep.
* The ECO and/or PLL should be properly prepared before entering low power mode.
*/
void SysClk_WakeUpTimeOut(uint32_t event)
{
/* Handle the wake up ECO/PLL error here */
CY_UNUSED_PARAMETER(event);
}
cy_stc_syspm_callback_params_t sysClkCallbackParams =
{
.base = NULL,
.context = (void*)&sysClkContext
};
cy_stc_syspm_callback_t sysClkCallback =
{
.skipMode = 0UL,
.callbackParams = &sysClkCallbackParams,
.prevItm = NULL,
.nextItm = NULL,
.order = 0
};
Function Usage
/* 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 wake up timings.
*/
/* Register the wake up timeout callback */
Cy_SysClk_RegisterCallback(&SysClk_WakeUpTimeOut, &sysClkContext);
/* Register the sysClk deep sleep callback */
bool regCbStatus = Cy_SysPm_RegisterCallback(&sysClkCallback);
if(!regCbStatus)
{
/* Could not register callback. Examine the number of registered callbacks */
}
/* Ensure that the clock measurement is not running and enter chip Deep Sleep */