https://github.com/ticky/circuitpython_stusb4500
CircuitPython driver for STUSB4500 USB Power Delivery board
https://github.com/ticky/circuitpython_stusb4500
Last synced: about 1 year ago
JSON representation
CircuitPython driver for STUSB4500 USB Power Delivery board
- Host: GitHub
- URL: https://github.com/ticky/circuitpython_stusb4500
- Owner: ticky
- License: mit
- Created: 2020-09-27T05:06:58.000Z (almost 6 years ago)
- Default Branch: develop
- Last Pushed: 2020-10-01T04:58:41.000Z (over 5 years ago)
- Last Synced: 2025-05-08T04:51:51.749Z (about 1 year ago)
- Language: Python
- Homepage: https://circuitpython-stusb4500.readthedocs.io/
- Size: 92.8 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Introduction
============
.. image:: https://readthedocs.org/projects/circuitpython-stusb4500/badge/?version=latest
:target: https://circuitpython-stusb4500.readthedocs.io/
:alt: Documentation Status
.. image:: https://github.com/ticky/CircuitPython_STUSB4500/workflows/Build%20CI/badge.svg
:target: https://github.com/ticky/CircuitPython_STUSB4500/actions
:alt: 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
--------
* `SparkFun STUSB4500 `_
While this was developed for and tested with the SparkFun breakout, it likely works with any STUSB4500-based board which exposes I2C, including:
* `USB C PD Sink by ketszim `_
* `STMicroelectronics EVAL-SCS001V1 `_
Dependencies
============
This driver depends on:
* `Adafruit CircuitPython `_
* `Bus Device `_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle `_.
Usage Example
=============
.. code-block:: python
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 `_.