Hi
I think that there is no need of gUSBConnected in following function as by checking this field OR_RH_PORT_CCS we can determine device is connected or not
What,s the need of this gUSBConnected ?
<void Host_Isr (void) __irq { USB_INT32U int_status; USB_INT32U ie_status;
if ((USB_INT_STAT & 0x00000008) > 0) { int_status = HcInterruptStatus; /* Read Interrupt Status */ ie_status = HcInterruptEnable; /* Read Interrupt enable status */
if (!(int_status & ie_status)) { return; } else { int_status = int_status & ie_status; if (int_status & OR_INTR_STATUS_RHSC) { //root hub status change interrupt /* Root hub status change interrupt */ if (HcRhPortStatus1 & OR_RH_PORT_CSC) { //connected status change inteerupt if (HcRhStatus & OR_RH_STATUS_DRWE) { /* * When DRWE is on, Connect Status Change * means a remote wakeup event. */ HOST_RhscIntr |= 0x01;// JUST SOMETHING FOR A BREAKPOINT } else { /* * When DRWE is off, Connect Status Change * is NOT a remote wakeup event */ if (HcRhPortStatus1 & OR_RH_PORT_CCS) { if (!gUSBConnected) { HOST_TDControlStatus = 0; HOST_WdhIntr = 0; HOST_RhscIntr |= 0x01; gUSBConnected = 1; } else PRINT_Log("Spurious status change (connected)?\n"); } else { if (gUSBConnected) { HcInterruptEnable = 0; // why do we get multiple disc. rupts??? HOST_RhscIntr &= ~0x01; gUSBConnected = 0; } else PRINT_Log("Spurious status change (disconnected)?\n"); } } HcRhPortStatus1 = OR_RH_PORT_CSC; } if (HcRhPortStatus2 & OR_RH_PORT_CSC) { if (HcRhStatus & OR_RH_STATUS_DRWE) { /* * When DRWE is on, Connect Status Change * means a remote wakeup event. */ HOST_RhscIntr |= 0x02;// JUST SOMETHING FOR A BREAKPOINT } else { /* * When DRWE is off, Connect Status Change * is NOT a remote wakeup event */ if (HcRhPortStatus2 & OR_RH_PORT_CCS) { if (!gUSBConnected) { HOST_TDControlStatus = 0; HOST_WdhIntr = 0; HOST_RhscIntr |= 0x02; gUSBConnected = 1; } else PRINT_Log("Spurious status change (connected)?\n"); } else { if (gUSBConnected) { HcInterruptEnable = 0; // why do we get multiple disc. rupts??? HOST_RhscIntr &= ~0x02; gUSBConnected = 0; } else PRINT_Log("Spurious status change (disconnected)?\n"); } } HcRhPortStatus2 = OR_RH_PORT_CSC; } if (HcRhPortStatus1 & OR_RH_PORT_PRSC) { HcRhPortStatus1 = OR_RH_PORT_PRSC; } if (HcRhPortStatus2 & OR_RH_PORT_PRSC) { HcRhPortStatus2 = OR_RH_PORT_PRSC; } } if (int_status & OR_INTR_STATUS_WDH) { /* Writeback Done Head interrupt */ HOST_WdhIntr = 1; HOST_TDControlStatus = (TDHead->Control >> 28) & 0xf; } HcInterruptStatus = int_status; /* Clear interrupt status register */ } VICVectAddr = 0; } }>