Source code files – Motorola USB08 User Manual

Page 112

Advertising
background image

Designer Reference Manual

USB08 Evaluation Board

112

Source Code Files

MOTOROLA

Source Code Files

// USB Interrupt Handler

// All Interrupt Sources of the JB8’s integrated USB peripheral
// will be treated by this ISR

//

@interrupt void isrUSB() {

if(UIR1 & BM_EOPF) {

// End of Packet detected?

SuspendCounter = 0;

// reset 3ms-Suspend Counter

UIR2 = BM_EOPFR;

// reset EOP Intr Flag

}

else if(UIR1 & BM_RXD0F) {

// has EP0 received some data?

if(USR0 & BM_SETUP)

// was it a SETUP Packet?

handleSETUP();

else

// or a normal OUT Packet

handleOUT();

}

else if(UIR1 & BM_TXD0F) {

// has EP0 sent Data?

handleIN();

}

else if(UIR1 & BM_TXD1F) {

// has EP1 sent Data?

handleIN1();

}

else if(UIR1 & BM_RXD2F) {

// has EP2 received Data?

handleOUT2();

}

else if(UIR1 & BM_RSTF) {

// USB Reset Signal State detected?

initUSB();

// Soft Reset of USB Systems

UCR3 |= BM_ENABLE1+BM_ENABLE2;

// Enable EP1 and EP2

UIR0 = BM_TXD0IE + BM_RXD0IE +

// EP0 Rx/Tx Intr Enable and

BM_TXD1IE + BM_RXD2IE +

// EP1 Tx and EP2 Rx Intr Enable

BM_EOPIE;

// and End-of-Packet Intr Enable

UCR0 |= BM_RX0E;

// EP0 Receive Enable

USB_State = US_DEFAULT;

// Device is powered and reset

}

}

//============================================================================

Advertising