/* Flush a Tx FIFO whose index is num.  */
void usb_txfifoflush(LL_USB_TypeDef *USBx, uint32_t num)
/* Flush a Tx FIFO whose index is num.  */
void usb_txfifoflush(LL_USB_TypeDef *USBx, uint32_t num)
{
    __IO uint32_t u32grstctl;
    __IO uint32_t u32Tmp = 0UL;
    u32grstctl = USBFS_GRSTCTL_TXFFLSH | ((num & 0x1FUL) << USBFS_GRSTCTL_TXFNUM_POS);
    WRITE_REG32(USBx->GREGS->GRSTCTL, u32grstctl);
    do {
        u32grstctl = READ_REG32(USBx->GREGS->GRSTCTL);
        if (u32Tmp <= 200000UL) {
            u32Tmp++;
        } else {
            break;
        }
        usb_udelay(1UL);
    } while (0UL != (u32grstctl & USBFS_GRSTCTL_TXFFLSH));
    usb_udelay(3UL);
}