Sat May 19 16:43:53 EDT 2012

SET_ADDRESS: why does lab1.c wait for IN ?

lab1.c replies with 0-size DATA1 to SET_ADDRESS, and it doesn't
immediately set the address.  That only gets used in ProcessInToken.
Why is there an IN token after SET_ADDRESS?

Answer: there is always an IN transaction after a SETUP transaction.
ProcessInToken() merely acts as a notification that the 0-size IN
transaction sent in response to the SET_ADDRESS is done.  Only after
that it is safe to set the address.

Basically, TRIF -> IN is just an acknowledgement of the end of an IN
transaction initiated by the PIC.  Like this:

   - PIC firmware prepares IN buffer (an empty one, serving as the
     Status word of a SET_ADDRESS control message)

   - PIC HW waits for IN token sent by host

   - PIC HW sends out DATA token to host

   - PIC HW receives ACK from host

   - This completes the transaction in hardware, so TRNIF is set, and
     the PID of last transaction set to "IN" in USTAT.

   - Only after the whole SET_ADDRESS transaction is done the device
     address can be changed.

The reason that this is the only case handled in IN events is because
we don't care in the other case: nothing more to be done after
transaction is over.