- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I add the two commands (bold in below) in function "dock_port_type_role_monitor()" called by while(1) in main(). the 1st command is to turn on a MOSFET switch and the 2nd to send a PR_SWAP command to a Samsung phone in the USB-C connector.
After Samsung plugged I found the 1st command works but the 2nd command does not. The Samsung is not changed to being charged. Could you tell me why and how to make it work?
The dock_port_type_role_monitor() is posted by LisaZ_26 in the previous post in the forum. The main.c is at attached.
void dock_port_type_role_monitor()
{
const dpm_status_t* dpm_stat = dpm_get_info(0);
if(!(dpm_stat->attach))
{
dock_port_monitor_state = 0;
}
switch(dock_port_monitor_state)
{
case 0:
if((dpm_stat->attach) && (dpm_stat->contract_exist)){
dock_port_monitor_state = 1;
ds_flag = 0;
ps_flag = 0;
}
break;
case 1:
if(!timer_is_running(0,PORT_CHG_RETRY_TMR)){
if((dpm_stat->cur_port_role == PRT_ROLE_SINK) && (ps_flag < 3))
{
if(dpm_pd_command(0,DPM_CMD_SEND_PR_SWAP,NULL,ps_cbk) != CCG_STAT_SUCCESS)
{
timer_start(0,PORT_CHG_RETRY_TMR,PORT_CHG_RETRY_TMR_PERIOD,NULL);
}
}
if((dpm_stat->cur_port_type == PRT_TYPE_DFP) && (ds_flag < 3))
{
if(dpm_pd_command(0,DPM_CMD_SEND_DR_SWAP,NULL,ds_cbk) != CCG_STAT_SUCCESS)
{
timer_start(0,PORT_CHG_RETRY_TMR,PORT_CHG_RETRY_TMR_PERIOD,NULL);
}
}
}
USB_SWITCH_CTRL_Write(0);
CyDelayUs(100);
// pd_prot_send_ctrl_msg(0,SOP,CTRL_MSG_PR_SWAP);
dpm_pd_command (TYPEC_PORT_0_IDX, DPM_CMD_SEND_PR_SWAP, NULL, NULL);
CyDelayUs(100);
break;
}
}
Thanks,
Derong Yuan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Derong,
Why you add
dpm_pd_command (TYPEC_PORT_0_IDX, DPM_CMD_SEND_PR_SWAP, NULL, NULL);
in case 1?
This will let CCG3 send PR_SWAP always in the while (1) loop and block the PD stack. This is not good way to test PR_SWAP.
You should add UART debug (Refer threads: How to debug cypd3135 in cy4531? ) to debug your code step by step. The files you are referring is working well on my project to initial PR_SWAP and DR_SWAP when the case is not the one I am looking for (I am looking for Power source and Data device role.)..
Best Regards,
Lisa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Derong,
Why you add
dpm_pd_command (TYPEC_PORT_0_IDX, DPM_CMD_SEND_PR_SWAP, NULL, NULL);
in case 1?
This will let CCG3 send PR_SWAP always in the while (1) loop and block the PD stack. This is not good way to test PR_SWAP.
You should add UART debug (Refer threads: How to debug cypd3135 in cy4531? ) to debug your code step by step. The files you are referring is working well on my project to initial PR_SWAP and DR_SWAP when the case is not the one I am looking for (I am looking for Power source and Data device role.)..
Best Regards,
Lisa