未验证 提交 10de75fa 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #1744 from liruncong/master

消除usb结构体gcc编译时的相关警告
...@@ -133,83 +133,103 @@ const static struct ucdc_comm_descriptor _comm_desc = ...@@ -133,83 +133,103 @@ const static struct ucdc_comm_descriptor _comm_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */ /* Interface Association Descriptor */
USB_DESC_LENGTH_IAD, {
USB_DESC_TYPE_IAD, USB_DESC_LENGTH_IAD,
USB_DYNAMIC, USB_DESC_TYPE_IAD,
0x02, USB_DYNAMIC,
USB_CDC_CLASS_COMM, 0x02,
USB_CDC_SUBCLASS_ACM, USB_CDC_CLASS_COMM,
USB_CDC_PROTOCOL_V25TER, USB_CDC_SUBCLASS_ACM,
0x00, USB_CDC_PROTOCOL_V25TER,
0x00,
},
#endif #endif
/* Interface Descriptor */ /* Interface Descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, USB_DESC_TYPE_INTERFACE,
0x00, USB_DYNAMIC,
0x01, 0x00,
USB_CDC_CLASS_COMM, 0x01,
USB_CDC_SUBCLASS_ACM, USB_CDC_CLASS_COMM,
USB_CDC_PROTOCOL_V25TER, USB_CDC_SUBCLASS_ACM,
0x00, USB_CDC_PROTOCOL_V25TER,
0x00,
},
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, {
USB_CDC_CS_INTERFACE, 0x05,
USB_CDC_SCS_HEADER, USB_CDC_CS_INTERFACE,
0x0110, USB_CDC_SCS_HEADER,
0x0110,
},
/* Call Management Functional Descriptor */ /* Call Management Functional Descriptor */
0x05, {
USB_CDC_CS_INTERFACE, 0x05,
USB_CDC_SCS_CALL_MGMT, USB_CDC_CS_INTERFACE,
0x00, USB_CDC_SCS_CALL_MGMT,
USB_DYNAMIC, 0x00,
USB_DYNAMIC,
},
/* Abstract Control Management Functional Descriptor */ /* Abstract Control Management Functional Descriptor */
0x04, {
USB_CDC_CS_INTERFACE, 0x04,
USB_CDC_SCS_ACM, USB_CDC_CS_INTERFACE,
0x02, USB_CDC_SCS_ACM,
0x02,
},
/* Union Functional Descriptor */ /* Union Functional Descriptor */
0x05, {
USB_CDC_CS_INTERFACE, 0x05,
USB_CDC_SCS_UNION, USB_CDC_CS_INTERFACE,
USB_DYNAMIC, USB_CDC_SCS_UNION,
USB_DYNAMIC, USB_DYNAMIC,
USB_DYNAMIC,
},
/* Endpoint Descriptor */ /* Endpoint Descriptor */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_INT, USB_DYNAMIC | USB_DIR_IN,
0x08, USB_EP_ATTR_INT,
0xFF, 0x08,
0xFF,
},
}; };
/* data interface descriptor */ /* data interface descriptor */
const static struct ucdc_data_descriptor _data_desc = const static struct ucdc_data_descriptor _data_desc =
{ {
/* interface descriptor */ /* interface descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, USB_DESC_TYPE_INTERFACE,
0x00, USB_DYNAMIC,
0x02, 0x00,
USB_CDC_CLASS_DATA, 0x02,
0x00, USB_CDC_CLASS_DATA,
0x00, 0x00,
0x00, 0x00,
0x00,
},
/* endpoint, bulk out */ /* endpoint, bulk out */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_OUT, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DYNAMIC | USB_DIR_OUT,
USB_CDC_BUFSIZE, USB_EP_ATTR_BULK,
0x00, USB_CDC_BUFSIZE,
0x00,
},
/* endpoint, bulk in */ /* endpoint, bulk in */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DYNAMIC | USB_DIR_IN,
USB_CDC_BUFSIZE, USB_EP_ATTR_BULK,
0x00, USB_CDC_BUFSIZE,
0x00,
},
}; };
static char serno[_SER_NO_LEN + 1] = {'\0'}; static char serno[_SER_NO_LEN + 1] = {'\0'};
......
...@@ -80,52 +80,64 @@ const static struct ucdc_eth_descriptor _comm_desc = ...@@ -80,52 +80,64 @@ const static struct ucdc_eth_descriptor _comm_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */ /* Interface Association Descriptor */
USB_DESC_LENGTH_IAD, {
USB_DESC_TYPE_IAD, USB_DESC_LENGTH_IAD,
USB_DYNAMIC, USB_DESC_TYPE_IAD,
0x02, USB_DYNAMIC,
USB_CDC_CLASS_COMM, 0x02,
USB_CDC_SUBCLASS_ETH, USB_CDC_CLASS_COMM,
USB_CDC_PROTOCOL_NONE, USB_CDC_SUBCLASS_ETH,
0x00, USB_CDC_PROTOCOL_NONE,
0x00,
},
#endif #endif
/* Interface Descriptor */ /* Interface Descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, USB_DESC_TYPE_INTERFACE,
0x00, USB_DYNAMIC,
0x01, 0x00,
USB_CDC_CLASS_COMM, 0x01,
USB_CDC_SUBCLASS_ETH, USB_CDC_CLASS_COMM,
USB_CDC_PROTOCOL_NONE, USB_CDC_SUBCLASS_ETH,
0x00, USB_CDC_PROTOCOL_NONE,
0x00,
},
/* Header Functional Descriptor */ /* Header Functional Descriptor */
sizeof(struct ucdc_header_descriptor), {
USB_CDC_CS_INTERFACE, sizeof(struct ucdc_header_descriptor),
USB_CDC_SCS_HEADER, USB_CDC_CS_INTERFACE,
0x0110, USB_CDC_SCS_HEADER,
0x0110,
},
/* Union Functional Descriptor */ /* Union Functional Descriptor */
sizeof(struct ucdc_union_descriptor), {
USB_CDC_CS_INTERFACE, sizeof(struct ucdc_union_descriptor),
USB_CDC_SCS_UNION, USB_CDC_CS_INTERFACE,
USB_DYNAMIC, USB_CDC_SCS_UNION,
USB_DYNAMIC, USB_DYNAMIC,
USB_DYNAMIC,
},
/* Abstract Control Management Functional Descriptor */ /* Abstract Control Management Functional Descriptor */
sizeof(struct ucdc_enet_descriptor), {
USB_CDC_CS_INTERFACE, sizeof(struct ucdc_enet_descriptor),
USB_CDC_SCS_ETH, USB_CDC_CS_INTERFACE,
USB_STRING_SERIAL_INDEX, USB_CDC_SCS_ETH,
{0,0,0,0}, USB_STRING_SERIAL_INDEX,
USB_ETH_MTU, {0,0,0,0},
0x00, USB_ETH_MTU,
0x00, 0x00,
0x00,
},
/* Endpoint Descriptor */ /* Endpoint Descriptor */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DIR_IN | USB_DYNAMIC, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_INT, USB_DIR_IN | USB_DYNAMIC,
0x08, USB_EP_ATTR_INT,
0xFF, 0x08,
0xFF,
},
}; };
/* data interface descriptor */ /* data interface descriptor */
...@@ -133,29 +145,35 @@ ALIGN(4) ...@@ -133,29 +145,35 @@ ALIGN(4)
const static struct ucdc_data_descriptor _data_desc = const static struct ucdc_data_descriptor _data_desc =
{ {
/* interface descriptor */ /* interface descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, USB_DESC_TYPE_INTERFACE,
0x00, USB_DYNAMIC,
0x02, 0x00,
USB_CDC_CLASS_DATA, 0x02,
USB_CDC_SUBCLASS_ETH, USB_CDC_CLASS_DATA,
0x00, USB_CDC_SUBCLASS_ETH,
0x00, 0x00,
0x00,
},
/* endpoint, bulk out */ /* endpoint, bulk out */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DIR_OUT | USB_DYNAMIC, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DIR_OUT | USB_DYNAMIC,
USB_DYNAMIC, USB_EP_ATTR_BULK,
0x00, USB_DYNAMIC,
0x00,
},
/* endpoint, bulk in */ /* endpoint, bulk in */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DYNAMIC | USB_DIR_IN,
USB_DYNAMIC, USB_EP_ATTR_BULK,
0x00, USB_DYNAMIC,
0x00,
},
}; };
ALIGN(4) ALIGN(4)
......
...@@ -275,71 +275,85 @@ const static struct uhid_comm_descriptor _hid_comm_desc = ...@@ -275,71 +275,85 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */ /* Interface Association Descriptor */
USB_DESC_LENGTH_IAD, {
USB_DESC_TYPE_IAD, USB_DESC_LENGTH_IAD,
USB_DYNAMIC, USB_DESC_TYPE_IAD,
0x01, USB_DYNAMIC,
0x03, /* bInterfaceClass: HID */ 0x01,
0x03, /* bInterfaceClass: HID */
#if defined(RT_USB_DEVICE_HID_KEYBOARD)||defined(RT_USB_DEVICE_HID_MOUSE) #if defined(RT_USB_DEVICE_HID_KEYBOARD)||defined(RT_USB_DEVICE_HID_MOUSE)
USB_HID_SUBCLASS_BOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ USB_HID_SUBCLASS_BOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
#else #else
USB_HID_SUBCLASS_NOBOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ USB_HID_SUBCLASS_NOBOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
#endif #endif
#if !defined(RT_USB_DEVICE_HID_KEYBOARD)||!defined(RT_USB_DEVICE_HID_MOUSE)||!defined(RT_USB_DEVICE_HID_MEDIA) #if !defined(RT_USB_DEVICE_HID_KEYBOARD)||!defined(RT_USB_DEVICE_HID_MOUSE)||!defined(RT_USB_DEVICE_HID_MEDIA)
USB_HID_PROTOCOL_NONE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ USB_HID_PROTOCOL_NONE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#elif !defined(RT_USB_DEVICE_HID_MOUSE) #elif !defined(RT_USB_DEVICE_HID_MOUSE)
USB_HID_PROTOCOL_KEYBOARD, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ USB_HID_PROTOCOL_KEYBOARD, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#else #else
USB_HID_PROTOCOL_MOUSE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ USB_HID_PROTOCOL_MOUSE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#endif #endif
0x00, 0x00,
#endif #endif
},
/* Interface Descriptor */ /* Interface Descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, /* bInterfaceNumber: Number of Interface */ USB_DESC_TYPE_INTERFACE,
0x00, /* bAlternateSetting: Alternate setting */ USB_DYNAMIC, /* bInterfaceNumber: Number of Interface */
0x02, /* bNumEndpoints */ 0x00, /* bAlternateSetting: Alternate setting */
0x03, /* bInterfaceClass: HID */ 0x02, /* bNumEndpoints */
0x03, /* bInterfaceClass: HID */
#if defined(RT_USB_DEVICE_HID_KEYBOARD)||defined(RT_USB_DEVICE_HID_MOUSE) #if defined(RT_USB_DEVICE_HID_KEYBOARD)||defined(RT_USB_DEVICE_HID_MOUSE)
USB_HID_SUBCLASS_BOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ USB_HID_SUBCLASS_BOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
#else #else
USB_HID_SUBCLASS_NOBOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ USB_HID_SUBCLASS_NOBOOT, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
#endif #endif
#if !defined(RT_USB_DEVICE_HID_KEYBOARD)||!defined(RT_USB_DEVICE_HID_MOUSE)||!defined(RT_USB_DEVICE_HID_MEDIA) #if !defined(RT_USB_DEVICE_HID_KEYBOARD)||!defined(RT_USB_DEVICE_HID_MOUSE)||!defined(RT_USB_DEVICE_HID_MEDIA)
USB_HID_PROTOCOL_NONE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ USB_HID_PROTOCOL_NONE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#elif !defined(RT_USB_DEVICE_HID_MOUSE) #elif !defined(RT_USB_DEVICE_HID_MOUSE)
USB_HID_PROTOCOL_KEYBOARD, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ USB_HID_PROTOCOL_KEYBOARD, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#else #else
USB_HID_PROTOCOL_MOUSE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ USB_HID_PROTOCOL_MOUSE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#endif #endif
0, /* iInterface: Index of string descriptor */ 0, /* iInterface: Index of string descriptor */
},
/* HID Descriptor */ /* HID Descriptor */
HID_DESCRIPTOR_SIZE, /* bLength: HID Descriptor size */ {
HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */ HID_DESCRIPTOR_SIZE, /* bLength: HID Descriptor size */
0x0110, /* bcdHID: HID Class Spec release number */ HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
0x00, /* bCountryCode: Hardware target country */ 0x0110, /* bcdHID: HID Class Spec release number */
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */ 0x00, /* bCountryCode: Hardware target country */
0x22, /* bDescriptorType */ 0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
sizeof(_report_desc), /* wItemLength: Total length of Report descriptor */ {
{
0x22, /* bDescriptorType */
sizeof(_report_desc), /* wItemLength: Total length of Report descriptor */
},
},
},
/* Endpoint Descriptor IN */ /* Endpoint Descriptor IN */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_INT, USB_DYNAMIC | USB_DIR_IN,
0x40, USB_EP_ATTR_INT,
0x01, 0x40,
0x01,
},
/* Endpoint Descriptor OUT */ /* Endpoint Descriptor OUT */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_OUT, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_INT, USB_DYNAMIC | USB_DIR_OUT,
0x40, USB_EP_ATTR_INT,
0x01, 0x40,
0x01,
},
}; };
...@@ -480,12 +494,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup) ...@@ -480,12 +494,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
rt_usbd_ep0_read(func->device, data->report_buf, setup->wLength, _hid_set_report_callback); rt_usbd_ep0_read(func->device, data->report_buf, setup->wLength, _hid_set_report_callback);
break; break;
case USB_HID_REQ_SET_IDLE: case USB_HID_REQ_SET_IDLE:
{
int duration = (setup->wValue >> 8);
int report_id = (setup->wValue & 0xFF);
dcd_ep0_send_status(func->device->dcd); dcd_ep0_send_status(func->device->dcd);
}
break; break;
case USB_HID_REQ_SET_PROTOCOL: case USB_HID_REQ_SET_PROTOCOL:
data->protocol = setup->wValue; data->protocol = setup->wValue;
......
...@@ -120,38 +120,46 @@ const static struct umass_descriptor _mass_desc = ...@@ -120,38 +120,46 @@ const static struct umass_descriptor _mass_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */ /* Interface Association Descriptor */
USB_DESC_LENGTH_IAD, {
USB_DESC_TYPE_IAD, USB_DESC_LENGTH_IAD,
USB_DYNAMIC, USB_DESC_TYPE_IAD,
0x01, USB_DYNAMIC,
USB_CLASS_MASS_STORAGE, 0x01,
0x06, USB_CLASS_MASS_STORAGE,
0x50, 0x06,
0x00, 0x50,
0x00,
},
#endif #endif
USB_DESC_LENGTH_INTERFACE, //bLength; {
USB_DESC_TYPE_INTERFACE, //type; USB_DESC_LENGTH_INTERFACE, //bLength;
USB_DYNAMIC, //bInterfaceNumber; USB_DESC_TYPE_INTERFACE, //type;
0x00, //bAlternateSetting; USB_DYNAMIC, //bInterfaceNumber;
0x02, //bNumEndpoints 0x00, //bAlternateSetting;
USB_CLASS_MASS_STORAGE, //bInterfaceClass; 0x02, //bNumEndpoints
0x06, //bInterfaceSubClass; USB_CLASS_MASS_STORAGE, //bInterfaceClass;
0x50, //bInterfaceProtocol; 0x06, //bInterfaceSubClass;
0x00, //iInterface; 0x50, //bInterfaceProtocol;
0x00, //iInterface;
USB_DESC_LENGTH_ENDPOINT, //bLength; },
USB_DESC_TYPE_ENDPOINT, //type;
USB_DYNAMIC | USB_DIR_OUT, //bEndpointAddress; {
USB_EP_ATTR_BULK, //bmAttributes; USB_DESC_LENGTH_ENDPOINT, //bLength;
USB_DYNAMIC, //wMaxPacketSize; USB_DESC_TYPE_ENDPOINT, //type;
0x00, //bInterval; USB_DYNAMIC | USB_DIR_OUT, //bEndpointAddress;
USB_EP_ATTR_BULK, //bmAttributes;
USB_DESC_LENGTH_ENDPOINT, //bLength; USB_DYNAMIC, //wMaxPacketSize;
USB_DESC_TYPE_ENDPOINT, //type; 0x00, //bInterval;
USB_DYNAMIC | USB_DIR_IN, //bEndpointAddress; },
USB_EP_ATTR_BULK, //bmAttributes;
USB_DYNAMIC, //wMaxPacketSize; {
0x00, //bInterval; USB_DESC_LENGTH_ENDPOINT, //bLength;
USB_DESC_TYPE_ENDPOINT, //type;
USB_DYNAMIC | USB_DIR_IN, //bEndpointAddress;
USB_EP_ATTR_BULK, //bmAttributes;
USB_DYNAMIC, //wMaxPacketSize;
0x00, //bInterval;
},
}; };
const static char* _ustring[] = const static char* _ustring[] =
...@@ -751,8 +759,8 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd, ...@@ -751,8 +759,8 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
return RT_FALSE; return RT_FALSE;
} }
if((cbw->dflags & USB_DIR_IN) && cmd->dir == DIR_OUT || if(((cbw->dflags & USB_DIR_IN) && (cmd->dir == DIR_OUT)) ||
!(cbw->dflags & USB_DIR_IN) && cmd->dir == DIR_IN) (!(cbw->dflags & USB_DIR_IN) && (cmd->dir == DIR_IN)))
{ {
rt_kprintf("dir error\n"); rt_kprintf("dir error\n");
return RT_FALSE; return RT_FALSE;
......
...@@ -106,54 +106,68 @@ const static struct ucdc_comm_descriptor _comm_desc = ...@@ -106,54 +106,68 @@ const static struct ucdc_comm_descriptor _comm_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */ /* Interface Association Descriptor */
USB_DESC_LENGTH_IAD, {
USB_DESC_TYPE_IAD, USB_DESC_LENGTH_IAD,
USB_DYNAMIC, USB_DESC_TYPE_IAD,
0x02, USB_DYNAMIC,
USB_CDC_CLASS_COMM, 0x02,
USB_CDC_SUBCLASS_ACM, USB_CDC_CLASS_COMM,
USB_CDC_PROTOCOL_VENDOR, USB_CDC_SUBCLASS_ACM,
0x00, USB_CDC_PROTOCOL_VENDOR,
0x00,
},
#endif #endif
/* Interface Descriptor */ /* Interface Descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, USB_DESC_TYPE_INTERFACE,
0x00, USB_DYNAMIC,
0x01, 0x00,
USB_CDC_CLASS_COMM, 0x01,
USB_CDC_SUBCLASS_ACM, USB_CDC_CLASS_COMM,
USB_CDC_PROTOCOL_VENDOR, USB_CDC_SUBCLASS_ACM,
0x00, USB_CDC_PROTOCOL_VENDOR,
0x00,
},
/* Header Functional Descriptor */ /* Header Functional Descriptor */
0x05, {
USB_CDC_CS_INTERFACE, 0x05,
USB_CDC_SCS_HEADER, USB_CDC_CS_INTERFACE,
0x0110, USB_CDC_SCS_HEADER,
0x0110,
},
/* Call Management Functional Descriptor */ /* Call Management Functional Descriptor */
0x05, {
USB_CDC_CS_INTERFACE, 0x05,
USB_CDC_SCS_CALL_MGMT, USB_CDC_CS_INTERFACE,
0x00, USB_CDC_SCS_CALL_MGMT,
USB_DYNAMIC, 0x00,
USB_DYNAMIC,
},
/* Abstract Control Management Functional Descriptor */ /* Abstract Control Management Functional Descriptor */
0x04, {
USB_CDC_CS_INTERFACE, 0x04,
USB_CDC_SCS_ACM, USB_CDC_CS_INTERFACE,
0x02, USB_CDC_SCS_ACM,
0x02,
},
/* Union Functional Descriptor */ /* Union Functional Descriptor */
0x05, {
USB_CDC_CS_INTERFACE, 0x05,
USB_CDC_SCS_UNION, USB_CDC_CS_INTERFACE,
USB_DYNAMIC, USB_CDC_SCS_UNION,
USB_DYNAMIC, USB_DYNAMIC,
USB_DYNAMIC,
},
/* Endpoint Descriptor */ /* Endpoint Descriptor */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DIR_IN | USB_DYNAMIC, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_INT, USB_DIR_IN | USB_DYNAMIC,
0x08, USB_EP_ATTR_INT,
0x0A, 0x08,
0x0A,
},
}; };
/* data interface descriptor */ /* data interface descriptor */
...@@ -161,29 +175,35 @@ ALIGN(4) ...@@ -161,29 +175,35 @@ ALIGN(4)
const static struct ucdc_data_descriptor _data_desc = const static struct ucdc_data_descriptor _data_desc =
{ {
/* interface descriptor */ /* interface descriptor */
USB_DESC_LENGTH_INTERFACE, {
USB_DESC_TYPE_INTERFACE, USB_DESC_LENGTH_INTERFACE,
USB_DYNAMIC, USB_DESC_TYPE_INTERFACE,
0x00, USB_DYNAMIC,
0x02, 0x00,
USB_CDC_CLASS_DATA, 0x02,
0x00, USB_CDC_CLASS_DATA,
0x00, 0x00,
0x00, 0x00,
0x00,
},
/* endpoint, bulk out */ /* endpoint, bulk out */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DIR_OUT | USB_DYNAMIC, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DIR_OUT | USB_DYNAMIC,
USB_DYNAMIC, USB_EP_ATTR_BULK,
0x00, USB_DYNAMIC,
0x00,
},
/* endpoint, bulk in */ /* endpoint, bulk in */
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DYNAMIC | USB_DIR_IN,
USB_DYNAMIC, USB_EP_ATTR_BULK,
0x00, USB_DYNAMIC,
0x00,
},
}; };
ALIGN(4) ALIGN(4)
......
...@@ -58,39 +58,47 @@ struct winusb_descriptor _winusb_desc = ...@@ -58,39 +58,47 @@ struct winusb_descriptor _winusb_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */ /* Interface Association Descriptor */
USB_DESC_LENGTH_IAD, {
USB_DESC_TYPE_IAD, USB_DESC_LENGTH_IAD,
USB_DYNAMIC, USB_DESC_TYPE_IAD,
0x01, USB_DYNAMIC,
0xFF, 0x01,
0x00, 0xFF,
0x00, 0x00,
0x00, 0x00,
0x00,
},
#endif #endif
/*interface descriptor*/ /*interface descriptor*/
USB_DESC_LENGTH_INTERFACE, //bLength; {
USB_DESC_TYPE_INTERFACE, //type; USB_DESC_LENGTH_INTERFACE, //bLength;
USB_DYNAMIC, //bInterfaceNumber; USB_DESC_TYPE_INTERFACE, //type;
0x00, //bAlternateSetting; USB_DYNAMIC, //bInterfaceNumber;
0x02, //bNumEndpoints 0x00, //bAlternateSetting;
0xFF, //bInterfaceClass; 0x02, //bNumEndpoints
0x00, //bInterfaceSubClass; 0xFF, //bInterfaceClass;
0x00, //bInterfaceProtocol; 0x00, //bInterfaceSubClass;
0x00, //iInterface; 0x00, //bInterfaceProtocol;
0x00, //iInterface;
},
/*endpoint descriptor*/ /*endpoint descriptor*/
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_OUT, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DYNAMIC | USB_DIR_OUT,
USB_DYNAMIC, USB_EP_ATTR_BULK,
0x00, USB_DYNAMIC,
0x00,
},
/*endpoint descriptor*/ /*endpoint descriptor*/
USB_DESC_LENGTH_ENDPOINT, {
USB_DESC_TYPE_ENDPOINT, USB_DESC_LENGTH_ENDPOINT,
USB_DYNAMIC | USB_DIR_IN, USB_DESC_TYPE_ENDPOINT,
USB_EP_ATTR_BULK, USB_DYNAMIC | USB_DIR_IN,
USB_DYNAMIC, USB_EP_ATTR_BULK,
0x00, USB_DYNAMIC,
0x00,
},
}; };
......
...@@ -36,7 +36,7 @@ static rt_list_t device_list; ...@@ -36,7 +36,7 @@ static rt_list_t device_list;
static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_size_t size); static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_size_t size);
static rt_size_t rt_usbd_ep_read_prepare(udevice_t device, uep_t ep, void *buffer, rt_size_t size); static rt_size_t rt_usbd_ep_read_prepare(udevice_t device, uep_t ep, void *buffer, rt_size_t size);
static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep); static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep);
static rt_err_t rt_usbd_ep_unassign(udevice_t device, uep_t ep); rt_err_t rt_usbd_ep_unassign(udevice_t device, uep_t ep);
/** /**
* This function will handle get_device_descriptor bRequest. * This function will handle get_device_descriptor bRequest.
...@@ -1865,7 +1865,7 @@ static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep) ...@@ -1865,7 +1865,7 @@ static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep)
return -RT_ERROR; return -RT_ERROR;
} }
static rt_err_t rt_usbd_ep_unassign(udevice_t device, uep_t ep) rt_err_t rt_usbd_ep_unassign(udevice_t device, uep_t ep)
{ {
RT_ASSERT(device != RT_NULL); RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->dcd != RT_NULL); RT_ASSERT(device->dcd != RT_NULL);
......
...@@ -78,11 +78,13 @@ static struct usb_qualifier_descriptor dev_qualifier = ...@@ -78,11 +78,13 @@ static struct usb_qualifier_descriptor dev_qualifier =
struct usb_os_comp_id_descriptor usb_comp_id_desc = struct usb_os_comp_id_descriptor usb_comp_id_desc =
{ {
//head section //head section
USB_DYNAMIC, {
0x0100, USB_DYNAMIC,
0x04, 0x0100,
USB_DYNAMIC, 0x04,
{0x00,0x00,0x00,0x00,0x00,0x00,0x00}, USB_DYNAMIC,
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
},
}; };
static rt_list_t class_list; static rt_list_t class_list;
int rt_usbd_class_list_init(void) int rt_usbd_class_list_init(void)
......
...@@ -249,7 +249,7 @@ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_ ...@@ -249,7 +249,7 @@ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_
if(hub->is_roothub) if(hub->is_roothub)
{ {
root_hub_ctrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE, root_hub_ctrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE,
(void*)feature); (void*)(rt_uint32_t)feature);
return RT_EOK; return RT_EOK;
} }
...@@ -290,7 +290,7 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port, ...@@ -290,7 +290,7 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
if(hub->is_roothub) if(hub->is_roothub)
{ {
root_hub_ctrl(hub->hcd, port, RH_SET_PORT_FEATURE, root_hub_ctrl(hub->hcd, port, RH_SET_PORT_FEATURE,
(void*)feature); (void*)(rt_uint32_t)feature);
return RT_EOK; return RT_EOK;
} }
...@@ -413,7 +413,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) ...@@ -413,7 +413,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
RT_DEBUG_LOG(RT_DEBUG_USB, ("port %d status 0x%x\n", i + 1, pstatus)); RT_DEBUG_LOG(RT_DEBUG_USB, ("port %d status 0x%x\n", i + 1, pstatus));
/* check port status change */ /* check port status change */
if ((pstatus & PORT_CCSC)) if (pstatus & PORT_CCSC)
{ {
/* clear port status change feature */ /* clear port status change feature */
rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_CONNECTION); rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_CONNECTION);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册