Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usb_device.h File Reference

USB device core layer APIs and structures. More...

Go to the source code of this file.

Data Structures

struct  usb_ep_cfg_data
 USB Endpoint Configuration. More...
 
struct  usb_interface_cfg_data
 USB Interface Configuration. More...
 
struct  usb_cfg_data
 USB device configuration. More...
 

Macros

#define USBD_DEVICE_DESCR_DEFINE(p)
 
#define USBD_CLASS_DESCR_DEFINE(p, instance)
 
#define USBD_MISC_DESCR_DEFINE(p)
 
#define USBD_USER_DESCR_DEFINE(p)
 
#define USBD_STRING_DESCR_DEFINE(p)
 
#define USBD_STRING_DESCR_USER_DEFINE(p)
 
#define USBD_TERM_DESCR_DEFINE(p)
 
#define USBD_DEFINE_CFG_DATA(name)
 
#define USBD_CFG_DATA_DEFINE(p, name)
 
#define USB_MAX_CTRL_MPS   64
 maximum packet size (MPS) for EP 0
 
#define USB_MAX_FS_BULK_MPS   64
 full speed MPS for bulk EP
 
#define USB_MAX_FS_INT_MPS   64
 full speed MPS for interrupt EP
 
#define USB_MAX_FS_ISO_MPS   1023
 full speed MPS for isochronous EP
 
#define USB_TRANS_READ   BIT(0) /** Read transfer flag */
 
#define USB_TRANS_WRITE   BIT(1) /** Write transfer flag */
 
#define USB_TRANS_NO_ZLP   BIT(2) /** No zero-length packet flag */
 
#define USB_DEVICE_BOS_DESC_DEFINE_CAP    static __in_section(usb, bos_desc_area, 1) __aligned(1) __used
 Helper macro to place the BOS compatibility descriptor in the right memory section.
 

Typedefs

typedef void(* usb_ep_callback) (uint8_t ep, enum usb_dc_ep_cb_status_code cb_status)
 Callback function signature for the USB Endpoint status.
 
typedef int(* usb_request_handler) (struct usb_setup_packet *setup, int32_t *transfer_len, uint8_t **payload_data)
 Callback function signature for class specific requests.
 
typedef void(* usb_interface_config) (struct usb_desc_header *head, uint8_t bInterfaceNumber)
 Function for interface runtime configuration.
 
typedef void(* usb_transfer_callback) (uint8_t ep, int tsize, void *priv)
 Callback function signature for transfer completion.
 

Functions

int usb_set_config (const uint8_t *usb_descriptor)
 Configure USB controller.
 
int usb_deconfig (void)
 Deconfigure USB controller.
 
int usb_enable (usb_dc_status_callback status_cb)
 Enable the USB subsystem and associated hardware.
 
int usb_disable (void)
 Disable the USB device.
 
int usb_write (uint8_t ep, const uint8_t *data, uint32_t data_len, uint32_t *bytes_ret)
 Write data to the specified endpoint.
 
int usb_read (uint8_t ep, uint8_t *data, uint32_t max_data_len, uint32_t *ret_bytes)
 Read data from the specified endpoint.
 
int usb_ep_set_stall (uint8_t ep)
 Set STALL condition on the specified endpoint.
 
int usb_ep_clear_stall (uint8_t ep)
 Clears STALL condition on the specified endpoint.
 
int usb_ep_read_wait (uint8_t ep, uint8_t *data, uint32_t max_data_len, uint32_t *read_bytes)
 Read data from the specified endpoint.
 
int usb_ep_read_continue (uint8_t ep)
 Continue reading data from the endpoint.
 
void usb_transfer_ep_callback (uint8_t ep, enum usb_dc_ep_cb_status_code)
 Transfer management endpoint callback.
 
int usb_transfer (uint8_t ep, uint8_t *data, size_t dlen, unsigned int flags, usb_transfer_callback cb, void *priv)
 Start a transfer.
 
int usb_transfer_sync (uint8_t ep, uint8_t *data, size_t dlen, unsigned int flags)
 Start a transfer and block-wait for completion.
 
void usb_cancel_transfer (uint8_t ep)
 Cancel any ongoing transfer on the specified endpoint.
 
void usb_cancel_transfers (void)
 Cancel all ongoing transfers.
 
bool usb_transfer_is_busy (uint8_t ep)
 Check that transfer is ongoing for the endpoint.
 
int usb_wakeup_request (void)
 Start the USB remote wakeup procedure.
 
bool usb_get_remote_wakeup_status (void)
 Get status of the USB remote wakeup feature.
 
void usb_bos_register_cap (void *hdr)
 Register BOS capability descriptor.
 

Detailed Description

USB device core layer APIs and structures.

This file contains the USB device core layer APIs and structures.

Macro Definition Documentation

◆ USB_MAX_CTRL_MPS

#define USB_MAX_CTRL_MPS   64

maximum packet size (MPS) for EP 0

◆ USB_MAX_FS_BULK_MPS

#define USB_MAX_FS_BULK_MPS   64

full speed MPS for bulk EP

◆ USB_MAX_FS_INT_MPS

#define USB_MAX_FS_INT_MPS   64

full speed MPS for interrupt EP

◆ USB_MAX_FS_ISO_MPS

#define USB_MAX_FS_ISO_MPS   1023

full speed MPS for isochronous EP

◆ USBD_CFG_DATA_DEFINE

#define USBD_CFG_DATA_DEFINE ( p,
name )
Value:
__DEPRECATED_MACRO \
static __in_section(_usb_cfg_data, static, p##_name) __used __aligned(4)

◆ USBD_CLASS_DESCR_DEFINE

#define USBD_CLASS_DESCR_DEFINE ( p,
instance )
Value:
static __in_section(usb, descriptor_##p.1, instance) __used __aligned(1)

◆ USBD_DEFINE_CFG_DATA

#define USBD_DEFINE_CFG_DATA ( name)
Value:
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition iterable_sections.h:216
USB device configuration.
Definition usb_device.h:177

◆ USBD_DEVICE_DESCR_DEFINE

#define USBD_DEVICE_DESCR_DEFINE ( p)
Value:
static __in_section(usb, descriptor_##p, 0) __used __aligned(1)

◆ USBD_MISC_DESCR_DEFINE

#define USBD_MISC_DESCR_DEFINE ( p)
Value:
static __in_section(usb, descriptor_##p, 2) __used __aligned(1)

◆ USBD_STRING_DESCR_DEFINE

#define USBD_STRING_DESCR_DEFINE ( p)
Value:
static __in_section(usb, descriptor_##p, 4) __used __aligned(1)

◆ USBD_STRING_DESCR_USER_DEFINE

#define USBD_STRING_DESCR_USER_DEFINE ( p)
Value:
static __in_section(usb, descriptor_##p, 5) __used __aligned(1)

◆ USBD_TERM_DESCR_DEFINE

#define USBD_TERM_DESCR_DEFINE ( p)
Value:
static __in_section(usb, descriptor_##p, 6) __used __aligned(1)

◆ USBD_USER_DESCR_DEFINE

#define USBD_USER_DESCR_DEFINE ( p)
Value:
static __in_section(usb, descriptor_##p, 3) __used __aligned(1)