Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usbc_vbus.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 The Chromium OS Authors
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
14
15#ifndef ZEPHYR_INCLUDE_DRIVERS_USBC_VBUS_H_
16#define ZEPHYR_INCLUDE_DRIVERS_USBC_VBUS_H_
17
26
27#include <zephyr/types.h>
28#include <zephyr/device.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
40
44__subsystem struct usbc_vbus_driver_api {
46 bool (*check_level)(const struct device *dev, enum tc_vbus_level level);
48 int (*measure)(const struct device *dev, int *vbus_meas);
50 int (*discharge)(const struct device *dev, bool enable);
52 int (*enable)(const struct device *dev, bool enable);
53};
54
56
66static inline bool usbc_vbus_check_level(const struct device *dev, enum tc_vbus_level level)
67{
68 return DEVICE_API_GET(usbc_vbus, dev)->check_level(dev, level);
69}
70
80static inline int usbc_vbus_measure(const struct device *dev, int *meas)
81{
82 return DEVICE_API_GET(usbc_vbus, dev)->measure(dev, meas);
83}
84
95static inline int usbc_vbus_discharge(const struct device *dev, bool enable)
96{
97 return DEVICE_API_GET(usbc_vbus, dev)->discharge(dev, enable);
98}
99
110static inline int usbc_vbus_enable(const struct device *dev, bool enable)
111{
112 return DEVICE_API_GET(usbc_vbus, dev)->enable(dev, enable);
113}
114
118
119#ifdef __cplusplus
120}
121#endif
122
123#endif /* ZEPHYR_INCLUDE_DRIVERS_USBC_VBUS_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
tc_vbus_level
VBUS level voltages.
Definition usbc_tc.h:342
static int usbc_vbus_measure(const struct device *dev, int *meas)
Reads and returns VBUS measured in mV.
Definition usbc_vbus.h:80
static bool usbc_vbus_check_level(const struct device *dev, enum tc_vbus_level level)
Checks if VBUS is at a particular level.
Definition usbc_vbus.h:66
static int usbc_vbus_enable(const struct device *dev, bool enable)
Controls a pin that enables VBUS measurements.
Definition usbc_vbus.h:110
static int usbc_vbus_discharge(const struct device *dev, bool enable)
Controls a pin that discharges VBUS.
Definition usbc_vbus.h:95
#define bool
Definition stdbool.h:13
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> USB-C VBUS driver operations
Definition usbc_vbus.h:44
int(* discharge)(const struct device *dev, bool enable)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_vbus.h:50
int(* measure)(const struct device *dev, int *vbus_meas)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_vbus.h:48
int(* enable)(const struct device *dev, bool enable)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_vbus.h:52
bool(* check_level)(const struct device *dev, enum tc_vbus_level level)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_vbus.h:46
USB Type-C Cable and Connector API used for USB-C drivers.