/* set the core to be host mode or device mode through the second input parameter.  */
void usb_modeset(LL_USB_TypeDef *USBx, uint8_t mode)
/* set the core to be host mode or device mode through the second input parameter.  */
void usb_modeset(LL_USB_TypeDef *USBx, uint8_t mode)
{
    if (mode == HOST_MODE) {
        MODIFY_REG32(USBx->GREGS->GUSBCFG, USBFS_GUSBCFG_FHMOD | USBFS_GUSBCFG_FDMOD, USBFS_GUSBCFG_FHMOD);
    } else {
        MODIFY_REG32(USBx->GREGS->GUSBCFG, USBFS_GUSBCFG_FHMOD | USBFS_GUSBCFG_FDMOD, USBFS_GUSBCFG_FDMOD);
    }
    usb_mdelay(50UL);
}