Source Code Files
Contents
USB08 Evaluation Board
Designer Reference Manual
MOTOROLA
Source Code Files
107
// GET_DESCRIPTOR Standard Device Request Handler
// called by handleSETUP();
//
void getDescriptor() {
uchar n;
uchar *dest;
switch(SetupBuffer.wValue.hi) {
case DT_DEVICE:
// Get Device Descriptor
SetupDataPtr = (uchar *)&DeviceDesc;
SetupSize = DeviceDesc.bLength;
break;
case DT_CONFIGURATION:
// Get Configuration Descriptor
SetupDataPtr = (uchar *)&ConfigDesc;
SetupSize = ConfigDesc.wTotalLength.lo;
break;
case DT_STRING:
// Get String Descriptor
// ### Table Index Boundary should be checked
SetupDataPtr = StringDescTable[SetupBuffer.wValue.lo];
SetupSize = *SetupDataPtr;
break;
default:
forceSTALL();
break;
}
if( SetupBuffer.wValue.hi == DT_DEVICE ||
SetupBuffer.wValue.hi == DT_CONFIGURATION ||
SetupBuffer.wValue.hi == DT_STRING) {
// check if requested Length is less than Descriptor Length
if((SetupBuffer.wLength.lo < SetupSize) && (SetupBuffer.wLength.hi == 0))
SetupSize = SetupBuffer.wLength.lo;
// copy (up to) 8 Bytes to EP0 Data Registers
n = 0;
dest = (uchar *)&UE0D0;
while(SetupSize!=0 && n<8) {
*dest = *SetupDataPtr;
dest++;
Setup+;
SetupSize--;
n++;
}
// prepare to send n Bytes as DATA1 at next IN Transaction
// Rem: RX0E (currently disabled) will be re-enabled at end of handleSETUP()
UCR0 = BM B n;
// check if this is the last DATA packet to send
if(n < 8) SetupBuffer.bRequest = REQUEST_COMPLETE;
}
}
//----------------------------------------------------------------------------