Sat May 19 14:54:26 EDT 2012

USB protocol info

A 0 is introduced after 6 consecutive one bits to ensure enough
transitions.  To decode this, just do the reverse: if 6 consecutive
one bits are received, drop the following zero.

If 7 consecutive ones are detected a bit stuffing error is raised an
the packet is discarded.

A packet on the wire is a NRZI encoding of a packet, prefixed with a
clock sync pattern.

See 7.1.9 in USB1.1 spec [1].

From in [1] it says that SETUP is a special kind of OUT that
resets the data sync.  SETUP token is always followed by a DATA token.

From 8.5.2 in [1]: Control Transfers Control transfers minimally have
two transaction stages: Setup and Status.  Setup is SETUP + DATA0.

The Status stage is delineated by a change in direction of data flow
from the previous stage and always uses a DATA1 PID.

The terms are a bit confusing: transaction, sequence, token, ....
Anyhow, it seems that I don't need to care about ACK.

So, a "stage" is actually two tokens:

 IN,    DATAx

The SETUP, OUT, IN tokens are always sent by the host.  The DATAx
tokens are sent by the host if preceded by SETUP and OUT, or by the
device is preceeded by IN.

( On the PIC, these stages are atomic. )


- In figure 8-12 [1], does a DEVICE GET_DESCRIPTOR request have a data
  stage?  I.e. is it a Control Read or a No-Data control

- Is the Status IN always empty, or can it have a payload?

[1] http://esd.cs.ucr.edu/webres/usb11.pdf