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)
133__subsystem
struct bc12_driver_api {
152static inline int z_impl_bc12_set_role(
const struct device *dev,
enum bc12_role role)
154 const struct bc12_driver_api *api = (
const struct bc12_driver_api *)dev->
api;
156 return api->set_role(dev, role);
174 const struct bc12_driver_api *api = (
const struct bc12_driver_api *)dev->
api;
176 return api->set_result_cb(dev, cb, user_data);
187#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:125
@ BC12_CHARGING_PORT
Definition usb_bc12.h:68
@ BC12_DISCONNECTED
Definition usb_bc12.h:66
@ BC12_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:101
int voltage_uv
Definition usb_bc12.h:107
int current_ua
Definition usb_bc12.h:106
bool pd_partner_connected
Definition usb_bc12.h:110
enum bc12_role bc12_role
Definition usb_bc12.h:102
enum bc12_type type
Definition usb_bc12.h:105
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418