Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

CYPD3171_CLA: Identifying USB PD Sink device using VID/ PID combination in CCG3PA Power Adapter designs

lock attach
Attachments are accessible only for community members.

CYPD3171_CLA: Identifying USB PD Sink device using VID/ PID combination in CCG3PA Power Adapter designs

Pranava_YN
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

USB Power Delivery (USB PD) along with Type-C specification aims at providing Universal Charger functionality where multiple different devices requiring different voltages and currents can be charged using a single USB PD charger. Even though universality is a key feature of USB PD Chargers, some charger designs requires recognition of a particular sink connected to it.

Any USB PD capable device is recognized through the combination of its VID and PID. VID refers to Vendor ID, which is allotted by USB-IF. PID refers to Product ID which is fixed by vendor for a particular product. This VID and PID information can be obtained from the sink by sending “Discover Identity VDM” message. Sink in response to this VDM message sends Acknowledgement which includes VID and PID of the sink device.

 

Following is the code snippet to send Discover Identity VDM message after the completion of PD negotiation between source and sink. The PD port is disabled if VID and PID of sink doesn’t match the expected values (expected sink device).

CYPD3171-24LQXQ_CLA project from CCGx Power SDK is used to test the code functionality.

 

bool send_discover_id(uint8_t port)

{

/* Format the command parameters.

Single DO with standard Discover_ID command to SOP controller.

Timeout is set to 100 ms.

*/

ccg_status_t stat;

cmd_buf.cmd_sop = SOP;

cmd_buf.cmd_do[0].val = 0xFF008001;

cmd_buf.no_of_cmd_do = 1;

cmd_buf.timeout = 100u;

 

 

/* Initiate the command. Keep trying until accepted. */

while ((stat = dpm_pd_command(port, DPM_CMD_SEND_VDM,

    &cmd_buf, pd_command_cb)) != CCG_STAT_SUCCESS)

{

/* Can implement a timeout/abort here. */

if (abort_cmd)

return false;

}

/* Command has been queued. We cannot block for callback here. */

return true;

}

 

App event APP_EVT_PD_CONTRACT_NEGOTIATION_COMPLETE is triggered in app_event_handler function once the PD negotiation is complete. Discover Identity message is sent after negotiation complete event through a timer callback.

Attached to this post is the project which recognizes Ez-PD BCR as valid sink and turns the provider FET off when sinks other than BCR are connected. All changes to project are made in app.c file.

Attachments
0 Likes
1187 Views
Comments
lagr_4818041
Level 1
Level 1
First comment on KBA 5 sign-ins First reply posted

Hi Brother,

I used the attached code to try to get the VID and PID from my sink device, It is very useful for me, but I find a questions about it : Why do I call the send_discover_id(0) directly on the APP_EVT_PD_CONTRACT_NEGOTIATION_COMPLETE event, instead of  timmer, and the device will keep restarting ?PranavaY_81

Pranava_YN
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi,

firmware requires a small delay after negotiation complete to initiate Discover Identity command. Therefore timer was used to provide that delay and not stall the firmware execution. Also note that the main loop must be running continuously to successfully send VDM command.

Best regards,

Pranava

lagr_4818041
Level 1
Level 1
First comment on KBA 5 sign-ins First reply posted

Hi Brother,

     I  initiate Discover SVIDs command to the sink device after get VID and PID,but the CCG3PA will continuous restart if I call the dpm_pd_command API initiate CMD  directly instead of use timmer,I am difficult to understand about it. Is it because the dpm cannot be interfered with by the application while processing the PD protocol ?PranavaY_81

lagr_4818041
Level 1
Level 1
First comment on KBA 5 sign-ins First reply posted

Hi Pranava,

Any updates about it? I'm very concerned about the question.

Have a nice Christmas and New Year.

Best regards,

Cavin

Pranava_YN
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi Cavin,

Sorry for delay in response.

The example project posted here is customized just to detect EZ-PD BCR as sink device. That is probably the reason for the reset.

please check the following line in pd_command_cb() function in the project.

if(vid!= 0x4b4 || (pid!= 0x3176))           // VID and PID to detect Ez PD BCR

You can remove that "if" condition and try.

Best regards,

Pranava