12#ifndef ZEPHYR_INCLUDE_DRIVERS_USB_USB_BC12_H_
13#define ZEPHYR_INCLUDE_DRIVERS_USB_USB_BC12_H_
36#define BC12_CHARGER_VOLTAGE_UV 5000 * 1000
48#define BC12_CHARGER_MIN_CURR_UA 2500
50#define BC12_CHARGER_MAX_CURR_UA 1500 * 1000
61#define BC12_CURR_UA(val) CLAMP(val, BC12_CHARGER_MIN_CURR_UA, BC12_CHARGER_MAX_CURR_UA)
141__subsystem
struct bc12_driver_api {
160static inline int z_impl_bc12_set_role(
const struct device *dev,
enum bc12_role role)
162 const struct bc12_driver_api *api = (
const struct bc12_driver_api *)dev->
api;
164 return api->set_role(dev, role);
182 const struct bc12_driver_api *api = (
const struct bc12_driver_api *)dev->
api;
184 return api->set_result_cb(dev, cb, user_data);
195#include <zephyr/syscalls/usb_bc12.h>
bc12_role
BC1.2 device role.
Definition usb_bc12.h:65
int bc12_set_result_cb(const struct device *dev, bc12_callback_t cb, void *user_data)
Register a callback for BC1.2 results.
int bc12_set_role(const struct device *dev, enum bc12_role role)
Set the BC1.2 role.
bc12_type
BC1.2 charging partner type.
Definition usb_bc12.h:72
void(* bc12_callback_t)(const struct device *dev, struct bc12_partner_state *state, void *user_data)
BC1.2 callback for charger configuration.
Definition usb_bc12.h:133
@ BC12_CHARGING_PORT
BC1.2 device is a charging port.
Definition usb_bc12.h:68
@ BC12_DISCONNECTED
No BC1.2 device connected.
Definition usb_bc12.h:66
@ BC12_PORTABLE_DEVICE
BC1.2 device is a portable device.
Definition usb_bc12.h:67
@ BC12_TYPE_PROPRIETARY
Proprietary charging port.
Definition usb_bc12.h:82
@ BC12_TYPE_UNKNOWN
Unknown charging port, BC1.2 detection failed.
Definition usb_bc12.h:84
@ BC12_TYPE_CDP
Charging Downstream Port.
Definition usb_bc12.h:80
@ BC12_TYPE_SDP
Standard Downstream Port.
Definition usb_bc12.h:76
@ BC12_TYPE_NONE
No partner connected.
Definition usb_bc12.h:74
@ BC12_TYPE_COUNT
Count of valid BC12 types.
Definition usb_bc12.h:86
@ BC12_TYPE_DCP
Dedicated Charging Port.
Definition usb_bc12.h:78
state
Definition parser_state.h:29
BC1.2 detected partner state.
Definition usb_bc12.h:92
int voltage_uv
Voltage, in uV, that the charging partner provides.
Definition usb_bc12.h:111
int current_ua
Current, in uA, that the charging partner provides.
Definition usb_bc12.h:106
bool pd_partner_connected
True if a PD partner is currently connected.
Definition usb_bc12.h:118
enum bc12_role bc12_role
Current role of the BC1.2 device.
Definition usb_bc12.h:94
enum bc12_type type
Charging partner type.
Definition usb_bc12.h:101
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516