/* This routine returns the current speed of the port */
usbPortSpeed_t usb_get_port_speed(usb_module_t *port)
/* This routine returns the current speed of the port */
usbPortSpeed_t usb_get_port_speed(usb_module_t *port)
{
    usbPortSpeed_t speed;
    uint32_t core = (uint32_t)port->controllerID;
    switch (BG_USBC_UH1_PORTSC1_PSPD(HW_USBC_PORTSC1_RD(core))) { 
    case usbSpeedFull:
        speed = usbSpeedFull;
        printf("Connected at full-speed\n");
        break;
    case usbSpeedLow:
        speed = usbSpeedLow;
        printf("Connected at low-speed\n");
        break;
    case usbSpeedHigh:
        speed = usbSpeedHigh;
        printf("Connected at high-speed\n");
        break;
    default:
        speed = usbSpeedUnknown;
        printf("Invalid port speed\n");
        break;
    }
    printf("PORTSC = 0x%08x\n", HW_USBC_PORTSC1_RD(core));
    return speed;
}