PDStack Middleware Library 1.20
Functions

General Description

This section describes the PDStack Function Prototypes.

Functions

cy_en_pdstack_status_t Cy_PdStack_Dpm_Init (cy_stc_pdstack_context_t *ptrPdStackContext, cy_stc_usbpd_context_t *ptrUsbPdContext, const cy_stc_pdstack_port_cfg_t *ptrPortCfg, cy_stc_pdstack_app_cbk_t *ptrAppCbk, const cy_stc_pdstack_dpm_params_t *ptrDpmParams, cy_stc_sw_timer_t *ptrTimerContext)
 This function initializes the device policy manager with callback pointers and loads the port configuration information from the port config table. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Start (cy_stc_pdstack_context_t *ptrPdStackContext)
 This function makes the specified USB Type-C port operational. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Stop (cy_stc_pdstack_context_t *ptrPdStackContext)
 This function stops the port operation. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Disable (cy_stc_pdstack_context_t *ptrPdStackContext)
 This function disables the PD port operation and limits it to receiving hard reset signalling. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_PrepareDeepSleep (cy_stc_pdstack_context_t *ptrPdStackContext, bool *ptrDeepSleep)
 This function configures the PD policy manager and Type-C manager state machines to allow the PMG1 device to be placed in deep sleep. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Resume (cy_stc_pdstack_context_t *ptrPdStackContext, bool *ptrResume)
 This function resumes the Type-C manager and PD policy engine state machines after the PMG1 device has woken up from deep sleep. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_IsSleepAllowed (cy_stc_pdstack_context_t *ptrPdStackContext, bool *ptrSleepAllowed)
 This function checks if the PD policy engine and Type-C manager state machines corresponding to the specified Type-C port are idle. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Rtos_Init (cy_stc_pdstack_context_t *ptrPdStackContext, cy_stc_pdstack_rtos_context_t *ptrRtosContext)
 This function initializes the device policy manager with RTOS context details. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Task (cy_stc_pdstack_context_t *ptrPdStackContext)
 This function runs the Type-C manager and PD policy manager tasks for the specified port. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_SendPdCommand (cy_stc_pdstack_context_t *ptrPdStackContext, cy_en_pdstack_dpm_pd_cmd_t cmd, cy_stc_pdstack_dpm_pd_cmd_buf_t *ptrCmdBuf, bool isResp, cy_pdstack_dpm_pd_cmd_cbk_t cmdCbk)
 This function provides an interface for the application module to send PD commands. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_SendTypecCommand (cy_stc_pdstack_context_t *ptrPdStackContext, cy_en_pdstack_dpm_typec_cmd_t cmd, cy_pdstack_dpm_typec_cmd_cbk_t cmdCbk)
 This function provides an interface for the application module to send commands to the Type-C connection manager. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_ProtReset (cy_stc_pdstack_context_t *ptrPdStackContext, cy_en_pd_sop_t sop)
 This function resets PD protocol layer (transmit and receive) message ID counters for the specified PD packet type. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_ProtResetRx (cy_stc_pdstack_context_t *ptrPdStackContext, cy_en_pd_sop_t sop)
 This function resets the PD receive message counter for the specified packet type. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_PeStop (cy_stc_pdstack_context_t *ptrPdStackContext)
 This function stops the policy engine. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_Pd3SrcRpFlowControl (cy_stc_pdstack_context_t *ptrPdStackContext, bool blockSinkAms)
 This function is used to specify whether we should keep the Rp termination at SinkTxNG or SinkTxOK while acting as a PD 3.0 source. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_IsIdle (cy_stc_pdstack_context_t *ptrPdStackContext, bool *ptrIsIdle)
 Function to check whether the Type-C/PD stack is idle. More...
 
void Cy_PdStack_Dpm_ClearSolnBusy (cy_stc_pdstack_context_t *ptrPdStackContext)
 Function to inform the Type-C/PD stack that the solution state allows Type-C transitions. More...
 
void Cy_PdStack_Dpm_SetSolnBusy (cy_stc_pdstack_context_t *ptrPdStackContext)
 Function to inform the Type-C/PD stack that the solution state does not allow Type-C transitions. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_ChangeEprActiveFlag (cy_stc_pdstack_context_t *ptrPdStackContext, bool flag)
 Function to change state of EPR mode active flag. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_IsEprModeActive (cy_stc_pdstack_context_t *ptrPdStackContext, bool *isActive)
 Function to check whether EPR mode is active. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_ChangeEprToSpr (cy_stc_pdstack_context_t *ptrPdStackContext, bool flag)
 Function changes the EPR to SPR indicator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_IsEprSpr (cy_stc_pdstack_context_t *ptrPdStackContext, bool *isSpr)
 Function checks whether the EPR pdo needs to limit it to SPR. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_IsEprAvsModeActive (cy_stc_pdstack_context_t *ptrPdStackContext, bool *isActive)
 Function to check whether EPR AVS mode is active. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_ChangeEprAvsActiveFlag (cy_stc_pdstack_context_t *ptrPdStackContext, bool flag)
 Function to change state of EPR AVS mode active flag. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_IsValidAvsReq (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t src_pdo_index, cy_pd_pd_do_t rdo)
 Function to change state of EPR AVS mode active flag. More...
 
void Cy_PdStack_Dpm_EprSnkSendKeepAliveCb (cy_timer_id_t id, void *ptrContext)
 Function callback to initiate Keep Alive message. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSnkMaxMin (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t count, uint16_t *max_min)
 Function to update the sink max/min current/power at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSnkCapMask (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t mask)
 Function to update the sink PDO mask at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSnkCap (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t count, cy_pd_pd_do_t *pdo)
 Function to update the sink PDOs at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSrcCapMask (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t mask)
 Function to update the source PDO mask at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSrcCap (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t count, cy_pd_pd_do_t *pdo)
 Function to update the source PDOs at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateEprSnkCap (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t count, cy_pd_pd_do_t *pdo)
 Function to update the EPR sink PDOs at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateEprSnkCapMask (cy_stc_pdstack_context_t *ptrPdStackContext, uint8_t mask)
 Function to update the EPR sink PDO mask at runtime thereby overriding the generated configuration by EZ-PD Configurator. More...
 
void cy_sw_timer_init (cy_stc_sw_timer_t *context, uint32_t sysClkFreq)
 This function initializes the software timer module. More...
 
bool cy_sw_timer_start (cy_stc_sw_timer_t *context, void *callbackContext, cy_timer_id_t id, uint16_t period, cy_cb_timer_t cb)
 Start a specific soft timer. More...
 
bool cy_sw_timer_start_wocb (cy_stc_sw_timer_t *context, cy_timer_id_t id, uint16_t period)
 Start a specific soft timer without providing a callback for expiry notification. More...
 
void cy_sw_timer_stop (cy_stc_sw_timer_t *context, cy_timer_id_t id)
 Stop a soft timer which is currently running. More...
 
bool cy_sw_timer_is_running (cy_stc_sw_timer_t *context, cy_timer_id_t id)
 Check whether the specified soft timer is currently running. More...
 
bool cy_sw_timer_range_enabled (cy_stc_sw_timer_t *context, cy_timer_id_t low, cy_timer_id_t high)
 Check whether the any of the soft timers in the specified range are currently running. More...
 
uint16_t cy_sw_timer_get_count (cy_stc_sw_timer_t *context, cy_timer_id_t id)
 Returns the time (in ms) remaining for timer expiration. More...
 
void cy_sw_timer_stop_all (cy_stc_sw_timer_t *context)
 Stops all active soft timers. More...
 
void cy_sw_timer_stop_range (cy_stc_sw_timer_t *context, cy_timer_id_t start, cy_timer_id_t end)
 This function stops all soft timers with ids in the specified range. More...
 
uint8_t cy_sw_timer_num_active (cy_stc_sw_timer_t *context)
 Returns number of active timers. More...
 
void cy_sw_timer_enter_sleep (cy_stc_sw_timer_t *context)
 This function prepares the timer module and the hardware timer for entering device deep sleep. More...
 
void cy_sw_timer_interrupt_handler (cy_stc_sw_timer_t *context)
 This function implements the interrupt handler callback used by the Soft Timer module, and is expected to be called by the application whenever the appropriate SysTick or WDT interrupt is received. More...
 
uint16_t cy_sw_timer_get_multiplier (cy_stc_sw_timer_t *context)
 This function retrieves the number of low frequency (LF) clock ticks required per ms. More...
 

Function Documentation

◆ Cy_PdStack_Dpm_Init()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Init ( cy_stc_pdstack_context_t ptrPdStackContext,
cy_stc_usbpd_context_t *  ptrUsbPdContext,
const cy_stc_pdstack_port_cfg_t ptrPortCfg,
cy_stc_pdstack_app_cbk_t ptrAppCbk,
const cy_stc_pdstack_dpm_params_t ptrDpmParams,
cy_stc_sw_timer_t ptrTimerContext 
)

This function initializes the device policy manager with callback pointers and loads the port configuration information from the port config table.

This function also initializes the PD policy engine and Type-C connection manager.

Parameters
ptrPdStackContextPdStack Library Context pointer.
ptrUsbPdContextUsbPd Driver Context pointer.
ptrPortCfgPort Configuration pointer.
ptrAppCbkApplication callback function pointer.
ptrDpmParamsPointer to the DPM parameter information structure.
ptrTimerContextPointer to soft timer context structure.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the input parameters are not valid

◆ Cy_PdStack_Dpm_Start()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Start ( cy_stc_pdstack_context_t ptrPdStackContext)

This function makes the specified USB Type-C port operational.

The port to be updated is specified by passing the PD Stack context corresponding to it.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer is invalid CY_PDSTACK_STAT_FAILURE if the operation fails.

◆ Cy_PdStack_Dpm_Stop()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Stop ( cy_stc_pdstack_context_t ptrPdStackContext)

This function stops the port operation.

The USBPD block corresponding to the port will be disabled.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer is invalid CY_PDSTACK_STAT_FAILURE if the operation fails.

◆ Cy_PdStack_Dpm_Disable()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Disable ( cy_stc_pdstack_context_t ptrPdStackContext)

This function disables the PD port operation and limits it to receiving hard reset signalling.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer is invalid CY_PDSTACK_STAT_FAILURE if the operation fails.

◆ Cy_PdStack_Dpm_PrepareDeepSleep()

cy_en_pdstack_status_t Cy_PdStack_Dpm_PrepareDeepSleep ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  ptrDeepSleep 
)

This function configures the PD policy manager and Type-C manager state machines to allow the PMG1 device to be placed in deep sleep.

If the state machines are not in a busy state, the USBPD block is configured to trigger a wake-up interrupt on any activity and the location pointed by ptrDeepSleep is set to true. If the state machines are busy, the location pointed by ptrDeepSleep is set to false to indicate that the PMG1 device shall not proceed into deep sleep.

Parameters
ptrPdStackContextPdStack Library Context pointer.
ptrDeepSleepOutput parameter contains true if deepsleep is possible and configured, otherwise false
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer or the ptrDeepSleep is invalid CY_PDSTACK_STAT_FAILURE if the operation fails.

◆ Cy_PdStack_Dpm_Resume()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Resume ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  ptrResume 
)

This function resumes the Type-C manager and PD policy engine state machines after the PMG1 device has woken up from deep sleep.

This function needs to be called to resume the stack operation if Cy_PdStack_Dpm_PrepareDeepSleep has previously been called and returned true. This needs to be done even if the PMG1 device did not actually go into deep sleep due to other reasons.

Parameters
ptrPdStackContextPdStack Library Context pointer.
ptrResumeOutput parameter contains true if successful otherwise false
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer or the ptrResume is invalid

◆ Cy_PdStack_Dpm_IsSleepAllowed()

cy_en_pdstack_status_t Cy_PdStack_Dpm_IsSleepAllowed ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  ptrSleepAllowed 
)

This function checks if the PD policy engine and Type-C manager state machines corresponding to the specified Type-C port are idle.

If this function indicates that the state machines are busy, deep sleep entry using the Cy_PdStack_Dpm_PrepareDeepSleep should not be attempted.

Parameters
ptrPdStackContextPdStack Library Context pointer.
ptrSleepAllowedOutput parameter contains true if possible to go into sleep mode, otherwise false
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer or the ptrSleepAllowed is invalid

◆ Cy_PdStack_Dpm_Rtos_Init()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Rtos_Init ( cy_stc_pdstack_context_t ptrPdStackContext,
cy_stc_pdstack_rtos_context_t ptrRtosContext 
)

This function initializes the device policy manager with RTOS context details.

Parameters
ptrPdStackContextPdStack Library Context pointer.
ptrRtosContextPointer to RTOS API's callback context
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the input parameters are not valid

◆ Cy_PdStack_Dpm_Task()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Task ( cy_stc_pdstack_context_t ptrPdStackContext)

This function runs the Type-C manager and PD policy manager tasks for the specified port.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context pointer is invalid

◆ Cy_PdStack_Dpm_SendPdCommand()

cy_en_pdstack_status_t Cy_PdStack_Dpm_SendPdCommand ( cy_stc_pdstack_context_t ptrPdStackContext,
cy_en_pdstack_dpm_pd_cmd_t  cmd,
cy_stc_pdstack_dpm_pd_cmd_buf_t ptrCmdBuf,
bool  isResp,
cy_pdstack_dpm_pd_cmd_cbk_t  cmdCbk 
)

This function provides an interface for the application module to send PD commands.

Parameters
ptrPdStackContextPdStack Library Context pointer.
cmdType of command to be initiated.
ptrCmdBufPointer to the command buffer.
isRespSet to true when the API is called to send a response to previously received PD messages.
cmdCbkPointer to the callback function.
Returns
CY_PDSTACK_STAT_SUCCESS if the command is registered CY_PDSTACK_STAT_CMD_FAILURE if the PD port is not ready for a command CY_PDSTACK_STAT_BUSY if there is another pending command. CY_PDSTACK_STAT_BAD_PARAM if any of the parameters are invalid

◆ Cy_PdStack_Dpm_SendTypecCommand()

cy_en_pdstack_status_t Cy_PdStack_Dpm_SendTypecCommand ( cy_stc_pdstack_context_t ptrPdStackContext,
cy_en_pdstack_dpm_typec_cmd_t  cmd,
cy_pdstack_dpm_typec_cmd_cbk_t  cmdCbk 
)

This function provides an interface for the application module to send commands to the Type-C connection manager.

Parameters
ptrPdStackContextPdStack Library Context pointer.
cmdType of command to be performed.
cmdCbkPointer to the callback function.
Returns
CY_PDSTACK_STAT_SUCCESS if the command is registered CY_PDSTACK_STAT_CMD_FAILURE if the PD port is not ready for a command CY_PDSTACK_STAT_BUSY if there is another pending command. CY_PDSTACK_STAT_BAD_PARAM if any of the parameters are invalid

◆ Cy_PdStack_Dpm_ProtReset()

cy_en_pdstack_status_t Cy_PdStack_Dpm_ProtReset ( cy_stc_pdstack_context_t ptrPdStackContext,
cy_en_pd_sop_t  sop 
)

This function resets PD protocol layer (transmit and receive) message ID counters for the specified PD packet type.

The message ID will be set to zero on the next PD message transmitted by PMG1. Message ID checks will not be performed for the next PD message of this type which is received by PMG1.

Parameters
ptrPdStackContextPdStack Library Context pointer.
sopPacket type (SOP, SOP' or SOP'')
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context parameter is or sop value is invalid

◆ Cy_PdStack_Dpm_ProtResetRx()

cy_en_pdstack_status_t Cy_PdStack_Dpm_ProtResetRx ( cy_stc_pdstack_context_t ptrPdStackContext,
cy_en_pd_sop_t  sop 
)

This function resets the PD receive message counter for the specified packet type.

This will cause the stack to skip checking for valid message ID on the next PD message of this type which is received.

Parameters
ptrPdStackContextPdStack Library Context pointer.
sopPacket type (SOP, SOP' or SOP'')
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context parameter or sop value is invalid

◆ Cy_PdStack_Dpm_PeStop()

cy_en_pdstack_status_t Cy_PdStack_Dpm_PeStop ( cy_stc_pdstack_context_t ptrPdStackContext)

This function stops the policy engine.

Used in a fault scenario where-in the USBPD communication needs to be stopped, but the Type-C manager needs to be active in order to detect detach of the faulty device.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful CY_PDSTACK_STAT_BAD_PARAM if the context parameter is invalid

◆ Cy_PdStack_Dpm_Pd3SrcRpFlowControl()

cy_en_pdstack_status_t Cy_PdStack_Dpm_Pd3SrcRpFlowControl ( cy_stc_pdstack_context_t ptrPdStackContext,
bool  blockSinkAms 
)

This function is used to specify whether we should keep the Rp termination at SinkTxNG or SinkTxOK while acting as a PD 3.0 source.

The PD policy engine has a default source implementation where it changes the Rp to SinkTxNG before sending any PD messages and reverts the Rp to SinkTxOK at the end of the AMS. This function can be used to speed up operation when initiating back-to-back AMS-es by preventing the Rp from being changed back to SinkTxOK after each AMS.

Parameters
ptrPdStackContextPdStack Library Context pointer.
blockSinkAmsIf true, Rp will be changed to SinkTxNG; if false, Rp will be changed to SinkTxOK.
Returns
CY_PDSTACK_STAT_SUCCESS if DUT is a PD 3.0 source CY_PDSTACK_STAT_CMD_FAILURE if DUT is not a PD 3.0 source. CY_PDSTACK_STAT_BAD_PARAM if the context parameter is invalid

◆ Cy_PdStack_Dpm_IsIdle()

cy_en_pdstack_status_t Cy_PdStack_Dpm_IsIdle ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  ptrIsIdle 
)

Function to check whether the Type-C/PD stack is idle.

Parameters
ptrPdStackContextPdStack Library Context pointer.
ptrIsIdleOutput parameter contains true if idle, false if any operations are pending on any port.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_ClearSolnBusy()

void Cy_PdStack_Dpm_ClearSolnBusy ( cy_stc_pdstack_context_t ptrPdStackContext)

Function to inform the Type-C/PD stack that the solution state allows Type-C transitions.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
None

◆ Cy_PdStack_Dpm_SetSolnBusy()

void Cy_PdStack_Dpm_SetSolnBusy ( cy_stc_pdstack_context_t ptrPdStackContext)

Function to inform the Type-C/PD stack that the solution state does not allow Type-C transitions.

Parameters
ptrPdStackContextPdStack Library Context pointer.
Returns
None

◆ Cy_PdStack_Dpm_ChangeEprActiveFlag()

cy_en_pdstack_status_t Cy_PdStack_Dpm_ChangeEprActiveFlag ( cy_stc_pdstack_context_t ptrPdStackContext,
bool  flag 
)

Function to change state of EPR mode active flag.

Parameters
ptrPdStackContextPdStack Library Context pointer.
flagsets/resets EPR active flag.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_IsEprModeActive()

cy_en_pdstack_status_t Cy_PdStack_Dpm_IsEprModeActive ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  isActive 
)

Function to check whether EPR mode is active.

Parameters
ptrPdStackContextPdStack Library Context pointer.
isActiveState of EPR flag
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_ChangeEprToSpr()

cy_en_pdstack_status_t Cy_PdStack_Dpm_ChangeEprToSpr ( cy_stc_pdstack_context_t ptrPdStackContext,
bool  flag 
)

Function changes the EPR to SPR indicator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
flagsets/resets EPR flag to limit PDO index.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_IsEprSpr()

cy_en_pdstack_status_t Cy_PdStack_Dpm_IsEprSpr ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  isSpr 
)

Function checks whether the EPR pdo needs to limit it to SPR.

Parameters
ptrPdStackContextPdStack Library Context pointer.
isSprWill contain true if eval pdo needs to limit pdo count to SPR otherwise false
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_IsEprAvsModeActive()

cy_en_pdstack_status_t Cy_PdStack_Dpm_IsEprAvsModeActive ( cy_stc_pdstack_context_t ptrPdStackContext,
bool *  isActive 
)

Function to check whether EPR AVS mode is active.

Parameters
ptrPdStackContextPdStack Library Context pointer.
isActiveState of EPR flag
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_ChangeEprAvsActiveFlag()

cy_en_pdstack_status_t Cy_PdStack_Dpm_ChangeEprAvsActiveFlag ( cy_stc_pdstack_context_t ptrPdStackContext,
bool  flag 
)

Function to change state of EPR AVS mode active flag.

Parameters
ptrPdStackContextPdStack Library Context pointer.
flagsets/resets EPR AVS active flag.
Returns
cy_en_pdstack_status_t

◆ Cy_PdStack_Dpm_IsValidAvsReq()

cy_en_pdstack_status_t Cy_PdStack_Dpm_IsValidAvsReq ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  src_pdo_index,
cy_pd_pd_do_t  rdo 
)

Function to change state of EPR AVS mode active flag.

Parameters
ptrPdStackContextPdStack Library Context pointer.
src_pdo_indexSRC PDO index.
rdoRequest Data Object received from port partner.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_EprSnkSendKeepAliveCb()

void Cy_PdStack_Dpm_EprSnkSendKeepAliveCb ( cy_timer_id_t  id,
void *  ptrContext 
)

Function callback to initiate Keep Alive message.

Parameters
idTimer index
ptrContextCallback context
Returns
None

◆ Cy_PdStack_Dpm_UpdateSnkMaxMin()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSnkMaxMin ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  count,
uint16_t *  max_min 
)

Function to update the sink max/min current/power at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
countNumber of PDOs
max_minPointer to max/min current/power array.
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful. CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_UpdateSnkCapMask()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSnkCapMask ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  mask 
)

Function to update the sink PDO mask at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
maskPDO mask
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful. CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_UpdateSnkCap()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSnkCap ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  count,
cy_pd_pd_do_t *  pdo 
)

Function to update the sink PDOs at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
countNumber of PDOs
pdoPointer to the PDO array
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful. CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_UpdateSrcCapMask()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSrcCapMask ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  mask 
)

Function to update the source PDO mask at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
maskPDO Mask
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_UpdateSrcCap()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateSrcCap ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  count,
cy_pd_pd_do_t *  pdo 
)

Function to update the source PDOs at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
countNumber of PDOs
pdoPointer to the PDO array
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_UpdateEprSnkCap()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateEprSnkCap ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  count,
cy_pd_pd_do_t *  pdo 
)

Function to update the EPR sink PDOs at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
countNumber of PDOs
pdoPointer to the PDO array
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ Cy_PdStack_Dpm_UpdateEprSnkCapMask()

cy_en_pdstack_status_t Cy_PdStack_Dpm_UpdateEprSnkCapMask ( cy_stc_pdstack_context_t ptrPdStackContext,
uint8_t  mask 
)

Function to update the EPR sink PDO mask at runtime thereby overriding the generated configuration by EZ-PD Configurator.

Parameters
ptrPdStackContextPdStack Library Context pointer.
maskPDO Mask
Returns
CY_PDSTACK_STAT_SUCCESS if operation is successful, CY_PDSTACK_STAT_BAD_PARAM if the parameters are invalid.

◆ cy_sw_timer_init()

void cy_sw_timer_init ( cy_stc_sw_timer_t context,
uint32_t  sysClkFreq 
)

This function initializes the software timer module.

This function initializes the data structures for timer management and enables the hardware timer used for the soft timer implementation.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
sysClkFreqSysClk frequency in MHz. This value is used to calibrate the watchdog timer.
Returns
None

◆ cy_sw_timer_start()

bool cy_sw_timer_start ( cy_stc_sw_timer_t context,
void *  callbackContext,
cy_timer_id_t  id,
uint16_t  period,
cy_cb_timer_t  cb 
)

Start a specific soft timer.

All soft timers are one-shot timers which will run until the specified period has elapsed. The timer expiration callback will be called at the end of the period, if one is provided.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
callbackContextPointer to the caller context.
idUnique timer id
periodTimer period in milliseconds.
cbTimer expiration callback. Can be NULL.
Returns
bool True if the timer is started, false if timer start fails.

All soft timers are one-shot timers which will run until the specified period has elapsed. The timer expiration callback will be called at the end of the period, if one is provided.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
callbackContextPointer to the caller context
idUnique timer id
periodTimer period in milliseconds.
cbTimer expiration callback. Can be NULL.
Returns
bool True if the timer is started, false if timer start fails.

◆ cy_sw_timer_start_wocb()

bool cy_sw_timer_start_wocb ( cy_stc_sw_timer_t context,
cy_timer_id_t  id,
uint16_t  period 
)

Start a specific soft timer without providing a callback for expiry notification.

The status of the timer (running or not) can be checked using the cy_sw_timer_is_running API.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
idUnique timer id
periodTimer period in milliseconds.
Returns
bool True if the timer is started, false if timer start fails.

Start a specific soft timer without providing a callback for expiry notification.

All soft timers are one-shot timers which will run until the specified period has elapsed.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
idUnique timer id
periodTimer period in milliseconds.
Returns
bool True if the timer is started, false if timer start fails.

◆ cy_sw_timer_stop()

void cy_sw_timer_stop ( cy_stc_sw_timer_t context,
cy_timer_id_t  id 
)

Stop a soft timer which is currently running.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
idUnique timer id
Returns
None

◆ cy_sw_timer_is_running()

bool cy_sw_timer_is_running ( cy_stc_sw_timer_t context,
cy_timer_id_t  id 
)

Check whether the specified soft timer is currently running.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
idUnique timer id
Returns
bool True if the timer is running, false otherwise.

◆ cy_sw_timer_range_enabled()

bool cy_sw_timer_range_enabled ( cy_stc_sw_timer_t context,
cy_timer_id_t  low,
cy_timer_id_t  high 
)

Check whether the any of the soft timers in the specified range are currently running.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
lowLowest soft timer ID to be checked.
highHighest soft timer ID to be checked.
Returns
bool True if the timers are running, false otherwise.

Check whether the any of the soft timers in the specified range are currently running.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
lowLowest soft timer ID to be checked.
highHighest soft timer ID to be checked.
Returns
bool True if the timers are running, false otherwise.

◆ cy_sw_timer_get_count()

uint16_t cy_sw_timer_get_count ( cy_stc_sw_timer_t context,
cy_timer_id_t  id 
)

Returns the time (in ms) remaining for timer expiration.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
idUnique timer id
Returns
Time remaining for expiration of the soft timer.

Returns the time (in ms) remaining for timer expiration.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
idUnique timer id
Returns
Time remaining for expiration of the soft timer.

◆ cy_sw_timer_stop_all()

void cy_sw_timer_stop_all ( cy_stc_sw_timer_t context)

Stops all active soft timers.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
None

Stops all active soft timers.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure..
Returns
None

◆ cy_sw_timer_stop_range()

void cy_sw_timer_stop_range ( cy_stc_sw_timer_t context,
cy_timer_id_t  start,
cy_timer_id_t  end 
)

This function stops all soft timers with ids in the specified range.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
startStarting timer ID. The value is inclusive.
endEnding timer ID. The value is inclusive.
Returns
None

◆ cy_sw_timer_num_active()

uint8_t cy_sw_timer_num_active ( cy_stc_sw_timer_t context)

Returns number of active timers.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
Number of Active Timers

◆ cy_sw_timer_enter_sleep()

void cy_sw_timer_enter_sleep ( cy_stc_sw_timer_t context)

This function prepares the timer module and the hardware timer for entering device deep sleep.

This must be called prior to entering deep sleep mode.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
None

◆ cy_sw_timer_interrupt_handler()

void cy_sw_timer_interrupt_handler ( cy_stc_sw_timer_t context)

This function implements the interrupt handler callback used by the Soft Timer module, and is expected to be called by the application whenever the appropriate SysTick or WDT interrupt is received.

This function scans all running timer instances and decrements their count as appropriate. If any of the timers has expired, it is stopped, de-allocated and the corresponding callback called (if not NULL). The timer can be restarted from the callback function if so desired.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
None

This function implements the interrupt handler callback used by the Soft Timer module, and is expected to be called by the application whenever the appropriate SysTick or WDT interrupt is received.

The ISR scans all running instances and decrements the count appropriately.

Timer ISR is called every 1ms (if not using Tickless implementation) or configured period if using tickless implementation. If there is any soft timer ON, in the ISR all active timer instances are decremented and then checked for timeouts. In case of timeout the timer is stopped and de-allocated. In case, a timer needs to be re-started, it can be done from the callback. On timer expire events are also raised here for various modules.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
None

◆ cy_sw_timer_get_multiplier()

uint16_t cy_sw_timer_get_multiplier ( cy_stc_sw_timer_t context)

This function retrieves the number of low frequency (LF) clock ticks required per ms.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
Returns the number of LF clock ticks per ms.

This function retrieves the number of low frequency (LF) clock ticks required per ms.

Parameters
contextThe pointer to the context structure cy_stc_sw_timer_t allocated by the user. The structure is used during the SW Timer operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
Returns the number of LF clock ticks per ms.