|
Zephyr Project API
3.2.0
A Scalable Open Source RTOS
|
USB device controller APIs. More...
#include <zephyr/device.h>Go to the source code of this file.
Data Structures | |
| struct | usb_dc_ep_cfg_data |
| USB Endpoint Configuration. More... | |
Macros | |
| #define | USB_EP_DIR_MASK 0x80U |
| #define | USB_EP_DIR_IN 0x80U |
| #define | USB_EP_DIR_OUT 0x00U |
| #define | USB_EP_GET_IDX(ep) ((ep) & ~USB_EP_DIR_MASK) |
| #define | USB_EP_GET_DIR(ep) ((ep) & USB_EP_DIR_MASK) |
| #define | USB_EP_GET_ADDR(idx, dir) ((idx) | ((dir) & USB_EP_DIR_MASK)) |
| #define | USB_EP_DIR_IS_IN(ep) (USB_EP_GET_DIR(ep) == USB_EP_DIR_IN) |
| #define | USB_EP_DIR_IS_OUT(ep) (USB_EP_GET_DIR(ep) == USB_EP_DIR_OUT) |
| #define | USB_EP_TRANSFER_TYPE_MASK 0x3U |
| #define | USB_EP_SYNCHRONIZATION_TYPE_MASK (0x3 << 2U) |
Typedefs | |
| typedef void(* | usb_dc_ep_callback) (uint8_t ep, enum usb_dc_ep_cb_status_code cb_status) |
| typedef void(* | usb_dc_status_callback) (enum usb_dc_status_code cb_status, const uint8_t *param) |
Enumerations | |
| enum | usb_dc_status_code { USB_DC_ERROR , USB_DC_RESET , USB_DC_CONNECTED , USB_DC_CONFIGURED , USB_DC_DISCONNECTED , USB_DC_SUSPEND , USB_DC_RESUME , USB_DC_INTERFACE , USB_DC_SET_HALT , USB_DC_CLEAR_HALT , USB_DC_SOF , USB_DC_UNKNOWN } |
| USB Driver Status Codes. More... | |
| enum | usb_dc_ep_cb_status_code { USB_DC_EP_SETUP , USB_DC_EP_DATA_OUT , USB_DC_EP_DATA_IN } |
| USB Endpoint Callback Status Codes. More... | |
| enum | usb_dc_ep_transfer_type { USB_DC_EP_CONTROL = 0 , USB_DC_EP_ISOCHRONOUS , USB_DC_EP_BULK , USB_DC_EP_INTERRUPT } |
| USB Endpoint Transfer Type. More... | |
| enum | usb_dc_ep_synchronozation_type { USB_DC_EP_NO_SYNCHRONIZATION = (0U << 2U) , USB_DC_EP_ASYNCHRONOUS = (1U << 2U) , USB_DC_EP_ADAPTIVE = (2U << 2U) , USB_DC_EP_SYNCHRONOUS = (3U << 2U) } |
| USB Endpoint Synchronization Type. More... | |
Functions | |
| int | usb_dc_attach (void) |
| Attach USB for device connection. More... | |
| int | usb_dc_detach (void) |
| Detach the USB device. More... | |
| int | usb_dc_reset (void) |
| Reset the USB device. More... | |
| int | usb_dc_set_address (const uint8_t addr) |
| Set USB device address. More... | |
| void | usb_dc_set_status_callback (const usb_dc_status_callback cb) |
| Set USB device controller status callback. More... | |
| int | usb_dc_ep_check_cap (const struct usb_dc_ep_cfg_data *const cfg) |
| check endpoint capabilities More... | |
| int | usb_dc_ep_configure (const struct usb_dc_ep_cfg_data *const cfg) |
| Configure endpoint. More... | |
| int | usb_dc_ep_set_stall (const uint8_t ep) |
| Set stall condition for the selected endpoint. More... | |
| int | usb_dc_ep_clear_stall (const uint8_t ep) |
| Clear stall condition for the selected endpoint. More... | |
| int | usb_dc_ep_is_stalled (const uint8_t ep, uint8_t *const stalled) |
| Check if the selected endpoint is stalled. More... | |
| int | usb_dc_ep_halt (const uint8_t ep) |
| Halt the selected endpoint. More... | |
| int | usb_dc_ep_enable (const uint8_t ep) |
| Enable the selected endpoint. More... | |
| int | usb_dc_ep_disable (const uint8_t ep) |
| Disable the selected endpoint. More... | |
| int | usb_dc_ep_flush (const uint8_t ep) |
| Flush the selected endpoint. More... | |
| int | usb_dc_ep_write (const uint8_t ep, const uint8_t *const data, const uint32_t data_len, uint32_t *const ret_bytes) |
| Write data to the specified endpoint. More... | |
| int | usb_dc_ep_read (const uint8_t ep, uint8_t *const data, const uint32_t max_data_len, uint32_t *const read_bytes) |
| Read data from the specified endpoint. More... | |
| int | usb_dc_ep_set_callback (const uint8_t ep, const usb_dc_ep_callback cb) |
| Set callback function for the specified endpoint. More... | |
| int | usb_dc_ep_read_wait (uint8_t ep, uint8_t *data, uint32_t max_data_len, uint32_t *read_bytes) |
| Read data from the specified endpoint. More... | |
| int | usb_dc_ep_read_continue (uint8_t ep) |
| Continue reading data from the endpoint. More... | |
| int | usb_dc_ep_mps (uint8_t ep) |
| Get endpoint max packet size. More... | |
| int | usb_dc_wakeup_request (void) |
| Start the host wake up procedure. More... | |
USB device controller APIs.
This file contains the USB device controller APIs. All device controller drivers should implement the APIs described in this file.
| #define USB_EP_DIR_IN 0x80U |
| #define USB_EP_DIR_IS_IN | ( | ep | ) | (USB_EP_GET_DIR(ep) == USB_EP_DIR_IN) |
True if the endpoint is an IN endpoint
| #define USB_EP_DIR_IS_OUT | ( | ep | ) | (USB_EP_GET_DIR(ep) == USB_EP_DIR_OUT) |
True if the endpoint is an OUT endpoint
| #define USB_EP_DIR_MASK 0x80U |
USB endpoint direction and number.
| #define USB_EP_DIR_OUT 0x00U |
| #define USB_EP_GET_ADDR | ( | idx, | |
| dir | |||
| ) | ((idx) | ((dir) & USB_EP_DIR_MASK)) |
Get endpoint address from endpoint index and direction
| #define USB_EP_GET_DIR | ( | ep | ) | ((ep) & USB_EP_DIR_MASK) |
Get direction from endpoint address
| #define USB_EP_GET_IDX | ( | ep | ) | ((ep) & ~USB_EP_DIR_MASK) |
Get endpoint index (number) from endpoint address
| #define USB_EP_SYNCHRONIZATION_TYPE_MASK (0x3 << 2U) |
USB endpoint Synchronization Type mask.
| #define USB_EP_TRANSFER_TYPE_MASK 0x3U |
USB endpoint Transfer Type mask.