EZ-USB FX3 Technical Reference Manual, Document Number: 001-76074 Rev. *F 98
Universal Serial Bus (USB)
CyU3PUsbEpPrepare (CY_U3P_SUPER_SPEED);
}
6.9.6 USB Disconnect
The following code example implements the USB disconnect handler to handle the USB disconnect event. This event is
detected by the LTSSM_DISCONNECT bit of the LNK_INTR link layer interrupt register.
static void
CyU3PUsbSSDisConnecthandler (
void)
{
/* If we still have VBUS, try to connect in USB 2.0 mode. */
if (CyU3PUsbCanConnect ())
{
if (UIB->otg_ctrl & CY_U3P_UIB_DEV_ENABLE)
{
/* If the 2.0 PHY is already on, simply turn off the USB 3.0 PHY. */
UIB->otg_ctrl &= ~(CY_U3P_UIB_SSDEV_ENABLE | CY_U3P_UIB_SSEPM_ENABLE);
CyU3PBusyWait (2);
/* Need to disable interrupts while updating the MPLL. */
UIB->intr_mask &= ~(CY_U3P_UIB_DEV_CTL_INT | CY_U3P_UIB_DEV_EP_INT |
CY_U3P_UIB_LNK_INT |
CY_U3P_UIB_PROT_INT | CY_U3P_UIB_PROT_EP_INT | CY_U3P_UIB_EPM_URUN);
CyU3PBusyWait (1);
USB3LNK->lnk_phy_conf &= 0x1FFFFFFF;
USB3LNK->lnk_phy_mpll_status = glUsbMpllDefault;
CyU3PBusyWait (1);
UIB->intr_mask |= (CY_U3P_UIB_DEV_CTL_INT | CY_U3P_UIB_DEV_EP_INT |
CY_U3P_UIB_LNK_INT | CY_U3P_UIB_PROT_INT | CY_U3P_UIB_PROT_EP_INT |
CY_U3P_UIB_EPM_URUN);
CyU3PSetUsbCoreClock (2, 0);
}
else
{
glUibDeviceInfo.usbSpeed = CY_U3P_FULL_SPEED;
CyU3PUsbPhyDisable (CyTrue);
if (glUibDeviceInfo.usb2Disable)
{
glUibDeviceInfo.usbState = CY_U3P_USB_CONFIGURED;
glUibDeviceInfo.usbSpeed = CY_U3P_NOT_CONNECTED;
glUibDeviceInfo.isConnected = CyFalse;
if (glUsbEvtCb != NULL)
glUsbEvtCb (CY_U3P_USB_EVENT_USB3_LNKFAIL, 0);
}
else
{
CyU3PUsbPhyEnable (CyFalse);
}
}
}
else
{
/* If no VBUS, disconnect and turn off PHYs. */