cancel
Showing results for 
Search instead for 
Did you mean: 

How to send a Unstructured VDM in stm32g0?

Gbang
Associate III

I found senduvdm callback in usbpd_vdm_user,c "USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO)";

and just found one interface,USBPD_StatusTypeDef USBPD_PE_UVDM_RequestMessage (uint8_t PortNum, USBPD_SOPType_TypeDef SOPType ), which can't set my data,and how to send an uvdm package after call a "send interface" ?

1 ACCEPTED SOLUTION

Accepted Solutions
Yohann M.
ST Employee

Hello

Here is the associated Message Sequence Chart you can refer to:0690X00000AqfEwQAJ.png

To fill data, you have to complete the following callbacks functions in usbpd_vdm_user.c file:

/**
  * @brief  VDM Send Unstructured message callback
  * @param  PortNum    current port number
  * @param  pUVDM_Header  Pointer on UVDM header based on @ref USBPD_UVDMHeader_TypeDef
  * @param  pNbData       Pointer of number of VDO to send
  * @param  pVDO          Pointer of VDO to send
  * @retval None
  */
static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
{
/* USER CODE BEGIN USBPD_VDM_SendUVDM */
 
/* USER CODE END USBPD_VDM_SendUVDM */
}
 
/**
  * @brief  Unstructured VDM  message callback to inform user of reception of UVDM message
  * @param  PortNum    current port number
  * @param  UVDM_Header UVDM header based on @ref USBPD_UVDMHeader_TypeDef
  * @param  pNbData    Pointer of number of received VDO
  * @param  pVDO       Pointer of received VDO
  * @retval USBPD Status
  */
static USBPD_StatusTypeDef USBPD_VDM_ReceiveUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef UVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
{
/* USER CODE BEGIN USBPD_VDM_ReceiveUVDM */
  return USBPD_ERROR;
/* USER CODE END USBPD_VDM_ReceiveUVDM */
}

View solution in original post

2 REPLIES 2
Yohann M.
ST Employee

Hello

Here is the associated Message Sequence Chart you can refer to:0690X00000AqfEwQAJ.png

To fill data, you have to complete the following callbacks functions in usbpd_vdm_user.c file:

/**
  * @brief  VDM Send Unstructured message callback
  * @param  PortNum    current port number
  * @param  pUVDM_Header  Pointer on UVDM header based on @ref USBPD_UVDMHeader_TypeDef
  * @param  pNbData       Pointer of number of VDO to send
  * @param  pVDO          Pointer of VDO to send
  * @retval None
  */
static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
{
/* USER CODE BEGIN USBPD_VDM_SendUVDM */
 
/* USER CODE END USBPD_VDM_SendUVDM */
}
 
/**
  * @brief  Unstructured VDM  message callback to inform user of reception of UVDM message
  * @param  PortNum    current port number
  * @param  UVDM_Header UVDM header based on @ref USBPD_UVDMHeader_TypeDef
  * @param  pNbData    Pointer of number of received VDO
  * @param  pVDO       Pointer of received VDO
  * @retval USBPD Status
  */
static USBPD_StatusTypeDef USBPD_VDM_ReceiveUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef UVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
{
/* USER CODE BEGIN USBPD_VDM_ReceiveUVDM */
  return USBPD_ERROR;
/* USER CODE END USBPD_VDM_ReceiveUVDM */
}

DirkHo
Associate

Hello,
I have a strange problem sending UVDMs on G0B1RE.
I connected it with a G474RE using wires. The whole negotiation works. I got an explicit contract. Connecting the G474RE to a laptop charger does also work fine. I can set voltages and respond to Discover Identity VDMs from the laptop supply.
Now, I wanted to use UVDMS for "user defined features". The G474RE already sends a UVDM, the G01B1RE successfully receives it. Then I wanted to send another UVDM as resone from the G01B1RE.
I'm waiting for "USBPD_NOTIFY_STATE_SRC_READY" then call USBPD_PE_UVDM_RequestMessage(PortNum,USBPD_SOPTYPE_SOP);
The USBPD_VDM_SendUVDM is called. I can see the action in the log

39 PE 46601 0 PE_STATE_READY
40 NOTIF 46603 0 STATE_SRC_READY
41 PE 46603 0 PE_UVDM_REQ_MESSAGE
42 IN 46624 0 SOP s:002 H:0x0641 (id:3, DR:UFP, PR:SNK) GOODCRC
43 PE 46624 0 PE_STATE_READY

But no message is sent - WHY ???