Driver for the on-board STUSB4500 USB-PD sink controller (U6).
More...
|
| | profiles (self) |
| | Gets the current active profiles.
|
| | set_profiles (self, profiles) |
| | Loads power profiles 1-3 and initiates a renegotiates.
|
| | request (self, max_volts) |
| | Request renegotiation from USB-PD charger for a voltage up to max_volts.
|
| | renegotiate (self) |
| | Instructs the STUSB4550 IC renegotiate with the USB-PD charger with the current power profiles.
|
| | contract_position (self) |
| | Gets with power profile is being used after negotiation with USB-PD charger.
|
| | contract (self) |
| | Reports which power profile was accepted and its current values.
|
|
|
int | MAX_PROFILES = 3 |
| | Number of profiles the chip holds.
|
Driver for the on-board STUSB4500 USB-PD sink controller (U6).
The STUSB4500 IC negotiates with USB-PD charger for the highest of up to three profiles (volts, amps) that the charger can supply. Profiles are written to the STUSB4500 IC working registers only, never its NVM registers, so they last until the board loses power. Whatever is negotiated also appears on the VIN pin. Use usb_pd() to get the board's instance rather than making another.
- Note
- Making the object raises OSError if the chip does not answer within 50 ms, or another device is at its address.
- Example
usb = mcu.usb_pd()
usb.request(9)
print(usb.contract())
◆ profiles()
Gets the current active profiles.
- Returns
- A list of (volts, amps), lowest priority first.
- Exceptions
-
| OSError | The chip did not respond. |
◆ set_profiles()
| set_profiles |
( |
| self, |
|
|
| profiles ) |
Loads power profiles 1-3 and initiates a renegotiates.
The first power profile must be 5 V (USB-PD specification rule). Each must be between 5V and 20 V (50 mV steps), and the current maximum is 5 A (10 mA steps) and at most 10 W (the board's limit). The last profile has the highest priority.
- Parameters
-
| profiles | A list of (volts, amps), e.g. [(5, 2), (9, 1)]. |
- Exceptions
-
| ValueError | A profile is out of range, or the first is not 5 V. |
| OSError | The chip did not respond. |
◆ request()
| request |
( |
| self, |
|
|
| max_volts ) |
Request renegotiation from USB-PD charger for a voltage up to max_volts.
The charger is offered these profiles and picks the highest it can supply:
- 5 V at 2 A, always.
- 9 V at 1 A, if max_volts is 9 or more.
- max_volts at 10 W, if max_volts is more than 9.
There is nothing between 5 V and 9 V, so request(7) gives 5 V.
- Parameters
-
| max_volts | Highest voltage to ask for, 5-20 (e.g. 5, 9, 12, 15 or 20). |
- Exceptions
-
| ValueError | max_volts is above 20 V. |
| OSError | The chip did not respond. |
◆ renegotiate()
Instructs the STUSB4550 IC renegotiate with the USB-PD charger with the current power profiles.
- Exceptions
-
| OSError | The chip did not respond. |
◆ contract_position()
| contract_position |
( |
| self | ) |
|
Gets with power profile is being used after negotiation with USB-PD charger.
- Returns
- 1-7; 0 means no PD contract (a plain USB port or charger).
- Exceptions
-
| OSError | The chip did not respond. |
◆ contract()
Reports which power profile was accepted and its current values.
The STUSB4500 reports which offered power profile was accepted but not its voltage, so the voltage is measured (vbus_volts()).
- Returns
- (volts, amps); amps is 0 when there is no PD contract.
- Exceptions
-
| OSError | The chip or the external ADC did not respond. |
The documentation for this class was generated from the following file: