License?
stwirth opened this issue · 4 comments
Hi @ardnew, nice work with this library!
I've been trying to find a driver for the ST4500 for an embedded Linux project and I found the official library from ST (https://github.com/usb-c/STUSB4500) hard to integrate/adapt to a non-ST platform.
Your library here seems much easier to port to embedded Linux.
I could not find any license information in the repo, could you clarify how your code can be used?
Thanks!
Hah, you're telling me – their code is actually what my library was based on, believe it or not. Theirs is extremely dense, with most of the high-level logic controlled implicitly with HAL hooks and event handlers. So good luck following it if you aren't familiar with their HAL. I had to use their IDE + debugger to trace execution path.
Aaaaanyway, I usually stick with the MIT license. Just added LICENSE
to the root of this repository.
Thanks for the feedback!
Thanks @ardnew!
FYI I'm also looking at https://github.com/sparkfun/SparkFun_STUSB4500_Arduino_Library which is MIT licensed as well.
I like your typedefs though but unfortunately I don't have the alert and attach pins connected on my board...
@stwirth You should know there is a major difference between this and the SparkFun library. Your choice of library to use should probably be based on these functional differences instead of which source code design is more appealing to you.
These differences may matter depending on how you plan to use the device: using fixed power profiles or using dynamic power profiles.
sparkfun/SparkFun_STUSB4500_Arduino_Library
Uses the device's integrated NVM for configuring PDOs, which implies the following:
- No microcontroller needs to remain connected to the device after its initial configuration.
- In this case the three (3) PDOs are static: one is required to be
{ +5V, 0.5–3.0A }
, so you really only have two (2) PDOs for a sink to choose from (in addition to the required+5V
standard). - You can always connect a microcontroller later if you wish to reconfigure PDOs.
- In this case the three (3) PDOs are static: one is required to be
- Modifying a PDO requires writing the new configuration to NVM and then resetting the device:
- Resetting the device will always disconnect the sink from
VBUS
temporarily:- The source will present
+5V
onVBUS
during initialization, but after "cable disconnect" messages are sent on the PD bus. - Depending on your device (oxplot breakout, SparkFun breakout, custom PCB, etc.), the
VBUS
power path may be gated behind a BJT/FET until negotiation completes, resulting in a very noticeable power cycle. - A bypass capacitor probably won't improve this because of the occasionally lengthy negotiation sequence.
- The source will present
- The device will read the new PDOs during initialization and negotiate a profile based on configured PDOs compared to source capabilities
- It is therefore impossible to analyze an arbitrary source's capabilities to select the best profile without causing an intermediate power cycle with your sink device
- Resetting the device will always disconnect the sink from
ardnew/STUSB4500
and ardnew/tinygo-stusb4500
Does not use the device's integrated NVM but configures the PDOs dynamically at run-time (RAM), which implies the following:
- Requires a microcontroller to remain connected to the device for managing PDO configurations:
- The PDO configurations are lost every time the device loses power. The microcontroller must reconfigure them.
- There is currently no NVM support, although this could be added in the future.
- There is effectively no limit on the number of PDOs that may be negotiated, since they can be reconfigured at run-time.
- The PDO configurations are lost every time the device loses power. The microcontroller must reconfigure them.
- Modifying a PDO and negotiating a new power profile does not require resetting the device:
- Transitioning from one power profile to another is transparent to the sink device. It is not subjected to power cycling.
- It is feasible (and practical) to write microcontroller firmware that can analyze available capabilities and negotiate an optimal power profile from an arbitrary PD source.
- For example, many commercial USB PD power supplies support the 5 standard voltages (
+5V
,+9V
,+12V
,+15V
,+20V
) with varying maximum currents (0.5A–5.0A
). These can be used to create a user-controllable variable power supply for a workbench.
- For example, many commercial USB PD power supplies support the 5 standard voltages (
Hope this clarifies some confusion and helps you choose an appropriate library for your project!