manuelbl / usb-pd-arduino

USB Power Delivery for Arduino
MIT License
57 stars 10 forks source link

Is this the only project that bit bangs USB PD + PPS? #16

Open gc-ss opened 3 months ago

gc-ss commented 3 months ago
  1. In case this project doesn't bitbang USB PD + PPS, please point out my misunderstanding

  2. What would be the disadvantage of this project vs. an out of box implementation that uses a PHY like FUSB302x? To me, a tremendous advantage of this project seems to be that we can take a cheap, easy to purchase and source Blue/Black pill, a dual comparator, resistors and have a USB PD + PPS trigger and analyzer ready to go - but I would like to know my blind spots and know what I'm missing

There also seems to be some PPS implementation but unsure about the level of PPS support:

https://github.com/manuelbl/usb-pd-arduino/blob/main/src/PDSink.cpp#L182

For example:

  1. Can the code currently request any voltage and current level from a PPS compliant charger?
  2. If so, is there some sample code that demo's that capability?

It seems like this is the only project that bit bangs USB PD + PPS - but if you are aware of similar projects, can you share here?

manuelbl commented 3 months ago

This project supports different STM32 MCUs with different degree of bit-banging. The F1/F4 families certainly use it. The G4/G0 family has built-in PD peripherals and doesn't need it. The reception is as important. Depending on the MCU family is uses ADCs, built-in comparators or the built-in USB PD peripheral.

This software solution (especially for the non-G4/G0 family) is quite involved. It uses multiple peripherals (timers, ADCs, SPI), many pins and almost exclusively works in interrupt handles to achieve USB PD communication. It requires a considerable part of your MCUs CPU time and you cannot disable interrupts. If this is no problem for your design, then this solution is likely lower cost than a dedicated external part.

Note that the protocol analyzer built with the comparators shared between CC1 and CC2 does not work in all cases (see https://github.com/manuelbl/usb-pd-arduino/issues/5#issuecomment-1687063224). For a trigger board, it's no issue however since either CC1 or CC2 is physically connected at any time.

The code allows to request any voltage from a PPS charger. PDSink.requestPower() fully covers this, including re-requesting it every 10s as required by the specification.

There is no specific demo for it. Just modify the TriggerBoard example by requesting a voltage that can only be delivered by PPS, such as 11V.

I remember having seen projects both from Google and STM that bit bang USB PD. But I don't remember if it included PPS as well.