/* This function will allocate an usb device instance from system. */
uinst_t rt_usb_alloc_instance(void)
/* This function will allocate an usb device instance from system. */
uinst_t rt_usb_alloc_instance(void)
{
    int i;
    rt_enter_critical();
    for(i=0; i<USB_MAX_DEVICE; i++)
    {
        if(uinst[i].status != UINST_STATUS_IDLE) continue;
        rt_memset(&uinst[i], 0, sizeof(struct uinstance));
        uinst[i].status = UINST_STATUS_BUSY;
        uinst[i].index = i + 1;
        uinst[i].address = 0;
        uinst[i].max_packet_size = 0x8;        
        rt_exit_critical();
        return &uinst[i];
    }            
    rt_exit_critical();     
    return RT_NULL;
}