mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
refactor(usb): Update USBH event callback arguments
This commit does the following: - Updates the USBH event callback arguments to now pass a usbh_event_data_t which can contain different data for each event - Updated event names
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,12 +29,31 @@ typedef struct usbh_ep_handle_s *usbh_ep_handle_t;
|
||||
|
||||
// ----------------------- Events --------------------------
|
||||
|
||||
/**
|
||||
* @brief Enumerator for various USBH events
|
||||
*/
|
||||
typedef enum {
|
||||
USBH_EVENT_DEV_NEW, /**< A new device has been enumerated and added to the device pool */
|
||||
USBH_EVENT_NEW_DEV, /**< A new device has been enumerated and added to the device pool */
|
||||
USBH_EVENT_DEV_GONE, /**< A device is gone. Clients should close the device */
|
||||
USBH_EVENT_DEV_ALL_FREE, /**< All devices have been freed */
|
||||
USBH_EVENT_ALL_FREE, /**< All devices have been freed */
|
||||
} usbh_event_t;
|
||||
|
||||
/**
|
||||
* @brief Event data object for USBH events
|
||||
*/
|
||||
typedef struct {
|
||||
usbh_event_t event;
|
||||
union {
|
||||
struct {
|
||||
uint8_t dev_addr;
|
||||
} new_dev_data;
|
||||
struct {
|
||||
uint8_t dev_addr;
|
||||
usb_device_handle_t dev_hdl;
|
||||
} dev_gone_data;
|
||||
};
|
||||
} usbh_event_data_t;
|
||||
|
||||
/**
|
||||
* @brief Endpoint events
|
||||
*
|
||||
@@ -109,9 +128,8 @@ typedef void (*usbh_ctrl_xfer_cb_t)(usb_device_handle_t dev_hdl, urb_t *urb, voi
|
||||
* @brief Callback used to indicate that the USBH has an event
|
||||
*
|
||||
* @note This callback is called from within usbh_process()
|
||||
* @note On a USBH_EVENT_DEV_ALL_FREE event, the dev_hdl argument is set to NULL
|
||||
*/
|
||||
typedef void (*usbh_event_cb_t)(usb_device_handle_t dev_hdl, usbh_event_t usbh_event, void *arg);
|
||||
typedef void (*usbh_event_cb_t)(usbh_event_data_t *event_data, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Callback used by the USBH to request actions from the Hub driver
|
||||
@@ -497,7 +515,7 @@ esp_err_t usbh_hub_enum_fill_str_desc(usb_device_handle_t dev_hdl, const usb_str
|
||||
/**
|
||||
* @brief Indicate the device enumeration is completed
|
||||
*
|
||||
* This will all the device to be opened by clients, and also trigger a USBH_EVENT_DEV_NEW event.
|
||||
* This will allow the device to be opened by clients, and also trigger a USBH_EVENT_NEW_DEV event.
|
||||
*
|
||||
* @note Hub Driver only
|
||||
* @note Must call in sequence
|
||||
|
Reference in New Issue
Block a user