diff options
| author | tangyuxin <[email protected]> | 2017-11-11 10:51:47 +0800 |
|---|---|---|
| committer | tangyuxin <[email protected]> | 2017-11-11 10:53:08 +0800 |
| commit | cc54e0a74ef1d6a4b13802915f80be213cf74a7c (patch) | |
| tree | 62fffb777f60b1e35bce87abe5fdb016683b6314 /components/drivers/include | |
| parent | f7a6078c5c7bf36fa87f72ccf61302de07889778 (diff) | |
[usb]update usb stack
Diffstat (limited to 'components/drivers/include')
| -rw-r--r-- | components/drivers/include/drivers/usb_common.h | 35 | ||||
| -rw-r--r-- | components/drivers/include/drivers/usb_device.h | 22 |
2 files changed, 31 insertions, 26 deletions
diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h index 1e9cf3dc9f..866909f3a7 100644 --- a/components/drivers/include/drivers/usb_common.h +++ b/components/drivers/include/drivers/usb_common.h @@ -313,12 +313,12 @@ typedef struct uiad_descriptor* uiad_desc_t; struct uendpoint_descriptor { - rt_uint8_t bLength; - rt_uint8_t type; - rt_uint8_t bEndpointAddress; - rt_uint8_t bmAttributes; + rt_uint8_t bLength; + rt_uint8_t type; + rt_uint8_t bEndpointAddress; + rt_uint8_t bmAttributes; rt_uint16_t wMaxPacketSize; - rt_uint8_t bInterval; + rt_uint8_t bInterval; }; typedef struct uendpoint_descriptor* uep_desc_t; @@ -358,33 +358,38 @@ struct usb_qualifier_descriptor rt_uint8_t bRESERVED; } __attribute__ ((packed)); +#ifndef HID_SUB_DESCRIPTOR_MAX +#define HID_SUB_DESCRIPTOR_MAX 1 +#endif struct uhid_descriptor { - rt_uint8_t bLength; - rt_uint8_t type; + rt_uint8_t bLength; + rt_uint8_t type; rt_uint16_t bcdHID; - rt_uint8_t bCountryCode; - rt_uint8_t bNumDescriptors; + rt_uint8_t bCountryCode; + rt_uint8_t bNumDescriptors; struct hid_descriptor_list { rt_uint8_t type; rt_uint16_t wLength; - }Descriptor[1]; + }Descriptor[HID_SUB_DESCRIPTOR_MAX]; }; typedef struct uhid_descriptor* uhid_desc_t; struct urequest { - rt_uint8_t request_type; - rt_uint8_t request; - rt_uint16_t value; - rt_uint16_t index; - rt_uint16_t length; + rt_uint8_t request_type; + rt_uint8_t bRequest; + rt_uint16_t wValue; + rt_uint16_t wIndex; + rt_uint16_t wLength; }; typedef struct urequest* ureq_t; #ifndef MIN #define MIN(a, b) (a < b ? a : b) +#endif +#ifndef MAX #define MAX(a, b) (a > b ? a : b) #endif diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h index b104da6ab9..fbbae7edb9 100644 --- a/components/drivers/include/drivers/usb_device.h +++ b/components/drivers/include/drivers/usb_device.h @@ -28,13 +28,13 @@ #define __USB_DEVICE_H__ #include <rtthread.h> -#include "usb_common.h" +#include "drivers/usb_common.h" /* Vendor ID */ #ifdef USB_VENDOR_ID -#define _VENDOR_ID USB_VENDOR_ID +#define _VENDOR_ID USB_VENDOR_ID #else -#define _VENDOR_ID 0x0EFF +#define _VENDOR_ID 0x0EFF #endif /* Product ID */ #ifdef USB_PRODUCT_ID @@ -76,7 +76,7 @@ typedef enum /* request to read full count */ UIO_REQUEST_READ_FULL, /* request to read any count */ - UIO_REQUEST_READ_MOST, + UIO_REQUEST_READ_BEST, /* request to write full count */ UIO_REQUEST_WRITE, }UIO_REQUEST_TYPE; @@ -99,11 +99,11 @@ struct udcd_ops struct ep_id { - rt_uint8_t addr; - rt_uint8_t type; - rt_uint8_t dir; - rt_uint8_t maxpacket; - rt_uint8_t status; + rt_uint8_t addr; + rt_uint8_t type; + rt_uint8_t dir; + rt_uint16_t maxpacket; + rt_uint8_t status; }; typedef rt_err_t (*udep_handler_t)(struct ufunction* func, rt_size_t size); @@ -238,7 +238,7 @@ struct udev_msg udcd_t dcd; union { - struct ep_msg ep_msg; + struct ep_msg ep_msg; struct urequest setup; } content; }; @@ -295,7 +295,7 @@ rt_err_t rt_usbd_ep0_clear_stall(udevice_t device); rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct urequest* setup); rt_err_t rt_usbd_ep0_in_handler(udcd_t dcd); rt_err_t rt_usbd_ep0_out_handler(udcd_t dcd, rt_size_t size); -rt_err_t rt_usbd_ep_in_handler(udcd_t dcd, rt_uint8_t address); +rt_err_t rt_usbd_ep_in_handler(udcd_t dcd, rt_uint8_t address, rt_size_t size); rt_err_t rt_usbd_ep_out_handler(udcd_t dcd, rt_uint8_t address, rt_size_t size); rt_err_t rt_usbd_reset_handler(udcd_t dcd); rt_err_t rt_usbd_connect_handler(udcd_t dcd); |
