2021-08-27 01:53 PM
I'm trying to send and receive Unstructured Vendor Defined Messages with the ST USB-PD stack but there is very little information in the documentation about the API.
I have found that I need to call USBPD_PE_UVDM_RequestMessage after which the stack will fire the USBPD_VDM_SendUVDM callback. However, the stack usually calls this function more than once, and it's not clear how to send more than 1 VDO.
Am I supposed to copy all of the data to the address given by pVDO or only copy 1 VDO each time the function is called? What is the maximum number of VDOs that I can send? Why does the stack call this function more than once when I can see on a PD traffic analyzer that only 1 message is sent over the wire?
Is there some document or example that actually explains how to use UVDMs? It seems like VDMs are mostly just used to enable DisplayPort support. I need to send small arbitrary messages between several boards connected with USB-PD.
@Yohann M.
I stripped out the function params on the initial question while trying to actually get it to submit, so here are the complete calls.
This function starts the process of sending a message: USBPD_PE_UVDM_RequestMessage(USBPD_PWR_TYPE_C_PORT_1, USBPD_SOPTYPE_SOP) .
This function is called by the stack multiple times afterward:
static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO).
Thanks,
Nathan
Solved! Go to Solution.
2021-08-30 12:34 AM
Dear @NathanWolcott
Please find the associated Message Sequence Chart:
Link to collision avoidance in PD3.0, there is a delay in the stack before really sending the UVDM message. It is why the callback is called several times.
Before sending a new message to UVDM, you should wait for notifications of the stack that you are in ready state (notification 'USBPD_NOTIFY_STATE_SRC_READY').
Maximum of VDO for a UVDM message is set to 7 (1 UVDM header + 6 other VDO).
Then maximum size of pVDO is 6. pNbData is this number.
Regards,
Yohann
2021-08-30 12:34 AM
Dear @NathanWolcott
Please find the associated Message Sequence Chart:
Link to collision avoidance in PD3.0, there is a delay in the stack before really sending the UVDM message. It is why the callback is called several times.
Before sending a new message to UVDM, you should wait for notifications of the stack that you are in ready state (notification 'USBPD_NOTIFY_STATE_SRC_READY').
Maximum of VDO for a UVDM message is set to 7 (1 UVDM header + 6 other VDO).
Then maximum size of pVDO is 6. pNbData is this number.
Regards,
Yohann
2021-09-02 10:30 AM
Hi @Yohann M.
Your information is working well for sending UVDMs but now I'm trying to receive them. I assumed that the USBPD_VDM_ReceiveUVDM() function would be called by the stack and have placed a print in there, and also a breakpoint but it never fires.
I know the message has been sent (I'm sending from the source port and receiving on the sink port and I can see the message on an analyzer). I'm getting the USBPD_NOTIFY_STATE_SRC_READY notification for the sending port and I also get a USBPD_NOTIFY_STATE_SNK_READY from the receiving port, which I assume means that it got the packet.
I also get a USBPD_NOTIFY_MSG_NOT_SUPPORTED notification on the sending port, which I assume the receiving port is sending automatically.
Is there some setting I need to enable to let the stack call the USBPD_VDM_ReceiveUVDM() function when it gets a message?
Thanks,
Nathan
2021-09-02 11:20 PM
Hi @NathanWolcott
Did you enable the flag 'PE_VDMSupport' to USBPD_TRUE in your DPM_Settings variable (usbpd_dpm_conf.h)?
Regards,
Yohann
2021-09-03 08:40 AM
Good morning @Yohann M.
Yes, PE_VDMSupport is set to true for both ports, however, it turned out that USBPD_VDM_UserInit was only called for port 0 and not port 1. Once I added the init call for the second port in USBPD_DPM_UserInit I started getting my prints in USBPD_VDM_ReceiveUVDM.
It looks like I must have generated the code once with only 1 port enabled, and since the call to USBPD_VDM_UserInit is inside a /* USER CODE BEGIN USBPD_DPM_UserInit */ block in USBPD_DPM_UserInit, when I enabled the second port, CubeMX didn't add the port's initialization call.
Thanks for the help,
Nathan