Skip to main content
Visitor II
October 22, 2019
Solved

How to send a Unstructured VDM in stm32g0?

  • October 22, 2019
  • 2 replies
  • 1357 views

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" ?

    This topic has been closed for replies.
    Best answer by Yohann M.

    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 */
    }

    2 replies

    Yohann M.Answer
    ST Employee
    October 22, 2019

    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 */
    }

    Visitor II
    January 22, 2025

    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 ???