Zephyr API 3.6.99
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
15#ifndef ZEPHYR_INCLUDE_DRIVERS_USBC_VBUS_H_
16#define ZEPHYR_INCLUDE_DRIVERS_USBC_VBUS_H_
17
27#include <zephyr/types.h>
28#include <zephyr/device.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35__subsystem struct usbc_vbus_driver_api {
36 bool (*check_level)(const struct device *dev, enum tc_vbus_level level);
37 int (*measure)(const struct device *dev, int *vbus_meas);
38 int (*discharge)(const struct device *dev, bool enable);
39 int (*enable)(const struct device *dev, bool enable);
40};
41
51static inline bool usbc_vbus_check_level(const struct device *dev, enum tc_vbus_level level)
52{
53 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
54
55 return api->check_level(dev, level);
56}
57
67static inline int usbc_vbus_measure(const struct device *dev, int *meas)
68{
69 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
70
71 return api->measure(dev, meas);
72}
73
84static inline int usbc_vbus_discharge(const struct device *dev, bool enable)
85{
86 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
87
88 return api->discharge(dev, enable);
89}
90
101static inline int usbc_vbus_enable(const struct device *dev, bool enable)
102{
103 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
104
105 return api->enable(dev, enable);
106}
107
112#ifdef __cplusplus
113}
114#endif
115
116#endif /* ZEPHYR_INCLUDE_DRIVERS_USBC_VBUS_H_ */
tc_vbus_level
VBUS level voltages.
Definition usbc_tc.h:326
static int usbc_vbus_measure(const struct device *dev, int *meas)
Reads and returns VBUS measured in mV.
Definition usbc_vbus.h:67
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:51
static int usbc_vbus_enable(const struct device *dev, bool enable)
Controls a pin that enables VBUS measurements.
Definition usbc_vbus.h:101
static int usbc_vbus_discharge(const struct device *dev, bool enable)
Controls a pin that discharges VBUS.
Definition usbc_vbus.h:84
#define bool
Definition stdbool.h:13
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409
Definition usbc_vbus.h:35
int(* discharge)(const struct device *dev, bool enable)
Definition usbc_vbus.h:38
int(* measure)(const struct device *dev, int *vbus_meas)
Definition usbc_vbus.h:37
int(* enable)(const struct device *dev, bool enable)
Definition usbc_vbus.h:39
bool(* check_level)(const struct device *dev, enum tc_vbus_level level)
Definition usbc_vbus.h:36
USB Type-C Cable and Connector API used for USB-C drivers.