Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
USB host controller (UHC) driver API. More...
Data Structures | |
struct | uhc_transfer |
UHC endpoint buffer info. More... | |
struct | uhc_event |
USB host controller event. More... | |
struct | uhc_device_caps |
USB host controller capabilities. More... | |
struct | uhc_data |
Common UHC driver data structure. More... | |
Macros | |
#define | UHC_STATUS_INITIALIZED 0 |
Controller is initialized by uhc_init() | |
#define | UHC_STATUS_ENABLED 1 |
Controller is enabled and all API functions are available. | |
Typedefs | |
typedef int(* | uhc_event_cb_t) (const struct device *dev, const struct uhc_event *const event) |
Callback to submit UHC event to higher layer. | |
Enumerations | |
enum | uhc_control_stage { UHC_CONTROL_STAGE_SETUP = 0 , UHC_CONTROL_STAGE_DATA , UHC_CONTROL_STAGE_STATUS } |
USB control transfer stage. More... | |
enum | uhc_event_type { UHC_EVT_DEV_CONNECTED_LS , UHC_EVT_DEV_CONNECTED_FS , UHC_EVT_DEV_CONNECTED_HS , UHC_EVT_DEV_REMOVED , UHC_EVT_RESETED , UHC_EVT_SUSPENDED , UHC_EVT_RESUMED , UHC_EVT_RWUP , UHC_EVT_EP_REQUEST , UHC_EVT_ERROR } |
USB host controller event types. More... | |
Functions | |
static bool | uhc_is_initialized (const struct device *dev) |
Checks whether the controller is initialized. | |
static bool | uhc_is_enabled (const struct device *dev) |
Checks whether the controller is enabled. | |
static int | uhc_bus_reset (const struct device *dev) |
Reset USB bus. | |
static int | uhc_sof_enable (const struct device *dev) |
Enable Start of Frame generator. | |
static int | uhc_bus_suspend (const struct device *dev) |
Suspend USB bus. | |
static int | uhc_bus_resume (const struct device *dev) |
Resume USB bus. | |
struct uhc_transfer * | uhc_xfer_alloc (const struct device *dev, const uint8_t addr, const uint8_t ep, const uint8_t attrib, const uint16_t mps, const uint16_t timeout, void *const udev, void *const cb) |
Allocate UHC transfer. | |
struct uhc_transfer * | uhc_xfer_alloc_with_buf (const struct device *dev, const uint8_t addr, const uint8_t ep, const uint8_t attrib, const uint16_t mps, const uint16_t timeout, void *const udev, void *const cb, size_t size) |
Allocate UHC transfer with buffer. | |
int | uhc_xfer_free (const struct device *dev, struct uhc_transfer *const xfer) |
Free UHC transfer and any buffers. | |
int | uhc_xfer_buf_add (const struct device *dev, struct uhc_transfer *const xfer, struct net_buf *buf) |
Add UHC transfer buffer. | |
struct net_buf * | uhc_xfer_buf_alloc (const struct device *dev, const size_t size) |
Allocate UHC transfer buffer. | |
void | uhc_xfer_buf_free (const struct device *dev, struct net_buf *const buf) |
Free UHC request buffer. | |
int | uhc_ep_enqueue (const struct device *dev, struct uhc_transfer *const xfer) |
Queue USB host controller transfer. | |
int | uhc_ep_dequeue (const struct device *dev, struct uhc_transfer *const xfer) |
Remove a USB host controller transfers from queue. | |
int | uhc_init (const struct device *dev, uhc_event_cb_t event_cb) |
Initialize USB host controller. | |
int | uhc_enable (const struct device *dev) |
Enable USB host controller. | |
int | uhc_disable (const struct device *dev) |
Disable USB host controller. | |
int | uhc_shutdown (const struct device *dev) |
Poweroff USB host controller. | |
static struct uhc_device_caps | uhc_caps (const struct device *dev) |
Get USB host controller capabilities. | |
USB host controller (UHC) driver API.
#define UHC_STATUS_ENABLED 1 |
#include <include/zephyr/drivers/usb/uhc.h>
Controller is enabled and all API functions are available.
#define UHC_STATUS_INITIALIZED 0 |
#include <include/zephyr/drivers/usb/uhc.h>
Controller is initialized by uhc_init()
uhc_event_cb_t |
#include <include/zephyr/drivers/usb/uhc.h>
Callback to submit UHC event to higher layer.
At the higher level, the event is to be inserted into a message queue.
[in] | dev | Pointer to device struct of the driver instance |
[in] | event | Point to event structure |
enum uhc_control_stage |
#include <include/zephyr/drivers/usb/uhc.h>
USB control transfer stage.
Enumerator | |
---|---|
UHC_CONTROL_STAGE_SETUP | |
UHC_CONTROL_STAGE_DATA | |
UHC_CONTROL_STAGE_STATUS |
enum uhc_event_type |
#include <include/zephyr/drivers/usb/uhc.h>
USB host controller event types.
|
inlinestatic |
#include <include/zephyr/drivers/usb/uhc.h>
Reset USB bus.
Perform USB bus reset, controller may emit UHC_EVT_RESETED at the end of reset signaling.
[in] | dev | Pointer to device struct of the driver instance |
-EBUSY | if the controller is already performing a bus operation |
|
inlinestatic |
#include <include/zephyr/drivers/usb/uhc.h>
Resume USB bus.
Signal resume for at least 20ms, emit UHC_EVT_RESUMED at the end of USB bus resume signaling. The SoF generator should subsequently start within 3ms.
[in] | dev | Pointer to device struct of the driver instance |
-EBUSY | if the controller is already performing a bus operation |
|
inlinestatic |
#include <include/zephyr/drivers/usb/uhc.h>
Suspend USB bus.
Disable SOF generator and emit UHC_EVT_SUSPENDED event when USB bus is suspended.
[in] | dev | Pointer to device struct of the driver instance |
-EALREADY | if already suspended |
|
inlinestatic |
#include <include/zephyr/drivers/usb/uhc.h>
Get USB host controller capabilities.
Obtain the capabilities of the controller such as high speed (HS), and more.
[in] | dev | Pointer to device struct of the driver instance |
int uhc_disable | ( | const struct device * | dev | ) |
#include <include/zephyr/drivers/usb/uhc.h>
Disable USB host controller.
Disable enabled USB host controller.
[in] | dev | Pointer to device struct of the driver instance |
-EALREADY | already disabled |
int uhc_enable | ( | const struct device * | dev | ) |
#include <include/zephyr/drivers/usb/uhc.h>
Enable USB host controller.
Enable powered USB host controller and allow host stack to recognize and enumerate devices.
[in] | dev | Pointer to device struct of the driver instance |
-EPERM | controller is not initialized |
-EALREADY | already enabled |
int uhc_ep_dequeue | ( | const struct device * | dev, |
struct uhc_transfer *const | xfer | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Remove a USB host controller transfers from queue.
Not implemented yet.
[in] | dev | Pointer to device struct of the driver instance |
[in] | xfer | Pointer to UHC transfer |
-EPERM | controller is not initialized |
int uhc_ep_enqueue | ( | const struct device * | dev, |
struct uhc_transfer *const | xfer | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Queue USB host controller transfer.
Add transfer to the queue. If the queue is empty, the transfer can be claimed by the controller immediately.
[in] | dev | Pointer to device struct of the driver instance |
[in] | xfer | Pointer to UHC transfer |
-EPERM | controller is not initialized |
int uhc_init | ( | const struct device * | dev, |
uhc_event_cb_t | event_cb | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Initialize USB host controller.
Initialize USB host controller.
[in] | dev | Pointer to device struct of the driver instance |
[in] | event_cb | Event callback from the higher layer (USB host stack) |
-EINVAL | on parameter error (no callback is passed) |
-EALREADY | already initialized |
#include <include/zephyr/drivers/usb/uhc.h>
Checks whether the controller is enabled.
[in] | dev | Pointer to device struct of the driver instance |
#include <include/zephyr/drivers/usb/uhc.h>
Checks whether the controller is initialized.
[in] | dev | Pointer to device struct of the driver instance |
int uhc_shutdown | ( | const struct device * | dev | ) |
#include <include/zephyr/drivers/usb/uhc.h>
Poweroff USB host controller.
Shut down the controller completely to reduce energy consumption or to change the role of the controller.
[in] | dev | Pointer to device struct of the driver instance |
-EALREADY | controller is already uninitialized |
|
inlinestatic |
#include <include/zephyr/drivers/usb/uhc.h>
Enable Start of Frame generator.
Enable SOF generator.
[in] | dev | Pointer to device struct of the driver instance |
-EALREADY | if already enabled |
struct uhc_transfer * uhc_xfer_alloc | ( | const struct device * | dev, |
const uint8_t | addr, | ||
const uint8_t | ep, | ||
const uint8_t | attrib, | ||
const uint16_t | mps, | ||
const uint16_t | timeout, | ||
void *const | udev, | ||
void *const | cb | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Allocate UHC transfer.
Allocate a new transfer from common transfer pool. Transfer has no buffer after allocation, but can be allocated and added from different pools.
[in] | dev | Pointer to device struct of the driver instance |
[in] | addr | Device (peripheral) address |
[in] | ep | Endpoint address |
[in] | attrib | Endpoint attributes |
[in] | mps | Maximum packet size of the endpoint |
[in] | timeout | Timeout in number of frames |
[in] | udev | Opaque pointer to USB device |
[in] | cb | Transfer completion callback |
struct uhc_transfer * uhc_xfer_alloc_with_buf | ( | const struct device * | dev, |
const uint8_t | addr, | ||
const uint8_t | ep, | ||
const uint8_t | attrib, | ||
const uint16_t | mps, | ||
const uint16_t | timeout, | ||
void *const | udev, | ||
void *const | cb, | ||
size_t | size | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Allocate UHC transfer with buffer.
Allocate a new transfer from common transfer pool with buffer.
[in] | dev | Pointer to device struct of the driver instance |
[in] | addr | Device (peripheral) address |
[in] | ep | Endpoint address |
[in] | attrib | Endpoint attributes |
[in] | mps | Maximum packet size of the endpoint |
[in] | timeout | Timeout in number of frames |
[in] | udev | Opaque pointer to USB device |
[in] | cb | Transfer completion callback |
[in] | size | Size of the buffer |
int uhc_xfer_buf_add | ( | const struct device * | dev, |
struct uhc_transfer *const | xfer, | ||
struct net_buf * | buf | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Add UHC transfer buffer.
Add a previously allocated buffer to the transfer.
[in] | dev | Pointer to device struct of the driver instance |
[in] | xfer | Pointer to UHC transfer |
[in] | buf | Pointer to UHC request buffer |
#include <include/zephyr/drivers/usb/uhc.h>
Allocate UHC transfer buffer.
Allocate a new buffer from common request buffer pool and assign it to the transfer if the xfer parameter is not NULL.
[in] | dev | Pointer to device struct of the driver instance |
[in] | size | Size of the request buffer |
#include <include/zephyr/drivers/usb/uhc.h>
Free UHC request buffer.
Put the buffer back into the request buffer pool.
[in] | dev | Pointer to device struct of the driver instance |
[in] | buf | Pointer to UHC request buffer |
int uhc_xfer_free | ( | const struct device * | dev, |
struct uhc_transfer *const | xfer | ||
) |
#include <include/zephyr/drivers/usb/uhc.h>
Free UHC transfer and any buffers.
Free any buffers and put the transfer back into the transfer pool.
[in] | dev | Pointer to device struct of the driver instance |
[in] | xfer | Pointer to UHC transfer |