CAT2 Peripheral Driver Library

Functions

bool Cy_SysPm_RegisterCallback (cy_stc_syspm_callback_t *handler)
 Registers a new syspm callback. More...
 
bool Cy_SysPm_UnregisterCallback (cy_stc_syspm_callback_t const *handler)
 This function unregisters a callback. More...
 
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. More...
 
cy_stc_syspm_callback_tCy_SysPm_GetFailedCallback (cy_en_syspm_callback_type_t type)
 Reads the result of the callback execution after the power mode functions execution. More...
 

Detailed Description

Function Documentation

◆ Cy_SysPm_RegisterCallback()

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. See cy_stc_syspm_callback_t. User is responsible for defining a separate buffer for each of the power modes registered lists.

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 as follows: the first registered callback will be always the first executed. And the last registered callback will be executed as the last callback. For modes CY_SYSPM_AFTER_TRANSITION and CY_SYSPM_CHECK_FAIL, the order is as follows: the first registered callback will be always the last executed. And the last registered callback will be executed as the first callback.
Parameters
handlerThe address of the syspm callback structure. See cy_stc_syspm_callback_t.
Note
Do not modify the registered structure in run-time.
Returns
  • True if a callback was registered.
  • False if a callback was not registered or maximum callbacks were registered.
Warning
After being registered, the SysPm callback structures must be allocated during power mode transition.

◆ Cy_SysPm_UnregisterCallback()

bool Cy_SysPm_UnregisterCallback ( cy_stc_syspm_callback_t const *  handler)

This function unregisters a callback.

The registered callback will be unregistered. Otherwise, false will be returned.

Parameters
handlerThe item that should be unregistered. See cy_stc_syspm_callback_t.
Returns
  • True if callback was unregistered.
  • False if it was not unregistered or no callbacks are registered.

◆ Cy_SysPm_ExecuteCallback()

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
The registered callbacks will be executed in order based on lastCallback 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 ref\ CY_SYSPM_BEFORE_TRANSITION.
  • Backward flow execution: from last executed callback to the first registered. Such order is relevant to callbacks with mode CY_SYSPM_AFTER_TRANSITION and CY_SYSPM_CHECK_FAIL. Note that, the last registered callback function is skipped with mode CY_SYSPM_CHECK_FAIL. This is because callback which returned CY_SYSPM_FAIL already know that it failed.

If no callbacks are registered, returns CY_SYSPM_SUCCESS.

Parameters
typeThe callback type. See cy_en_syspm_callback_type_t.
modeThe callback mode. See cy_en_syspm_callback_mode_t.
Returns
  • CY_SYSPM_SUCCESS if callback successfully completed or nor callbacks registered.
  • CY_SYSPM_FAIL one of the executed callback(s) returned fail.

◆ Cy_SysPm_GetFailedCallback()

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.

Parameters
typePower mode for which a callback execution result is required.
Returns
  • The address of the callback configuration structure if the callback handler function failed.
  • NULL if the callback skipped or executed successfully.