/* Get a free channel number so that can be distributed to a device endpoint.  */
uint16_t usb_host_getfreech(usb_core_instance *pdev)
/* Get a free channel number so that can be distributed to a device endpoint.  */
uint16_t usb_host_getfreech(usb_core_instance *pdev)
{
    uint8_t tmp_idx;
    uint16_t u16Ret = HC_ERROR;
    for (tmp_idx = 0U ; tmp_idx < USB_MAX_CH_NUM ; tmp_idx++) {
        if ((pdev->host.channel[tmp_idx & (USB_MAX_TX_FIFOS - 1U)] & HC_USED) == 0U) {
            u16Ret = HC_OK;
            break;
        }
    }
    if (u16Ret == HC_OK) {
        u16Ret = tmp_idx;
    } else {
        u16Ret = HC_ERROR;
    }
    return u16Ret;
}