Usb status register 0 (usr0), Universal serial bus (usb) interface – Motorola USB08 User Manual

Page 70

Advertising
background image

Designer Reference Manual

USB08 Evaluation Board

70

Universal Serial Bus (USB) Interface

MOTOROLA

Universal Serial Bus (USB) Interface

refers to a SETUP or an OUT packet. Therefore, the flag SETUP in the
USB status register 0 (USR0) has to be examined. If this flag is set, the
last token received by EP0 was a SETUP token and the interrupt routine
is branched to the function for handling of SETUP transactions,
handleSETUP().

In the USB status register 0 (USR0) the function handleSETUP() finds
not only the type of the transaction (SETUP or OUT), but can also
determine the number of received bytes. In the case of a SETUP
transaction, the data length is always defined as eight bytes. Therefore,
USR0 should contain the value 0

×

48.

The eight bytes received by endpoint 0 are available in the eight
registers UE0D0–UE0D7 and will be transferred into the buffer variable
SetupBuffer. This variable of the type setup_buffer is explained in the
following excerpt from

U08USB.H

.

// Structure of Setup Packet sent during

// SETUP Stage of Standard Device Requests

// according to USB1.1 spec page 183

//

typedef struct {

uchar bmRequestType; // Characteristics (Dir,Type,Recipient)

uchar bRequest; // Standard Request Code

iword wValue; // Value Field

iword wIndex; // Index or Offset Field

iword wLength; // No. of Bytes to transfer (Data Stage)

} setup_buffer;

The field bmRequestType must contain the value 0 in bits 5 and 6;
otherwise, it is not a standard device request.

Bit 7

6

5

4

3

2

1

Bit 0

Read:

R0SEQ

SETUP

0

0

RP0SIZ3

RP0SIZ2

RP0SIZ1

RP0SIZ0

Write:

Reset:

Unaffected by reset

= Unimplemented

Figure 4-6. USB Status Register 0 (USR0)

Advertising