Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
25#include <zephyr/types.h>
26#include <zephyr/device.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
34 bool (*check_level)(const struct device *dev, enum tc_vbus_level level);
35 int (*measure)(const struct device *dev, int *vbus_meas);
36 int (*discharge)(const struct device *dev, bool enable);
37 int (*enable)(const struct device *dev, bool enable);
38};
39
49static inline bool usbc_vbus_check_level(const struct device *dev, enum tc_vbus_level level)
50{
51 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
52
53 return api->check_level(dev, level);
54}
55
65static inline int usbc_vbus_measure(const struct device *dev, int *meas)
66{
67 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
68
69 return api->measure(dev, meas);
70}
71
82static inline int usbc_vbus_discharge(const struct device *dev, bool enable)
83{
84 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
85
86 return api->discharge(dev, enable);
87}
88
99static inline int usbc_vbus_enable(const struct device *dev, bool enable)
100{
101 const struct usbc_vbus_driver_api *api = (const struct usbc_vbus_driver_api *)dev->api;
102
103 return api->enable(dev, enable);
104}
105
110#ifdef __cplusplus
111}
112#endif
113
114#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:65
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:49
static int usbc_vbus_enable(const struct device *dev, bool enable)
Controls a pin that enables VBUS measurments.
Definition: usbc_vbus.h:99
static int usbc_vbus_discharge(const struct device *dev, bool enable)
Controls a pin that discharges VBUS.
Definition: usbc_vbus.h:82
#define bool
Definition: stdbool.h:13
Runtime device structure (in ROM) per driver instance.
Definition: device.h:381
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:387
Definition: usbc_vbus.h:33
int(* discharge)(const struct device *dev, bool enable)
Definition: usbc_vbus.h:36
int(* measure)(const struct device *dev, int *vbus_meas)
Definition: usbc_vbus.h:35
int(* enable)(const struct device *dev, bool enable)
Definition: usbc_vbus.h:37
bool(* check_level)(const struct device *dev, enum tc_vbus_level level)
Definition: usbc_vbus.h:34
USB Type-C Cable and Connector API used for USB-C drivers.