This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

USB-C VBUS

Overview

USB-C VBUS is the line in a USB Type-C connection that delivers power from a Source to a Sink device.

USB-C VBUS API

The USB-C VBUS device driver presents an API that’s used to control and measure VBUS.

Configuration Options

Related configuration options:

API Reference

group usbc_vbus_api

USB-C VBUS API.

Functions

static inline bool usbc_vbus_check_level(const struct device *dev, enum tc_vbus_level level)

Checks if VBUS is at a particular level.

Parameters:
  • dev – Runtime device structure

  • level – The level voltage to check against

Return values:
  • true – if VBUS is at the level voltage

  • false – if VBUS is not at that level voltage

static inline int usbc_vbus_measure(const struct device *dev, int *meas)

Reads and returns VBUS measured in mV.

Parameters:
  • dev – Runtime device structure

  • meas – pointer where the measured VBUS voltage is stored

Return values:
  • 0 – on success

  • -EIO – on failure

static inline int usbc_vbus_discharge(const struct device *dev, bool enable)

Controls a pin that discharges VBUS.

Parameters:
  • dev – Runtime device structure

  • enable – Discharge VBUS when true

Return values:
  • 0 – on success

  • -EIO – on failure

  • -ENOENT – if discharge pin isn’t defined

static inline int usbc_vbus_enable(const struct device *dev, bool enable)

Controls a pin that enables VBUS measurments.

Parameters:
  • dev – Runtime device structure

  • enable – enable VBUS measurments when true

Return values:
  • 0 – on success

  • -EIO – on failure

  • -ENOENT – if enable pin isn’t defined

struct usbc_vbus_driver_api
#include <usbc_vbus.h>