/* This function will do debouce, it is invoked when sub device attached to the hub port. */
rt_err_t rt_usb_hub_port_debounce(uhubinst_t uhub, rt_uint16_t port)
/* This function will do debouce, it is invoked when sub device attached to the hub port. */
rt_err_t rt_usb_hub_port_debounce(uhubinst_t uhub, rt_uint16_t port)
{
    rt_err_t ret;
    int i = 0, times = 20;
    rt_uint32_t pstatus;
    rt_bool_t connect = RT_TRUE;
    RT_ASSERT(uhub != RT_NULL);
    for(i=0; i<times; i++)
    {
        ret = rt_usb_hub_get_port_status(uhub, port, (rt_uint8_t*)&pstatus);
        if(ret != RT_EOK) return ret;
        if(!(pstatus & PORT_CCS)) 
        {
            connect = RT_FALSE;
            break;
        }
        rt_thread_delay(1);
    }        
    if(connect) return RT_EOK;
    else return -RT_ERROR;
}