stusb4500: sink profiles, renegotiation and the current contract.
More...
|
|
constexpr uint8_t | stusb4500::kMaxProfiles = 3 |
| | Number of profiles the chip holds.
|
stusb4500: sink profiles, renegotiation and the current contract.
Needs #include <stusb4500.h>. See stusb4500.h for how the profiles work and the UsbPdPower.ino example.
◆ begin()
| bool stusb4500::begin |
( |
| ) |
|
Sets up I2C1 and the control pins.
- Returns
- true if the chip answers.
- Examples
- UsbPdPower.ino.
◆ boardProfiles()
| uint8_t stusb4500::boardProfiles |
( |
uint16_t | max_millivolts, |
|
|
Profile * | out ) |
The board's profiles for Tools > USB-PD Power.
5 V/2 A, then 9 V/1 A if max_millivolts >= 9000, then max_millivolts at 10 W (schematic limit) if it is above 9 V.
- Parameters
-
| max_millivolts | Highest voltage to ask for, or 0 for "use the chip's
stored settings". |
| out | Array with room for kMaxProfiles. |
- Returns
- Number of profiles written to out; 0 for max_millivolts 0.
- Examples
- UsbPdPower.ino.
◆ contractMilliamps()
| uint16_t stusb4500::contractMilliamps |
( |
| ) |
|
Operating current agreed in the current contract.
- Returns
- Current in mA; 0 = no contract.
- Examples
- UsbPdPower.ino.
◆ contractPosition()
| uint8_t stusb4500::contractPosition |
( |
| ) |
|
Which charger offer is in use.
- Returns
- Position 1-7 of the offer; 0 = no PD contract (plain 5 V USB, or no charger attached).
- Examples
- UsbPdPower.ino.
◆ getProfiles()
| uint8_t stusb4500::getProfiles |
( |
Profile * | out | ) |
|
Reads the active profiles.
- Parameters
-
| out | Array with room for kMaxProfiles. |
- Returns
- Number of profiles written to out.
- Examples
- UsbPdPower.ino.
◆ renegotiate()
| bool stusb4500::renegotiate |
( |
| ) |
|
Asks the charger to negotiate again with the current profiles.
- Returns
- false if begin() has not run or the chip does not answer.
◆ setProfiles()
| bool stusb4500::setProfiles |
( |
const Profile * | profiles, |
|
|
uint8_t | count ) |
Loads 1-3 profiles and renegotiates if they differ from the current ones.
- Parameters
-
| profiles | Profiles in priority order, lowest first; the first must be 5 V. |
| count | Number of profiles, 1 to kMaxProfiles. |
- Returns
- false if the arguments are invalid or the chip does not answer.
- Examples
- UsbPdPower.ino.
◆ vbusMillivolts()
| uint32_t stusb4500::vbusMillivolts |
( |
| ) |
|
VBUS measured by the on-board ADC (MAX11635 channel 3).
- Returns
- Voltage in mV.
- Examples
- UsbPdPower.ino.