Skip to main content
Visitor II
December 11, 2019
Question

How can I determine Source PDO capabilities?

  • December 11, 2019
  • 2 replies
  • 1541 views

I am developing an application using an STUSB4500 and an external MCU STM32G031K8 that should be able to read USB PD Source capabilities and allow the user to dynamically set custom PDOs.

I have based the majority of my code off of the example software package STSW-STUSB003.

According to that software, you determine Source capabilities by first sending a USB PD soft reset command (the USB Power Delivery command, not a STUSB4500 soft reset), int PdMessage_SoftReset() and int PdMessage_SoftReset_WithTimeout() in the firmware package, after which the Source will broadcast is capabilities:

 1. The STUSB4500 raises the ALRT line as expected after this PD command is sent

 2. I read the PRT_STATUS (0x16) register to verify a message is received

 3. I then read the RX_HEADER (0x31) register, unfortunately there are no docs on this register content

 4. So using the firmware package's definition (USBPD_MsgHeader_TypeDef), I am decoding the content of RX_HEADER

 5. At this point, regardless of what PD source I use (testing with Apple 60W PD charger), the reported number of PDOs in RX_HEADER is always 0

 6. The message type of these headers is either 0x3 (USBPD_CTRLMSG_Accept) or 0x6 (USBPD_CTRLMSG_PS_RDY)

I'm not sure if I am decoding the header incorrectly or if something else is wrong.

My full source code can be found here:

 https://github.com/ardnew/upd-touch/tree/alert-signal/Core/STUSB4500

My subroutine void stusb4500_alert(stusb4500_device_t *) in stusb4500_api.c corresponds to void ALARM_MANAGEMENT(uint8_t) in the STSW-STUSB003 package.

Any suggestions would be appreciated, thanks!

    This topic has been closed for replies.

    2 replies

    ardnewAuthor
    Visitor II
    December 11, 2019

    Disregard this question, the code is actually behaving as expected! My problem appears to be related to a timing issue, where halting with breakpoints in the debugger was causing Type-C or PD messages to be dropped.

    Not setting breakpoints during the PD negotiations was the fix.

    Visitor II
    January 18, 2020

    Hi,

    The Source PDOs are stored in the STUSB4500 buffer only for a short time.

    If the software is too slow to read these registers (for instance because of a breakpoint), then the buffer will be overwritten by upcoming messages, and you will lose the Source PDO information.