Loading...
Searching...
No Matches
stusb4500.h
Go to the documentation of this file.
1
26#pragma once
27
28#include <stdint.h>
29
30namespace stusb4500 {
31
34
38struct Profile {
39 uint16_t millivolts;
40 uint16_t milliamps;
41};
42
44constexpr uint8_t kMaxProfiles = 3;
45
50bool begin();
51
58bool setProfiles(const Profile* profiles, uint8_t count);
59
65uint8_t getProfiles(Profile* out);
66
77uint8_t boardProfiles(uint16_t max_millivolts, Profile* out);
78
84
91
97
102uint32_t vbusMillivolts();
103
105
106} // namespace stusb4500
bool begin()
Sets up I2C1 and the control pins.
bool renegotiate()
Asks the charger to negotiate again with the current profiles.
uint8_t getProfiles(Profile *out)
Reads the active profiles.
uint8_t contractPosition()
Which charger offer is in use.
uint16_t contractMilliamps()
Operating current agreed in the current contract.
constexpr uint8_t kMaxProfiles
Number of profiles the chip holds.
Definition stusb4500.h:44
uint8_t boardProfiles(uint16_t max_millivolts, Profile *out)
The board's profiles for Tools > USB-PD Power.
bool setProfiles(const Profile *profiles, uint8_t count)
Loads 1-3 profiles and renegotiates if they differ from the current ones.
uint32_t vbusMillivolts()
VBUS measured by the on-board ADC (MAX11635 channel 3).
One sink profile (PDO): a voltage the board accepts and the current it draws.
Definition stusb4500.h:38
uint16_t milliamps
0-5000, 10 mA steps
Definition stusb4500.h:40
uint16_t millivolts
5000-20000, 50 mV steps
Definition stusb4500.h:39