Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
New experimental USB device stack APIs and structures. More...
#include <zephyr/device.h>
#include <zephyr/usb/bos.h>
#include <zephyr/usb/usb_ch9.h>
#include <zephyr/usb/usbd_msg.h>
#include <zephyr/net/buf.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/slist.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/iterable_sections.h>
Go to the source code of this file.
Data Structures | |
struct | usbd_str_desc_data |
Used internally to keep descriptors in order. More... | |
struct | usbd_bos_desc_data |
USBD BOS Device Capability descriptor data. More... | |
struct | usbd_desc_node |
Descriptor node. More... | |
struct | usbd_config_node |
Device configuration node. More... | |
struct | usbd_ch9_data |
USB device support middle layer runtime data. More... | |
struct | usbd_status |
USB device support status. More... | |
struct | usbd_context |
USB device support runtime context. More... | |
struct | usbd_cctx_vendor_req |
Vendor Requests Table. More... | |
struct | usbd_class_api |
USB device support class instance API. More... | |
struct | usbd_class_data |
USB device support class data. More... | |
Macros | |
#define | USB_BSTRING_LENGTH(s) (sizeof(s) * 2 - 2) |
#define | USB_STRING_DESCRIPTOR_LENGTH(s) (sizeof(s) * 2) |
#define | USBD_NUMOF_INTERFACES_MAX 16U |
#define | USBD_CCTX_REGISTERED 0 |
USB Class instance registered flag. | |
#define | USBD_DEVICE_DEFINE(device_name, udc_dev, vid, pid) |
Define USB device context structure. | |
#define | USBD_CONFIGURATION_DEFINE(name, attrib, power) |
Define USB device configuration. | |
#define | USBD_DESC_LANG_DEFINE(name) |
Create a string descriptor node and language string descriptor. | |
#define | USBD_DESC_STRING_DEFINE(d_name, d_string, d_utype) |
Create a string descriptor. | |
#define | USBD_DESC_MANUFACTURER_DEFINE(d_name, d_string) USBD_DESC_STRING_DEFINE(d_name, d_string, USBD_DUT_STRING_MANUFACTURER) |
Create a string descriptor node and manufacturer string descriptor. | |
#define | USBD_DESC_PRODUCT_DEFINE(d_name, d_string) USBD_DESC_STRING_DEFINE(d_name, d_string, USBD_DUT_STRING_PRODUCT) |
Create a string descriptor node and product string descriptor. | |
#define | USBD_DESC_SERIAL_NUMBER_DEFINE(d_name) |
Create a string descriptor node and serial number string descriptor. | |
#define | USBD_DESC_BOS_DEFINE(name, len, subset) |
Define BOS Device Capability descriptor node. | |
#define | USBD_DEFINE_CLASS(class_name, class_api, class_priv, class_v_reqs) |
Define USB device support class data. | |
#define | VENDOR_REQ_DEFINE(_reqs, _len) |
Helper to declare request table of usbd_cctx_vendor_req. | |
#define | USBD_VENDOR_REQ(_reqs...) |
Helper to declare supported vendor requests. | |
Typedefs | |
typedef void(* | usbd_msg_cb_t) (struct usbd_context *const ctx, const struct usbd_msg *const msg) |
Callback type definition for USB device message delivery. | |
Enumerations | |
enum | usbd_ch9_state { USBD_STATE_DEFAULT = 0 , USBD_STATE_ADDRESS , USBD_STATE_CONFIGURED } |
USB device support middle layer runtime state. More... | |
enum | usbd_speed { USBD_SPEED_FS , USBD_SPEED_HS , USBD_SPEED_SS } |
USB device speed. More... | |
Functions | |
static struct usbd_context * | usbd_class_get_ctx (const struct usbd_class_data *const c_data) |
Get the USB device runtime context under which the class is registered. | |
static void * | usbd_class_get_private (const struct usbd_class_data *const c_data) |
Get class implementation private data. | |
int | usbd_add_descriptor (struct usbd_context *uds_ctx, struct usbd_desc_node *dn) |
Add common USB descriptor. | |
uint8_t | usbd_str_desc_get_idx (const struct usbd_desc_node *const desc_nd) |
Get USB string descriptor index from descriptor node. | |
void | usbd_remove_descriptor (struct usbd_desc_node *const desc_nd) |
Remove USB string descriptor. | |
int | usbd_add_configuration (struct usbd_context *uds_ctx, const enum usbd_speed speed, struct usbd_config_node *cd) |
Add a USB device configuration. | |
int | usbd_register_class (struct usbd_context *uds_ctx, const char *name, const enum usbd_speed speed, uint8_t cfg) |
Register an USB class instance. | |
int | usbd_register_all_classes (struct usbd_context *uds_ctx, const enum usbd_speed speed, uint8_t cfg) |
Register all available USB class instances. | |
int | usbd_unregister_class (struct usbd_context *uds_ctx, const char *name, const enum usbd_speed speed, uint8_t cfg) |
Unregister an USB class instance. | |
int | usbd_unregister_all_classes (struct usbd_context *uds_ctx, const enum usbd_speed speed, uint8_t cfg) |
Unregister all available USB class instances. | |
int | usbd_msg_register_cb (struct usbd_context *const uds_ctx, const usbd_msg_cb_t cb) |
Register USB notification message callback. | |
int | usbd_init (struct usbd_context *uds_ctx) |
Initialize USB device. | |
int | usbd_enable (struct usbd_context *uds_ctx) |
Enable the USB device support and registered class instances. | |
int | usbd_disable (struct usbd_context *uds_ctx) |
Disable the USB device support. | |
int | usbd_shutdown (struct usbd_context *const uds_ctx) |
Shutdown the USB device support. | |
int | usbd_ep_set_halt (struct usbd_context *uds_ctx, uint8_t ep) |
Halt endpoint. | |
int | usbd_ep_clear_halt (struct usbd_context *uds_ctx, uint8_t ep) |
Clear endpoint halt. | |
bool | usbd_ep_is_halted (struct usbd_context *uds_ctx, uint8_t ep) |
Checks whether the endpoint is halted. | |
struct net_buf * | usbd_ep_buf_alloc (const struct usbd_class_data *const c_data, const uint8_t ep, const size_t size) |
Allocate buffer for USB device request. | |
int | usbd_ep_ctrl_enqueue (struct usbd_context *const uds_ctx, struct net_buf *const buf) |
Queue USB device control request. | |
int | usbd_ep_enqueue (const struct usbd_class_data *const c_data, struct net_buf *const buf) |
Queue USB device request. | |
int | usbd_ep_dequeue (struct usbd_context *uds_ctx, const uint8_t ep) |
Remove all USB device controller requests from endpoint queue. | |
int | usbd_ep_buf_free (struct usbd_context *uds_ctx, struct net_buf *buf) |
Free USB device request buffer. | |
bool | usbd_is_suspended (struct usbd_context *uds_ctx) |
Checks whether the USB device controller is suspended. | |
int | usbd_wakeup_request (struct usbd_context *uds_ctx) |
Initiate the USB remote wakeup (TBD) | |
enum usbd_speed | usbd_bus_speed (const struct usbd_context *const uds_ctx) |
Get actual device speed. | |
enum usbd_speed | usbd_caps_speed (const struct usbd_context *const uds_ctx) |
Get highest speed supported by the controller. | |
int | usbd_device_set_bcd (struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint16_t bcd) |
Set USB device descriptor value bcdUSB. | |
int | usbd_device_set_vid (struct usbd_context *const uds_ctx, const uint16_t vid) |
Set USB device descriptor value idVendor. | |
int | usbd_device_set_pid (struct usbd_context *const uds_ctx, const uint16_t pid) |
Set USB device descriptor value idProduct. | |
int | usbd_device_set_code_triple (struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t base_class, const uint8_t subclass, const uint8_t protocol) |
Set USB device descriptor code triple Base Class, SubClass, and Protocol. | |
int | usbd_config_attrib_rwup (struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t cfg, const bool enable) |
Setup USB device configuration attribute Remote Wakeup. | |
int | usbd_config_attrib_self (struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t cfg, const bool enable) |
Setup USB device configuration attribute Self-powered. | |
int | usbd_config_maxpower (struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t cfg, const uint8_t power) |
Setup USB device configuration power consumption. | |
bool | usbd_can_detect_vbus (struct usbd_context *const uds_ctx) |
Check that the controller can detect the VBUS state change. | |
New experimental USB device stack APIs and structures.
This file contains the USB device stack APIs and structures.