Introduction

Documentation Status Build Status

CircuitPython driver for STUSB4500 USB Power Delivery board.

Implementation Notes

Based on SparkFun’s Arduino library. Further information and notes from the ST reference implementation. Python library and project structure inspired by Adafruit’s VEML7700 library, and Adafruit’s other such libraries.

Hardware

While this was developed for and tested with the SparkFun breakout, it likely works with any STUSB4500-based board which exposes I2C, including:

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

import board
import busio
import stusb4500

i2c = busio.I2C(board.SCL, board.SDA)
pd_board = stusb4500.STUSB4500(i2c)

print("Current PD Configuration:")
print("PDO Number: {}".format(pd_board.pdo_number))

for i in range(1, 4):
    print(
        "PDO{}: {}V (+{}%/-{}%), {}A".format(
            i,
            pd_board.get_voltage(i),
            pd_board.get_upper_voltage_limit(i),
            pd_board.get_lower_voltage_limit(i),
            pd_board.get_current(i)
        )
    )

print("Flex Current: {}".format(pd_board.flex_current))
print("External Power: {}".format(pd_board.external_power))
print("USB Communication Capable: {}".format(pd_board.usb_comm_capable))
print("Configuration OK GPIO: {}".format(pd_board.config_ok_gpio))
print("GPIO Control: {}".format(pd_board.gpio_ctrl))
print("Enable Power Only Above 5V: {}".format(pd_board.power_above_5v_only))
print("Request Source Current: {}".format(pd_board.req_src_current))
print("Factory Default: {}".format(pd_board.is_factory_defaults))

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Building

This library, along with dependencies and user code, can be too large to be useful on M0 boards like the Trinket M0. Built versions should show up once CI is configured and I’ve tagged a version, but for both your and my own development purposes I’m documenting how to just get an mpy file here.

You will need to install Adafruit’s mpy-cross compiler, either Adafruit’s built version or on macOS you can install via Homebrew by running brew install ticky/utilities/circuitpython.

Documentation

For information on building library documentation, please check out this guide.

Indices and tables