CAT2 Peripheral Driver Library

Functions

void Cy_USBPD_Calc_Cabl_Gain (cy_stc_usbpd_context_t *context, uint32_t cur, uint8_t *gain_sel)
 Calculates cable gain. More...
 
void Cy_USBPD_CSA_Calc_Ref (cy_stc_usbpd_context_t *context, uint32_t cur_10mA, uint8_t gain, uint32_t *vref_sel, bool vin_rsense)
 Calculates Vref Voltage. More...
 
void Cy_USBPD_PFC_StopComp (cy_stc_usbpd_context_t *context)
 Disables PFC Comparator. More...
 
void Cy_USBPD_SR_StopComp (cy_stc_usbpd_context_t *context)
 Disables SR Comparator. More...
 
bool Cy_USBPD_PFC_SetComp (cy_stc_usbpd_context_t *context, uint32_t cur, cy_usbpd_vbus_filter_edge_detect_cfg_t edge, cy_pd_cmp_cbk_t cbk)
 Sets PFC Comparator. More...
 
bool Cy_USBPD_SR_SetComp (cy_stc_usbpd_context_t *context, uint32_t cur, cy_usbpd_vbus_filter_edge_detect_cfg_t edge, cy_pd_cmp_cbk_t cbk)
 Sets SR Comparator. More...
 
uint16_t Cy_USBPD_Hal_MeasureCur (cy_stc_usbpd_context_t *context)
 Sample the VBus current using ADC. More...
 
void Cy_USBPD_Hal_Disable_CV (cy_stc_usbpd_context_t *context)
 Disables CV. More...
 
void Cy_USBPD_Hal_Enable_CV (cy_stc_usbpd_context_t *context)
 Enables CV. More...
 
void Cy_USBPD_Hal_Set_Fb_Dac (cy_stc_usbpd_context_t *context, int16_t dac_value)
 Configure Feedback DAC control of device. More...
 
int16_t Cy_USBPD_Hal_Get_Fb_Dac (cy_stc_usbpd_context_t *context)
 Read Feedback DAC control of device. More...
 
uint8_t Cy_USBPD_Get_Silicon_Rev (cy_stc_usbpd_context_t *context)
 Function to get silicon revision. More...
 
bool Cy_USBPD_CF_GetStatus (cy_stc_usbpd_context_t *context)
 Retrieves the status of the CF mode hardware. More...
 
bool Cy_USBPD_PFC_CompSample (cy_stc_usbpd_context_t *context, uint32_t cur)
 Samples the PFC comparator. More...
 
void Cy_USBPD_LSCSA_Calc_Cfg (cy_stc_usbpd_context_t *context, uint32_t cur_10mA, uint8_t *gain_sel, uint32_t *vref_sel)
 Calculate the gain and reference settings for a specific current requirement. More...
 
cy_en_usbpd_status_t Cy_USBPD_LSCSA_Config (cy_stc_usbpd_context_t *context, cy_en_usbpd_vbus_lscsa_app_config_t lscsa_app, uint32_t gain_sel_value)
 Sets up LSCSA for specified application. More...
 
void Cy_USBPD_CF_Mon_Enable (cy_stc_usbpd_context_t *context, bool reset_state, cy_vbus_cf_cbk_t cbk)
 Enables hardware monitoring for VBus Current foldback on the specified port. More...
 
void Cy_USBPD_CF_Mon_Disable (cy_stc_usbpd_context_t *context)
 Disables hardware monitoring for VBus Current foldback on the specified port. More...
 
void Cy_USBPD_CF_Enable (cy_stc_usbpd_context_t *context, uint32_t cur)
 Enables VBus Current foldback on the specified port. More...
 
void Cy_USBPD_CF_Disable (cy_stc_usbpd_context_t *context)
 Disables hardware monitoring for VBus Current foldback on the specified port. More...
 
void Cy_USBPD_PFC_Intr1Handler (cy_stc_usbpd_context_t *context)
 PFC Interrupt handler. More...
 
void Cy_USBPD_SR_Intr1Handler (cy_stc_usbpd_context_t *context)
 SR Interrupt handler. More...
 
void Cy_USBPD_VBTR_Start (cy_stc_usbpd_context_t *context)
 This function triggers VBUS voltage transition. More...
 
void Cy_USBPD_VBTR_Config (cy_stc_usbpd_context_t *context, int16_t dac_cur, int16_t dac_req, cy_cb_adc_events_t vbtr_cb)
 This function does blocking Vbus transition to VSAFE_5V from lower iDAC setting to zero. More...
 
bool Cy_USBPD_VBTR_IsIdle (cy_stc_usbpd_context_t *context)
 Gets the current status of the VBTR module. More...
 
void Cy_USBPD_VBTR_SetIdac (cy_stc_usbpd_context_t *context, int16_t dac_req, cy_cb_adc_events_t vbtr_cb)
 Configures VBUS transition operation for the requested idac value. More...
 
void Cy_USBPD_VBTR_Abort (cy_stc_usbpd_context_t *context)
 Aborts the ongoing VBUS transition operation. More...
 
bool Cy_USBPD_IBTR_IsIdle (cy_stc_usbpd_context_t *context)
 Gets the current status of the IBTR module. More...
 
void Cy_USBPD_IBTR_Set (cy_stc_usbpd_context_t *context, uint16_t refgen_req, cy_cb_adc_events_t ibtr_cb)
 Configures VBUS current transition operation for the requested idac value. More...
 
void Cy_USBPD_IBTR_Abort (cy_stc_usbpd_context_t *context)
 Aborts the ongoing VBUS current transition operation. More...
 

Detailed Description

Function Documentation

◆ Cy_USBPD_Calc_Cabl_Gain()

void Cy_USBPD_Calc_Cabl_Gain ( cy_stc_usbpd_context_t context,
uint32_t  cur,
uint8_t *  gain_sel 
)

Calculates cable gain.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
curCurrent
gain_selCable gain

◆ Cy_USBPD_CSA_Calc_Ref()

void Cy_USBPD_CSA_Calc_Ref ( cy_stc_usbpd_context_t context,
uint32_t  cur_10mA,
uint8_t  gain,
uint32_t *  vref_sel,
bool  vin_rsense 
)

Calculates Vref Voltage.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
cur_10mACurrent
gainGain
vref_selVREF Voltage
vin_rsenseVIN Rsense

◆ Cy_USBPD_PFC_StopComp()

void Cy_USBPD_PFC_StopComp ( cy_stc_usbpd_context_t context)

Disables PFC Comparator.

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

◆ Cy_USBPD_SR_StopComp()

void Cy_USBPD_SR_StopComp ( cy_stc_usbpd_context_t context)

Disables SR Comparator.

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

◆ Cy_USBPD_PFC_SetComp()

bool Cy_USBPD_PFC_SetComp ( cy_stc_usbpd_context_t context,
uint32_t  cur,
cy_usbpd_vbus_filter_edge_detect_cfg_t  edge,
cy_pd_cmp_cbk_t  cbk 
)

Sets PFC Comparator.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
curCurrent
edgeEdge detection interrupt
cbkCallback
Returns
bool Returns true if PFC comparator is set

◆ Cy_USBPD_SR_SetComp()

bool Cy_USBPD_SR_SetComp ( cy_stc_usbpd_context_t context,
uint32_t  cur,
cy_usbpd_vbus_filter_edge_detect_cfg_t  edge,
cy_pd_cmp_cbk_t  cbk 
)

Sets SR Comparator.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
curCurrent
edgeEdge detection interrupt
cbkCallback
Returns
bool Returns true if SR comparator is set

◆ Cy_USBPD_Hal_MeasureCur()

uint16_t Cy_USBPD_Hal_MeasureCur ( cy_stc_usbpd_context_t context)

Sample the VBus current using ADC.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
uint16_t Returns sampled current

◆ Cy_USBPD_Hal_Disable_CV()

void Cy_USBPD_Hal_Disable_CV ( cy_stc_usbpd_context_t context)

Disables CV.

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

◆ Cy_USBPD_Hal_Enable_CV()

void Cy_USBPD_Hal_Enable_CV ( cy_stc_usbpd_context_t context)

Enables CV.

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

◆ Cy_USBPD_Hal_Set_Fb_Dac()

void Cy_USBPD_Hal_Set_Fb_Dac ( cy_stc_usbpd_context_t context,
int16_t  dac_value 
)

Configure Feedback DAC control of device.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
dac_valueSigned DAC value. Positive is sink and negative is source.

◆ Cy_USBPD_Hal_Get_Fb_Dac()

int16_t Cy_USBPD_Hal_Get_Fb_Dac ( cy_stc_usbpd_context_t context)

Read Feedback DAC control of device.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
int16_t Signed DAC value. Positive is sink and negative is source.

◆ Cy_USBPD_Get_Silicon_Rev()

uint8_t Cy_USBPD_Get_Silicon_Rev ( cy_stc_usbpd_context_t context)

Function to get silicon revision.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
uint8_t Silicon revision

◆ Cy_USBPD_CF_GetStatus()

bool Cy_USBPD_CF_GetStatus ( cy_stc_usbpd_context_t context)

Retrieves the status of the CF mode hardware.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
uint8_t Whether the hardware module is in CF mode or not.

◆ Cy_USBPD_PFC_CompSample()

bool Cy_USBPD_PFC_CompSample ( cy_stc_usbpd_context_t context,
uint32_t  cur 
)

Samples the PFC comparator.

The function samples against the requested current and restores the previous settings after sampling. This function is useful when the comparator is already configured for interrupt and needs to be multiplexed to sample at a different current.

Parameters
contextUSB-PD port context.
curOperating current in 10mA units.
Returns
bool State of the comparator on sampling.

Applicable devices: CCG3PA, CCG3PA2, PAG1S.

◆ Cy_USBPD_LSCSA_Calc_Cfg()

void Cy_USBPD_LSCSA_Calc_Cfg ( cy_stc_usbpd_context_t context,
uint32_t  cur_10mA,
uint8_t *  gain_sel,
uint32_t *  vref_sel 
)

Calculate the gain and reference settings for a specific current requirement.

This function eliminates the pre-calculated table.

Parameters
contextUSB-PD port context.
cur_10mACurrent setting in 10mA unit for which CSA setting is required.
gain_selPointer to variable where the gain setting code corresponding to the current setting needs to be stored.
vref_selPointer to variable where the voltage reference code corresponding to the current setting needs to be stored.
Returns
None

Applicable devices: CCG3PA, CCG3PA2, PAG1S.

◆ Cy_USBPD_LSCSA_Config()

cy_en_usbpd_status_t Cy_USBPD_LSCSA_Config ( cy_stc_usbpd_context_t context,
cy_en_usbpd_vbus_lscsa_app_config_t  lscsa_app,
uint32_t  gain_sel_value 
)

Sets up LSCSA for specified application.

Parameters
contextUSB-PD port context.
lscsa_appLSCSA application
gain_sel_valueGain selection code to be used
Returns
Status.

Applicable devices: CCG3PA, CCG3PA2, PAG1S.

◆ Cy_USBPD_CF_Mon_Enable()

void Cy_USBPD_CF_Mon_Enable ( cy_stc_usbpd_context_t context,
bool  reset_state,
cy_vbus_cf_cbk_t  cbk 
)

Enables hardware monitoring for VBus Current foldback on the specified port.

The function invokes the callback when a change happens from the current state. When the monitor is enabled, the calling function can specify the default state to allow for both high to low and low to high detection at enable. This avoids any race condition while enabling the monitoring. Monitoring should be enabled only when no VBUS transition is enabled.

Parameters
contextUSB-PD port context.
reset_stateCurrent CF state as expected by the calling function.
cbkFunction to be called when CF event is detected.

Applicable devices: PAG1S.

◆ Cy_USBPD_CF_Mon_Disable()

void Cy_USBPD_CF_Mon_Disable ( cy_stc_usbpd_context_t context)

Disables hardware monitoring for VBus Current foldback on the specified port.

Monitoring should be disabled when there is VBUS transition as well as when not in PPS mode operation.

Parameters
contextUSB-PD port context.

Applicable devices: PAG1S.

◆ Cy_USBPD_CF_Enable()

void Cy_USBPD_CF_Enable ( cy_stc_usbpd_context_t context,
uint32_t  cur 
)

Enables VBus Current foldback on the specified port.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
curOperating current in 10mA units.

◆ Cy_USBPD_CF_Disable()

void Cy_USBPD_CF_Disable ( cy_stc_usbpd_context_t context)

Disables hardware monitoring for VBus Current foldback on the specified port.

Monitoring should be disabled when there is VBUS transition as well as when not in PPS mode operation.

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

◆ Cy_USBPD_PFC_Intr1Handler()

void Cy_USBPD_PFC_Intr1Handler ( cy_stc_usbpd_context_t context)

PFC Interrupt handler.

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

◆ Cy_USBPD_SR_Intr1Handler()

void Cy_USBPD_SR_Intr1Handler ( cy_stc_usbpd_context_t context)

SR Interrupt handler.

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

◆ Cy_USBPD_VBTR_Start()

void Cy_USBPD_VBTR_Start ( cy_stc_usbpd_context_t context)

This function triggers VBUS voltage transition.

It expects that configuration has been done already.

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

◆ Cy_USBPD_VBTR_Config()

void Cy_USBPD_VBTR_Config ( cy_stc_usbpd_context_t context,
int16_t  dac_cur,
int16_t  dac_req,
cy_cb_adc_events_t  vbtr_cb 
)

This function does blocking Vbus transition to VSAFE_5V from lower iDAC setting to zero.

It assumes that the caller has already setup the iDAC to negative value. Calling the function with a positive iDAC setting shall result in EA being loaded directly to zero and CV mode disabled. If the VBUS is higher than 5V, the VBUS_IN safe voltage correction is expected to drop the voltage.

The function is expected to be called only during HAL start / stop functions and should not be invoked while in attached state.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
dac_curInitial signed iDAC value for VBUS voltage transition. Negative for source and positive for sink.
dac_reqFinal signed iDAC value for VBUS voltage transition. Negative for source and positive for sink.
vbtr_cbCallback to notify vbtr events

◆ Cy_USBPD_VBTR_IsIdle()

bool Cy_USBPD_VBTR_IsIdle ( cy_stc_usbpd_context_t context)

Gets the current status of the VBTR module.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
bool Idle state of the VBTR module. Returns False if VBTR Vbus voltage transition is in progress.

◆ Cy_USBPD_VBTR_SetIdac()

void Cy_USBPD_VBTR_SetIdac ( cy_stc_usbpd_context_t context,
int16_t  dac_req,
cy_cb_adc_events_t  vbtr_cb 
)

Configures VBUS transition operation for the requested idac value.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
dac_reqFinal signed iDAC value for VBUS voltage transition. Negative for source and positive for sink.
vbtr_cbCallback to notify vbtr events

◆ Cy_USBPD_VBTR_Abort()

void Cy_USBPD_VBTR_Abort ( cy_stc_usbpd_context_t context)

Aborts the ongoing VBUS transition operation.

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

◆ Cy_USBPD_IBTR_IsIdle()

bool Cy_USBPD_IBTR_IsIdle ( cy_stc_usbpd_context_t context)

Gets the current status of the IBTR module.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
Idle state of the IBTR module. Returns False if IBTR Vbus voltage transition is in progress.

◆ Cy_USBPD_IBTR_Set()

void Cy_USBPD_IBTR_Set ( cy_stc_usbpd_context_t context,
uint16_t  refgen_req,
cy_cb_adc_events_t  ibtr_cb 
)

Configures VBUS current transition operation for the requested idac value.

Parameters
contextThe pointer to the context structure cy_stc_usbpd_context_t allocated by the user. The structure is used during the USBPD operation for internal configuration and data retention. The user must not modify anything in this structure.
refgen_reqSigned iDAC value. Negative for source and positive for sink.
ibtr_cbCallback to notify IBTR events.

◆ Cy_USBPD_IBTR_Abort()

void Cy_USBPD_IBTR_Abort ( cy_stc_usbpd_context_t context)

Aborts the ongoing VBUS current transition operation.

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