Source code files – Motorola USB08 User Manual

Page 108

Advertising
background image

Designer Reference Manual

USB08 Evaluation Board

108

Source Code Files

MOTOROLA

Source Code Files

void handleSETUP() {

UCR0 &= ~BM_RX0E;

// Deactivate EP0 Receiver

UIR2 = BM_RXD0FR;

// Reset EP0 Receive Flag

SetupBuffer = *(setup_buffer *)(&UE0D0);

if(USR0 != 0x48) {

// SETUP Transaction must be DATA0 with Size=8

forceSTALL();

// otherwise we have an Error Condition

}

else {

// now we will check the Request Type

if((SetupBuffer.bmRequestType & 0x60) != 0) {

forceSTALL();

// Non-Standard Requests will not be handled!

}

else {

// Standard Request Decoder:

switch(SetupBuffer.bRequest) {

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_TX0E);

// Deactivate EP0 Receiver + Transmitter

UIR2 = BM_RXD0FR;

// Reset EP0 Receive Flag

// OUT Transactions over EP0 appear as Status Stage

// of a Standard Device Request only

UCR0 |= BM_RX0E;

// Activate EP0 Receiver

}

//----------------------------------------------------------------------------

Advertising