Source Code Files
Contents
USB08 Evaluation Board Designer Reference Manual
MOTOROLA Source Code Files 109
void handleIN() {
uchar n;
uchar *dest;
UCR0 &= ~BM_TX0E; // Deactivate EP0 Trans mitter
UIR2 = BM_TXD0FR; // Reset EP0 Transmit c omplete Flag
switch(SetupBuffer.bReq uest) {
case SET_ADDRESS:
UADDR = SetupBuffer.wValue.l o | BM _U SBEN;
if(SetupBuffer.wValue.l o != 0) USB _State = US_ADDRESSED;
else USB_State = US_DEFAULT;
SetupBuffer.bRequest = REQUE ST _C OMPLETE;
break;
case GET_DESCRIPTOR:
// copy (up to) 8 Bytes to EP0 Data Registers
n = 0;
dest = (uchar *)&UE0D0;
while(SetupSize!=0 && n <8) {
*dest = *SetupDataPtr;
dest++;
SetupDataPtr++;
SetupSize--;
n++;
}
// prepare to send n Bytes at next IN Trans ac ti on
// toggle DATA0/1
UCR0 = ((UCR0^BM_T0SEQ) & BM_T0SEQ) + BM_TX0E + BM_RX0E + n;
// check if this is the last DATA packet to send
if(n < 8) SetupBuffer.bRequest = REQUEST_COMPLETE;
break;
case CLEAR_FEATURE:
case SET_CONFIGURATION:
// nothing to do - handshake finishe d
SetupBuffer.bRequest = REQUE ST _C OMPLETE;
break;
case REQUEST_COMPLETE:
// Request is finished - just clear th e TXD 0F Flag (see above)
// and do not re-enable EP0 Transmitter, since there is no more
// data to send
break;
default:
forceSTALL();
break;
}
}
//--------------------- ------------------------ ----------------------- --------