cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the response after send a dr_swap request in stm32g0 usb pd development?

Gbang
Associate III

I sended a dr_swap request, and the target will response a ack/reject/wait.

I use the follow api to send dr_swap, and the target response a reject. However, this api just return USB_OK not USBPD_REJECT. And where I could get the response from the target?

yy = USBPD_PE_Request_CtrlMessage(port_num, USBPD_CONTROLMSG_DR_SWAP, USBPD_SOPTYPE_SOP);

1 ACCEPTED SOLUTION

Accepted Solutions
Yohann M.
ST Employee

All the request functions (like USBPD_DPM_RequestDataRoleSwap) will not trig directly the sent of the message to port partner. Idea is to post a request to the stack and when stack is ready, it will consume this request to send it to the port partner.

Only 1 request is possible. Another request sent whereas the previous one has not been consumed will be not taken in account (USBPD_BUSY status will be returned)

USBPD_BUSY is also returned if there are no connected port partners.

In your case, USBPD_OK from USBPD_DPM_RequestDataRoleSwap means than request has been posted to the stack.

Answer from port partner will be available in the different notifications received in the USBPD_DPM_Notification function and mainly:

  •  USBPD_NOTIFY_DATAROLESWAP_RECEIVED  = 35u,
  •  USBPD_NOTIFY_DATAROLESWAP_UFP    = 36u,
  •  USBPD_NOTIFY_DATAROLESWAP_DFP    = 37u,
  •  USBPD_NOTIFY_DATAROLESWAP_WAIT    = 38u,
  •  USBPD_NOTIFY_DATAROLESWAP_REJECTED  = 39u,
  •  USBPD_NOTIFY_DATAROLESWAP_NOT_SUPPORTED = 40u,

Please refer to message sequence chart available in UM2552, §4.4.1 Data role swap.

View solution in original post

1 REPLY 1
Yohann M.
ST Employee

All the request functions (like USBPD_DPM_RequestDataRoleSwap) will not trig directly the sent of the message to port partner. Idea is to post a request to the stack and when stack is ready, it will consume this request to send it to the port partner.

Only 1 request is possible. Another request sent whereas the previous one has not been consumed will be not taken in account (USBPD_BUSY status will be returned)

USBPD_BUSY is also returned if there are no connected port partners.

In your case, USBPD_OK from USBPD_DPM_RequestDataRoleSwap means than request has been posted to the stack.

Answer from port partner will be available in the different notifications received in the USBPD_DPM_Notification function and mainly:

  •  USBPD_NOTIFY_DATAROLESWAP_RECEIVED  = 35u,
  •  USBPD_NOTIFY_DATAROLESWAP_UFP    = 36u,
  •  USBPD_NOTIFY_DATAROLESWAP_DFP    = 37u,
  •  USBPD_NOTIFY_DATAROLESWAP_WAIT    = 38u,
  •  USBPD_NOTIFY_DATAROLESWAP_REJECTED  = 39u,
  •  USBPD_NOTIFY_DATAROLESWAP_NOT_SUPPORTED = 40u,

Please refer to message sequence chart available in UM2552, §4.4.1 Data role swap.