Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
New USB device controller (UDC) driver API. More...
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/net/buf.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/usb/usb_ch9.h>
Go to the source code of this file.
Data Structures | |
struct | udc_device_caps |
USB device controller capabilities. More... | |
struct | udc_ep_caps |
USB device controller endpoint capabilities. More... | |
struct | udc_ep_stat |
USB device controller endpoint status. More... | |
struct | udc_ep_config |
USB device controller endpoint configuration. More... | |
struct | udc_event |
USB device controller event. More... | |
struct | udc_buf_info |
UDC endpoint buffer info. More... | |
struct | udc_api |
UDC driver API This is the mandatory API any USB device controller driver needs to expose with exception of: device_speed(), test_mode() are only required for HS controllers. More... | |
struct | udc_data |
Common UDC driver data structure. More... | |
Macros | |
#define | UDC_STATUS_INITIALIZED 0 |
Controller is initialized by udc_init() and can generate the VBUS events, if capable, but shall not be recognizable by host. | |
#define | UDC_STATUS_ENABLED 1 |
Controller is enabled and all API functions are available, controller is recognizable by host. | |
#define | UDC_STATUS_SUSPENDED 2 |
Controller is suspended by the host. | |
Typedefs | |
typedef int(* | udc_event_cb_t) (const struct device *dev, const struct udc_event *const event) |
Callback to submit UDC event to higher layer. | |
Enumerations | |
enum | udc_mps0 { UDC_MPS0_8 , UDC_MPS0_16 , UDC_MPS0_32 , UDC_MPS0_64 } |
Maximum packet size of control endpoint supported by the controller. More... | |
enum | udc_bus_speed { UDC_BUS_UNKNOWN , UDC_BUS_SPEED_FS , UDC_BUS_SPEED_HS , UDC_BUS_SPEED_SS } |
USB device actual speed. More... | |
enum | udc_event_type { UDC_EVT_VBUS_READY , UDC_EVT_VBUS_REMOVED , UDC_EVT_RESUME , UDC_EVT_SUSPEND , UDC_EVT_RESET , UDC_EVT_SOF , UDC_EVT_EP_REQUEST , UDC_EVT_ERROR } |
USB device controller event types. More... | |
Functions | |
static bool | udc_is_initialized (const struct device *dev) |
Checks whether the controller is initialized. | |
static bool | udc_is_enabled (const struct device *dev) |
Checks whether the controller is enabled. | |
static bool | udc_is_suspended (const struct device *dev) |
Checks whether the controller is suspended. | |
int | udc_init (const struct device *dev, udc_event_cb_t event_cb) |
Initialize USB device controller. | |
int | udc_enable (const struct device *dev) |
Enable USB device controller. | |
int | udc_disable (const struct device *dev) |
Disable USB device controller. | |
int | udc_shutdown (const struct device *dev) |
Poweroff USB device controller. | |
static struct udc_device_caps | udc_caps (const struct device *dev) |
Get USB device controller capabilities. | |
enum udc_bus_speed | udc_device_speed (const struct device *dev) |
Get actual USB device speed. | |
static int | udc_set_address (const struct device *dev, const uint8_t addr) |
Set USB device address. | |
static int | udc_test_mode (const struct device *dev, const uint8_t mode, const bool dryrun) |
Enable Test Mode. | |
static int | udc_host_wakeup (const struct device *dev) |
Initiate host wakeup procedure. | |
int | udc_ep_try_config (const struct device *dev, const uint8_t ep, const uint8_t attributes, uint16_t *const mps, const uint8_t interval) |
Try an endpoint configuration. | |
int | udc_ep_enable (const struct device *dev, const uint8_t ep, const uint8_t attributes, const uint16_t mps, const uint8_t interval) |
Configure and enable endpoint. | |
int | udc_ep_disable (const struct device *dev, const uint8_t ep) |
Disable endpoint. | |
int | udc_ep_set_halt (const struct device *dev, const uint8_t ep) |
Halt endpoint. | |
int | udc_ep_clear_halt (const struct device *dev, const uint8_t ep) |
Clear endpoint halt. | |
int | udc_ep_enqueue (const struct device *dev, struct net_buf *const buf) |
Queue USB device controller request. | |
int | udc_ep_dequeue (const struct device *dev, const uint8_t ep) |
Remove all USB device controller requests from endpoint queue. | |
struct net_buf * | udc_ep_buf_alloc (const struct device *dev, const uint8_t ep, const size_t size) |
Allocate UDC request buffer. | |
int | udc_ep_buf_free (const struct device *dev, struct net_buf *const buf) |
Free UDC request buffer. | |
static void | udc_ep_buf_set_zlp (struct net_buf *const buf) |
Set ZLP flag in requests metadata. | |
static struct udc_buf_info * | udc_get_buf_info (const struct net_buf *const buf) |
Get requests metadata. | |
New USB device controller (UDC) driver API.
#define UDC_STATUS_ENABLED 1 |
Controller is enabled and all API functions are available, controller is recognizable by host.
#define UDC_STATUS_INITIALIZED 0 |
Controller is initialized by udc_init() and can generate the VBUS events, if capable, but shall not be recognizable by host.
#define UDC_STATUS_SUSPENDED 2 |
Controller is suspended by the host.
udc_event_cb_t |
Callback to submit UDC event to higher layer.
At the higher level, the event is to be inserted into a message queue. (TBD) Maybe it is better to provide a pointer to k_msgq passed during initialization.
[in] | dev | Pointer to device struct of the driver instance |
[in] | event | Point to event structure |
enum udc_bus_speed |
enum udc_event_type |
USB device controller event types.
enum udc_mps0 |