Loading...
Searching...
No Matches
stusb4500.h File Reference

Driver for the on-board STUSB4500 USB Power Delivery sink controller (U6). More...

#include <stdint.h>

Go to the source code of this file.

Classes

struct  stusb4500::Profile
 One sink profile (PDO): a voltage the board accepts and the current it draws. More...

Functions

bool stusb4500::begin ()
 Sets up I2C1 and the control pins.
bool stusb4500::setProfiles (const Profile *profiles, uint8_t count)
 Loads 1-3 profiles and renegotiates if they differ from the current ones.
uint8_t stusb4500::getProfiles (Profile *out)
 Reads the active profiles.
uint8_t stusb4500::boardProfiles (uint16_t max_millivolts, Profile *out)
 The board's profiles for Tools > USB-PD Power.
bool stusb4500::renegotiate ()
 Asks the charger to negotiate again with the current profiles.
uint8_t stusb4500::contractPosition ()
 Which charger offer is in use.
uint16_t stusb4500::contractMilliamps ()
 Operating current agreed in the current contract.
uint32_t stusb4500::vbusMillivolts ()
 VBUS measured by the on-board ADC (MAX11635 channel 3).

Variables

constexpr uint8_t stusb4500::kMaxProfiles = 3
 Number of profiles the chip holds.

Detailed Description

Driver for the on-board STUSB4500 USB Power Delivery sink controller (U6).

The STUSB4500 asks a USB-PD charger for the highest of up to three "sink profiles" (PDOs) that the charger can supply. initVariant() (variant.cpp) loads the board's default profiles at start-up; a sketch can change them:

#include <stusb4500.h>
const stusb4500::Profile profiles[] = {{5000, 2000}, {9000, 1000}};
bool setProfiles(const Profile *profiles, uint8_t count)
Loads 1-3 profiles and renegotiates if they differ from the current ones.
One sink profile (PDO): a voltage the board accepts and the current it draws.
Definition stusb4500.h:38
Driver for the on-board STUSB4500 USB Power Delivery sink controller (U6).

Profiles are written to the chip's working registers only, never to its NVM, so they last until the board loses power. Profile 1 must be 5 V (USB rule). Profile 3 has the highest priority, then 2, then 1.

VBUS also feeds the header's VIN pin, so VIN follows the contract. The chip negotiates from its NVM at plug-in, before any sketch runs; Phyduino boards have the NVM set to 5 V only (tests/sketches/usbpd_nvm, run once per board).

Bus: I2C1, address 0x28 (pins in pins_arduino.h, PHYDUINO_USBPD_*). It is separate from the Wire library's I2C0, so both can be used freely.