keil_examples/USBHostLite/UsbHost/Host/usbhost_lpc17xx.c
/*
**************************************************************************************************************
*                                         INTERRUPT SERVICE ROUTINE
*
* Description: This function services the interrupt caused by host controller
*
* Arguments  : None
*
* Returns    : None
*
**************************************************************************************************************
*/
INTERRUPT SERVICE ROUTINE
Description: This function services the interrupt caused by host controller

Arguments  : None

Returns    : None
INTERRUPT SERVICE ROUTINE Description : This function services the interrupt caused by host controller Arguments : None Returns : None
void  USB_IRQHandler (void)
{
    uint32_t   int_status;
    uint32_t   ie_status;
    int_status    = LPC_USB->InterruptStatus;                          
    ie_status     = LPC_USB->InterruptEnable;                          
    if (!(int_status & ie_status)) {
        return;
    } else {
        int_status = int_status & ie_status;
        if (int_status & OR_INTR_STATUS_RHSC) {                 
            if (LPC_USB->RhPortStatus1 & OR_RH_PORT_CSC) {
				if (LPC_USB->RhStatus & OR_RH_STATUS_DRWE) {
					HOST_RhscIntr |= 0x01;
				}
				else {
					if (LPC_USB->RhPortStatus1 & 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) {
							LPC_USB->InterruptEnable = 0; 
							HOST_RhscIntr &= ~0x01;
							gUSBConnected = 0;
						}
						else
							PRINT_Log("Spurious status change (disconnected)?\n");
					}
                }
            	LPC_USB->RhPortStatus1 = OR_RH_PORT_CSC;
            }
			if (LPC_USB->RhPortStatus2 & OR_RH_PORT_CSC) {
				if (LPC_USB->RhStatus & OR_RH_STATUS_DRWE) {
					HOST_RhscIntr |= 0x02;
				}
				else {
					if (LPC_USB->RhPortStatus2 & 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) {
							LPC_USB->InterruptEnable = 0; 
							HOST_RhscIntr &= ~0x02;
							gUSBConnected = 0;
						}
						else
							PRINT_Log("Spurious status change (disconnected)?\n");
					}
				}
				LPC_USB->RhPortStatus2 = OR_RH_PORT_CSC;
			}
			if (LPC_USB->RhPortStatus1 & OR_RH_PORT_PRSC) {
				LPC_USB->RhPortStatus1 = OR_RH_PORT_PRSC;
			}
			if (LPC_USB->RhPortStatus2 & OR_RH_PORT_PRSC) {
				LPC_USB->RhPortStatus2 = OR_RH_PORT_PRSC;
			}
		}
        if (int_status & OR_INTR_STATUS_WDH) {                  
            HOST_WdhIntr = 1;
			HOST_TDControlStatus = (TDHead->Control >> 28) & 0xf;
        }
		if (int_status & OR_INTR_STATUS_UE) {                   
			UnrecoverableIntCount++;
        }                    
        LPC_USB->InterruptStatus = int_status;                         
    }           
    return;
}
void USB_IRQHandler ( void ) { uint32_t int_status ; uint32_t ie_status ; int_status = LPC_USB -> InterruptStatus ; ie_status = LPC_USB -> InterruptEnable ; if ( ! ( int_status & ie_status ) ) { return ; } else { int_status = int_status & ie_status ; if ( int_status & OR_INTR_STATUS_RHSC ) { if ( LPC_USB -> RhPortStatus1 & OR_RH_PORT_CSC ) { if ( LPC_USB -> RhStatus & OR_RH_STATUS_DRWE ) { HOST_RhscIntr |= 0x01 ; } else { if ( LPC_USB -> RhPortStatus1 & OR_RH_PORT_CCS ) { if ( ! gUSBConnected ) { HOST_TDControlStatus = 0 ; HOST_WdhIntr = 0 ; HOST_RhscIntr |= 0x01 ; gUSBConnected = 1 ; } else PRINT_Log ( " \n " ) ; } else { if ( gUSBConnected ) { LPC_USB -> InterruptEnable = 0 ; HOST_RhscIntr &= ~ 0x01 ; gUSBConnected = 0 ; } else PRINT_Log ( " \n " ) ; } } LPC_USB -> RhPortStatus1 = OR_RH_PORT_CSC ; } if ( LPC_USB -> RhPortStatus2 & OR_RH_PORT_CSC ) { if ( LPC_USB -> RhStatus & OR_RH_STATUS_DRWE ) { HOST_RhscIntr |= 0x02 ; } else { if ( LPC_USB -> RhPortStatus2 & OR_RH_PORT_CCS ) { if ( ! gUSBConnected ) { HOST_TDControlStatus = 0 ; HOST_WdhIntr = 0 ; HOST_RhscIntr |= 0x02 ; gUSBConnected = 1 ; } else PRINT_Log ( " \n " ) ; } else { if ( gUSBConnected ) { LPC_USB -> InterruptEnable = 0 ; HOST_RhscIntr &= ~ 0x02 ; gUSBConnected = 0 ; } else PRINT_Log ( " \n " ) ; } } LPC_USB -> RhPortStatus2 = OR_RH_PORT_CSC ; } if ( LPC_USB -> RhPortStatus1 & OR_RH_PORT_PRSC ) { LPC_USB -> RhPortStatus1 = OR_RH_PORT_PRSC ; } if ( LPC_USB -> RhPortStatus2 & OR_RH_PORT_PRSC ) { LPC_USB -> RhPortStatus2 = OR_RH_PORT_PRSC ; } } if ( int_status & OR_INTR_STATUS_WDH ) { HOST_WdhIntr = 1 ; HOST_TDControlStatus = ( TDHead -> Control >> 28 ) & 0xf ; } if ( int_status & OR_INTR_STATUS_UE ) { UnrecoverableIntCount ++ ; } LPC_USB -> InterruptStatus = int_status ; } return ; }
INTERRUPT SERVICE ROUTINE
Description: This function services the interrupt caused by host controller
INTERRUPT SERVICE ROUTINE Description : This function services the interrupt caused by host controller
/* Read Interrupt Status                */ /* Read Interrupt enable status         */ /* Root hub status change interrupt     */ /*
					 * When DRWE is on, Connect Status Change
					 * means a remote wakeup event.
					*/ // JUST SOMETHING FOR A BREAKPOINT /*
					 * When DRWE is off, Connect Status Change
					 * is NOT a remote wakeup event
					*/ // why do we get multiple disc. rupts??? /*
				 	* When DRWE is on, Connect Status Change
				 	* means a remote wakeup event.
					*/ // JUST SOMETHING FOR A BREAKPOINT /*
				 	* When DRWE is off, Connect Status Change
				 	* is NOT a remote wakeup event
					*/ // why do we get multiple disc. rupts??? /* Writeback Done Head interrupt        */ /* Unrecoverable Error interrupt        */ /* Clear interrupt status register      */