
Designer Reference Manual USB08 Evaluation Board
108 Source Code Files MOTOROLA
Source Code Files
void handleSETUP() {
UCR0 &= ~BM_RX0E; // Deactivate EP0 Recei ver
UIR2 = BM_RXD0FR; // Reset EP0 Receive Fl ag
SetupBuffer = *(setup_buffer *)(&UE0D0);
if(USR0 != 0x48) { // SETUP Transaction mu st be DATA0 with Size=8
forceSTALL(); // otherwise we have an Erro r Condition
}
else { // now we will check th e Request Type
if((SetupBuffer.bmReque st Typ e & 0x60) != 0) {
forceSTALL(); // Non-Standard Requests will no t be han dled!
}
else { // Standard Request Decoder :
switch(SetupBuffer.bReq uest) {
case CLEAR_FEATURE: // 1
clearFeature();
break;
case SET_ADDRESS: // 5
setAddress();
break;
case GET_DESCRIPTOR: // 6
getDescriptor();
break;
case SET_CONFIGURATION: // 9
setConfiguration();
break;
default:
forceSTALL();
break;
}
}
}
UCR0 |= BM_RX0E; // Activate EP0 Receiver
}
//--------------------- ------------------------ ----------------------- --------
void handleOUT() {
UCR0 &= ~(BM_RX0E+BM_TX 0E); // Deactivate EP0 Recei ver + Transmitter
UIR2 = BM_RXD0FR; // Reset EP0 Receive Fl ag
// OUT Transactions ove r EP0 appear as Status S tage
// of a Standard Device Request only
UCR0 |= BM_RX0E; // Activate EP0 Receiver
}
//--------------------- ------------------------ ----------------------- --------