Skip to main content
Visitor II
March 24, 2025
Question

How to implement USB DPM, prevent hard reset

  • March 24, 2025
  • 1 reply
  • 699 views

I tried following STM32 AN5418 but the EvaluateSinkCapabilities method is not getting called. I added debug prints everywhere in the code and here is what I am receiving:

1. VBusInit (this always happens)

2. DPM notification 104 (Stack init)

3. Cable detection

4. Unimplemented SetDataInfo 8 (USBPD_CORE_EXTENDED_CAPA)

5. SetDataInfo 6 (USBPD_CORE_DATATYPE_RCV_REQ_PDO

- I haven't implemented anything in this, but I had it print out what it received and it looked good (e.g. 5V 3A 9V 3A 20V 5A etc.)

6. Notification: 30 (USBPD_NOTIFY_HARDRESET_RX)

7. Hard reset callback

8. Device turns off, turns on a few seconds later and goes through this same loop

What do I need to implement to get this working? Is this just because all of my methods are unimplemented besides EvaluateSinkCapabilities and one of the cases in GetDataInfo? At what point/do I call USBPD_DPM_RequestMessageRequest?

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    March 25, 2025

    Hi @Nv7 

    Would you describe your working environment? Would you attach your project? 

    USBPD_DPM_RequestMessageRequestfunction is used to send a power request to the source device based on the selected Source PDO and the prepared RDO. Check this example.

    Nv7Author
    Visitor II
    March 27, 2025

    https://github.com/TektiteBiz/charge2b Here is the code. It appears that RequestMessageRequest is unimplemented, as well as everything else. I am not sure how to implement these.

     

    Looking at the example it seems that it is unimplemented there too. (https://github.com/STMicroelectronics/STM32CubeG0/blob/fa3123ccb654f447d3738b86740fb869b2701ace/Projects/STM32G081B-EVAL/Applications/USB-PD/USB-PD_Consumer_1port/Src/usbpd_dpm_user.c#L535)

    USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
    {
     USBPD_StatusTypeDef _status = USBPD_ERROR;
    /* USER CODE BEGIN USBPD_DPM_RequestMessageRequest */
     /* To be adapted to call the PE function */
     /* _status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);*/
     DPM_USER_DEBUG_TRACE(PortNum, "HELP: update USBPD_DPM_RequestMessageRequest");
    /* USER CODE END USBPD_DPM_RequestMessageRequest */
     DPM_USER_ERROR_TRACE(PortNum, _status, "REQUEST not accepted by the stack");
     return _status;
    }