update doc
This commit is contained in:
@@ -15,11 +15,12 @@ CLASS 驱动信息结构体
|
||||
.. code-block:: C
|
||||
|
||||
struct usbh_class_info {
|
||||
uint8_t class; /* Base device class code */
|
||||
uint8_t subclass; /* Sub-class, depends on base class. Eg. */
|
||||
uint8_t protocol; /* Protocol, depends on base class. Eg. */
|
||||
uint16_t vid; /* Vendor ID (for vendor/product specific devices) */
|
||||
uint16_t pid; /* Product ID (for vendor/product specific devices) */
|
||||
uint8_t match_flags; /* Used for product specific matches; range is inclusive */
|
||||
uint8_t class; /* Base device class code */
|
||||
uint8_t subclass; /* Sub-class, depends on base class. Eg. */
|
||||
uint8_t protocol; /* Protocol, depends on base class. Eg. */
|
||||
uint16_t vid; /* Vendor ID (for vendor/product specific devices) */
|
||||
uint16_t pid; /* Product ID (for vendor/product specific devices) */
|
||||
const struct usbh_class_driver *class_driver;
|
||||
};
|
||||
|
||||
@@ -28,99 +29,90 @@ CLASS 驱动信息结构体
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_endpoint {
|
||||
struct usbh_endpoint {
|
||||
struct usb_endpoint_descriptor ep_desc;
|
||||
} usbh_endpoint_t;
|
||||
};
|
||||
|
||||
接口备用结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
struct usbh_interface_altsetting {
|
||||
struct usb_interface_descriptor intf_desc;
|
||||
struct usbh_endpoint ep[CONFIG_USBHOST_MAX_ENDPOINTS];
|
||||
};
|
||||
|
||||
接口结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_interface {
|
||||
struct usb_interface_descriptor intf_desc;
|
||||
struct usbh_endpoint ep[CONFIG_USBHOST_EP_NUM];
|
||||
struct usbh_interface {
|
||||
struct usbh_interface_altsetting altsetting[CONFIG_USBHOST_MAX_INTF_ALTSETTINGS];
|
||||
uint8_t altsetting_num;
|
||||
char devname[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
struct usbh_class_driver *class_driver;
|
||||
void *priv;
|
||||
} usbh_interface_t;
|
||||
|
||||
};
|
||||
|
||||
配置结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_configuration {
|
||||
struct usbh_configuration {
|
||||
struct usb_configuration_descriptor config_desc;
|
||||
struct usbh_interface intf[CONFIG_USBHOST_INTF_NUM];
|
||||
} usbh_configuration_t;
|
||||
struct usbh_interface intf[CONFIG_USBHOST_MAX_INTERFACES];
|
||||
};
|
||||
|
||||
hubport 结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_hubport {
|
||||
bool connected; /* True: device connected; false: disconnected */
|
||||
bool port_change; /* True: port changed; false: port do not change */
|
||||
uint8_t port; /* Hub port index */
|
||||
uint8_t dev_addr; /* device address */
|
||||
uint8_t speed; /* device speed */
|
||||
usbh_epinfo_t ep0; /* control ep info */
|
||||
struct usbh_hubport {
|
||||
bool connected; /* True: device connected; false: disconnected */
|
||||
uint8_t port; /* Hub port index */
|
||||
uint8_t dev_addr; /* device address */
|
||||
uint8_t speed; /* device speed */
|
||||
usbh_pipe_t ep0; /* control ep pipe info */
|
||||
struct usb_device_descriptor device_desc;
|
||||
struct usbh_configuration config;
|
||||
const char *iManufacturer;
|
||||
const char *iProduct;
|
||||
const char *iSerialNumber;
|
||||
#if 0
|
||||
uint8_t* config_desc;
|
||||
uint8_t* raw_config_desc;
|
||||
#endif
|
||||
struct usb_setup_packet *setup;
|
||||
struct usbh_hub *parent; /*if NULL, is roothub*/
|
||||
} usbh_hubport_t;
|
||||
USB_MEM_ALIGNX struct usb_setup_packet setup;
|
||||
struct usbh_hub *parent;
|
||||
};
|
||||
|
||||
hub 结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_hub {
|
||||
struct usbh_hub {
|
||||
usb_slist_t list;
|
||||
uint8_t index; /* Hub index */
|
||||
uint8_t nports; /* Hub port number */
|
||||
uint8_t dev_addr; /* Hub device address */
|
||||
usbh_epinfo_t intin;
|
||||
uint8_t *int_buffer;
|
||||
struct hub_port_status *port_status;
|
||||
bool connected;
|
||||
bool is_roothub;
|
||||
uint8_t index;
|
||||
uint8_t hub_addr;
|
||||
usbh_pipe_t intin;
|
||||
USB_MEM_ALIGNX uint8_t int_buffer[1];
|
||||
struct usbh_urb intin_urb;
|
||||
struct usb_hub_descriptor hub_desc;
|
||||
struct usbh_hubport child[CONFIG_USBHOST_EHPORTS];
|
||||
struct usbh_hubport *parent; /* Parent hub port */
|
||||
struct usb_work work;
|
||||
} usbh_hub_t;
|
||||
|
||||
usbh_event_notify_handler
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbh_event_notify_handler`` 是 USB 中断中的核心,主要用于处理 **设备连接** 和 **设备断开** 中断,从而唤醒线程去执行枚举。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbh_event_notify_handler(uint8_t event, uint8_t rhport);
|
||||
|
||||
- **event** 中断事件
|
||||
- **rhport** roothub 端口号
|
||||
|
||||
其中 ``event`` 有如下类型:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
enum usbh_event_type {
|
||||
USBH_EVENT_ATTACHED,
|
||||
USBH_EVENT_REMOVED,
|
||||
struct usbh_hubport child[CONFIG_USBHOST_MAX_EHPORTS];
|
||||
struct usbh_hubport *parent;
|
||||
usb_slist_t hub_event_list;
|
||||
};
|
||||
|
||||
usbh_initialize
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbh_initialize`` 用来初始化 usb 主机协议栈,包括:创建插拔检测用的信号量和枚举线程、高低工作队列、初始化 roothub 端点0 配置,初始化 usb 主机控制器。
|
||||
``usbh_initialize`` 用来初始化 usb 主机协议栈,包括:初始化 usb 主机控制器,创建 roothub 设备,创建 hub 检测线程。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
|
||||
Reference in New Issue
Block a user