/* This function will do USB_REQ_GET_DESCRIPTO' request for the usb device instance, */
rt_err_t rt_usb_get_descriptor(uinst_t uinst, rt_uint8_t type, void *buffer, int nbytes)
/* This function will do USB_REQ_GET_DESCRIPTO' request for the usb device instance, */
rt_err_t rt_usb_get_descriptor(uinst_t uinst, rt_uint8_t type, void *buffer, int nbytes)
{
    struct ureqest setup;
    int timeout = 100;
    RT_ASSERT(uinst != RT_NULL);
    setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD | 
        USB_REQ_TYPE_DEVICE;
    setup.request = USB_REQ_GET_DESCRIPTOR;
    setup.index = 0;
    setup.length = nbytes;
    setup.value = type << 8;
    if(rt_usb_hcd_control_xfer(uinst->hcd, uinst, &setup, buffer, nbytes, 
        timeout) != nbytes) return -RT_EIO;
    else return RT_EOK;
}