merge latest usb class with workaround
This commit is contained in:
parent
6cafbf07ce
commit
0bfb881168
|
@ -589,8 +589,9 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
|
||||||
|
|
||||||
/* create a cdc function */
|
/* create a cdc function */
|
||||||
func = rt_usbd_function_new(device, &dev_desc, &ops);
|
func = rt_usbd_function_new(device, &dev_desc, &ops);
|
||||||
//not support HS
|
|
||||||
//rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
/* support HS */
|
||||||
|
rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||||
|
|
||||||
/* allocate memory for cdc vcom data */
|
/* allocate memory for cdc vcom data */
|
||||||
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
|
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct hid_s
|
||||||
uep_t ep_in;
|
uep_t ep_in;
|
||||||
uep_t ep_out;
|
uep_t ep_out;
|
||||||
int status;
|
int status;
|
||||||
rt_uint16_t protocol;
|
rt_uint8_t protocol;
|
||||||
rt_uint8_t report_buf[MAX_REPORT_SIZE];
|
rt_uint8_t report_buf[MAX_REPORT_SIZE];
|
||||||
struct rt_messagequeue hid_mq;
|
struct rt_messagequeue hid_mq;
|
||||||
};
|
};
|
||||||
|
@ -246,7 +246,7 @@ static struct udevice_descriptor _dev_desc =
|
||||||
USB_DESC_LENGTH_DEVICE, //bLength;
|
USB_DESC_LENGTH_DEVICE, //bLength;
|
||||||
USB_DESC_TYPE_DEVICE, //type;
|
USB_DESC_TYPE_DEVICE, //type;
|
||||||
USB_BCD_VERSION, //bcdUSB;
|
USB_BCD_VERSION, //bcdUSB;
|
||||||
USB_CLASS_HID, //bDeviceClass;
|
0x0, //bDeviceClass;
|
||||||
0x00, //bDeviceSubClass;
|
0x00, //bDeviceSubClass;
|
||||||
0x00, //bDeviceProtocol;
|
0x00, //bDeviceProtocol;
|
||||||
64, //bMaxPacketSize0;
|
64, //bMaxPacketSize0;
|
||||||
|
@ -266,8 +266,8 @@ static struct usb_qualifier_descriptor dev_qualifier =
|
||||||
sizeof(dev_qualifier), //bLength
|
sizeof(dev_qualifier), //bLength
|
||||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||||
0x0200, //bcdUSB
|
0x0200, //bcdUSB
|
||||||
USB_CLASS_MASS_STORAGE, //bDeviceClass
|
0x0, //bDeviceClass
|
||||||
0x06, //bDeviceSubClass
|
0x0, //bDeviceSubClass
|
||||||
0x50, //bDeviceProtocol
|
0x50, //bDeviceProtocol
|
||||||
64, //bMaxPacketSize0
|
64, //bMaxPacketSize0
|
||||||
0x01, //bNumConfigurations
|
0x01, //bNumConfigurations
|
||||||
|
@ -347,7 +347,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
|
||||||
USB_DYNAMIC | USB_DIR_IN,
|
USB_DYNAMIC | USB_DIR_IN,
|
||||||
USB_EP_ATTR_INT,
|
USB_EP_ATTR_INT,
|
||||||
0x40,
|
0x40,
|
||||||
0x01,
|
0x0A,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Endpoint Descriptor OUT */
|
/* Endpoint Descriptor OUT */
|
||||||
|
@ -458,6 +458,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
|
||||||
|
|
||||||
struct hid_s *data = (struct hid_s *) func->user_data;
|
struct hid_s *data = (struct hid_s *) func->user_data;
|
||||||
|
|
||||||
|
|
||||||
switch (setup->bRequest)
|
switch (setup->bRequest)
|
||||||
{
|
{
|
||||||
case USB_REQ_GET_DESCRIPTOR:
|
case USB_REQ_GET_DESCRIPTOR:
|
||||||
|
@ -486,7 +487,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
|
||||||
dcd_ep0_send_status(func->device->dcd);
|
dcd_ep0_send_status(func->device->dcd);
|
||||||
break;
|
break;
|
||||||
case USB_HID_REQ_GET_PROTOCOL:
|
case USB_HID_REQ_GET_PROTOCOL:
|
||||||
rt_usbd_ep0_write(func->device, &data->protocol,2);
|
rt_usbd_ep0_write(func->device, &data->protocol,1);
|
||||||
break;
|
break;
|
||||||
case USB_HID_REQ_SET_REPORT:
|
case USB_HID_REQ_SET_REPORT:
|
||||||
|
|
||||||
|
@ -692,8 +693,9 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
|
||||||
|
|
||||||
/* create a cdc function */
|
/* create a cdc function */
|
||||||
func = rt_usbd_function_new(device, &_dev_desc, &ops);
|
func = rt_usbd_function_new(device, &_dev_desc, &ops);
|
||||||
//not support hs
|
|
||||||
//rt_usbd_device_set_qualifier(device, &_dev_qualifier);
|
/* For high speed mode supporting */
|
||||||
|
rt_usbd_device_set_qualifier(device, &dev_qualifier);
|
||||||
|
|
||||||
/* allocate memory for cdc vcom data */
|
/* allocate memory for cdc vcom data */
|
||||||
data = (struct hid_s*)rt_malloc(sizeof(struct hid_s));
|
data = (struct hid_s*)rt_malloc(sizeof(struct hid_s));
|
||||||
|
|
|
@ -78,9 +78,9 @@ static struct udevice_descriptor dev_desc =
|
||||||
USB_DESC_LENGTH_DEVICE, //bLength;
|
USB_DESC_LENGTH_DEVICE, //bLength;
|
||||||
USB_DESC_TYPE_DEVICE, //type;
|
USB_DESC_TYPE_DEVICE, //type;
|
||||||
USB_BCD_VERSION, //bcdUSB;
|
USB_BCD_VERSION, //bcdUSB;
|
||||||
0x00, //bDeviceClass;
|
USB_CLASS_MASS_STORAGE, //bDeviceClass;
|
||||||
0x00, //bDeviceSubClass;
|
0x06, //bDeviceSubClass;
|
||||||
0x00, //bDeviceProtocol;
|
0x50, //bDeviceProtocol;
|
||||||
0x40, //bMaxPacketSize0;
|
0x40, //bMaxPacketSize0;
|
||||||
_VENDOR_ID, //idVendor;
|
_VENDOR_ID, //idVendor;
|
||||||
_PRODUCT_ID, //idProduct;
|
_PRODUCT_ID, //idProduct;
|
||||||
|
@ -98,9 +98,9 @@ static struct usb_qualifier_descriptor dev_qualifier =
|
||||||
sizeof(dev_qualifier), //bLength
|
sizeof(dev_qualifier), //bLength
|
||||||
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType
|
||||||
0x0200, //bcdUSB
|
0x0200, //bcdUSB
|
||||||
0x00, //bDeviceClass
|
USB_CLASS_MASS_STORAGE, //bDeviceClass
|
||||||
0x00, //bDeviceSubClass
|
0x06, //bDeviceSubClass
|
||||||
0x00, //bDeviceProtocol
|
0x50, //bDeviceProtocol
|
||||||
64, //bMaxPacketSize0
|
64, //bMaxPacketSize0
|
||||||
0x01, //bNumConfigurations
|
0x01, //bNumConfigurations
|
||||||
0,
|
0,
|
||||||
|
@ -610,8 +610,11 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
|
||||||
rt_usbd_ep_set_stall(func->device, data->ep_out);
|
rt_usbd_ep_set_stall(func->device, data->ep_out);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rt_usbd_ep_set_stall(func->device, data->ep_in);
|
//rt_kprintf("warning:in stall path but not stall\n");
|
||||||
|
|
||||||
|
/* FIXME: Disable the operation or the disk cannot work. */
|
||||||
|
//rt_usbd_ep_set_stall(func->device, data->ep_in);
|
||||||
}
|
}
|
||||||
data->csw_response.data_reside = 0;
|
data->csw_response.data_reside = 0;
|
||||||
}
|
}
|
||||||
|
@ -719,9 +722,22 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//workaround: for stability in full-speed mode
|
||||||
|
else if(cmd->cmd_len == 12)
|
||||||
|
{
|
||||||
|
switch(cmd->type)
|
||||||
|
{
|
||||||
|
case COUNT:
|
||||||
|
data->cb_data_size = cbw->cb[4];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
|
rt_kprintf("cmd_len error %d\n", cmd->cmd_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,7 +753,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
|
||||||
data = (struct mstorage*)func->user_data;
|
data = (struct mstorage*)func->user_data;
|
||||||
if(cmd->cmd_len != cbw->cb_len)
|
if(cmd->cmd_len != cbw->cb_len)
|
||||||
{
|
{
|
||||||
// rt_kprintf("cb_len error\n");
|
rt_kprintf("cb_len error\n");
|
||||||
cmd->cmd_len = cbw->cb_len;
|
cmd->cmd_len = cbw->cb_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,7 +784,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd,
|
||||||
|
|
||||||
if(cbw->xfer_len < data->cb_data_size)
|
if(cbw->xfer_len < data->cb_data_size)
|
||||||
{
|
{
|
||||||
// rt_kprintf("xfer_len < data_size\n");
|
rt_kprintf("xfer_len < data_size\n");
|
||||||
data->cb_data_size = cbw->xfer_len;
|
data->cb_data_size = cbw->xfer_len;
|
||||||
data->csw_response.status = 1;
|
data->csw_response.status = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue