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

USB EZ-PD™ Type-C Forum Discussions

TaAi_1278401
Level 1
Level 1
25 sign-ins 10 sign-ins 5 replies posted

I want to connect CY4531(DFP) and CY4531(UFP) and comunicate VDM custom command.

DFP side send following code. I refered to CCGx_FW_UserGuide.pdf
dpm_pd_command(port, DPM_CMD_SEND_VDM, &cmd_buf, pd_command_cb)


please tell me How to get VDM custom command at UFP?
Do I 'm able to use "dpm_get_info" command?
Please let me know if there is any reference document.

0 Likes
1 Solution
Sananya_14
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

As per A, please try adding your required UVDM handling code in eval_vdm() function. This will be called by the stack on receiving a VDM command as per the app_callback_ptr. The existing code handles the VDM commands and calls the vdm_resp_handler() so you could modify the response as per your requirement. For example:

if ((vdm->dat[VDM_HEADER_IDX].ustd_vdm_hdr.vdm_type == VDM_TYPE_UNSTRUCTURED) &&(vdm->dat[VDM_HEADER_IDX].ustd_vdm_hdr.cmd_type == CMD_TYPE_INITIATOR))
{

app_stat->vdm_resp.resp_buf[VDM_HEADER_IDX].val = vdm->dat[VDM_HEADER_IDX].val;

{
if (vdm->len == 1)
{
switch(vdm->dat[VDM_HEADER_IDX].ustd_vdm_hdr.cmd)
{
 case START_UVDM_COMMAND: //custom command 
 {
  app_stat->vdm_resp.resp_buf[0].val = 0xFF000000; //custom data

  app_stat-  >vdm_resp.resp_buf[VDM_HEADER_IDX].ustd_vdm_hdr.cmd_type = CMD_TYPE_RESP_ACK;
  }
break;

Best Regards,

Sananya

View solution in original post

4 Replies
Sananya_14
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

On the UFP side, the VDM command can be handled using the app callback from the stack on eval_vdm() function. Please refer to the vdm.c file in the CCG3 project and you can add your own handling of the commands, I'm assuming that you'll be sending UVDMs. You could also refer to the CCGx Host SDK API Guide for more details.

Best Regards,
Sananya

0 Likes

Hi, Sananya.
Thank you for your reply.

I checked eval_vdm() at vdm.c. and  CCGx_FW_API_Guide.pdf

But I don't fully understand your advice.

Which change should I make?

A,Should I add my operation code to the eval_vdm () code?

or

B,Should eval_vmd() be called at main.c  with  that replaced vdm_resp_handler with my operation code?

Are there sample code with eval_vmd() be used.

Best Regards

0 Likes
Sananya_14
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

As per A, please try adding your required UVDM handling code in eval_vdm() function. This will be called by the stack on receiving a VDM command as per the app_callback_ptr. The existing code handles the VDM commands and calls the vdm_resp_handler() so you could modify the response as per your requirement. For example:

if ((vdm->dat[VDM_HEADER_IDX].ustd_vdm_hdr.vdm_type == VDM_TYPE_UNSTRUCTURED) &&(vdm->dat[VDM_HEADER_IDX].ustd_vdm_hdr.cmd_type == CMD_TYPE_INITIATOR))
{

app_stat->vdm_resp.resp_buf[VDM_HEADER_IDX].val = vdm->dat[VDM_HEADER_IDX].val;

{
if (vdm->len == 1)
{
switch(vdm->dat[VDM_HEADER_IDX].ustd_vdm_hdr.cmd)
{
 case START_UVDM_COMMAND: //custom command 
 {
  app_stat->vdm_resp.resp_buf[0].val = 0xFF000000; //custom data

  app_stat-  >vdm_resp.resp_buf[VDM_HEADER_IDX].ustd_vdm_hdr.cmd_type = CMD_TYPE_RESP_ACK;
  }
break;

Best Regards,

Sananya

Hello, sananya.

Thank you for reply.

The question has been solved.

0 Likes