This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LM4F USB: Distinguishing between IN, OUT, and SETUP packets



I'm trying to figure out how to distinguish between IN, OUT, and SETUP packets on EP0. We have the EP0 bit USBTXIS, which just tells us that something happened on EP0. The RXRDY bit in CSRL0 just tells us that  a packet arrived, but how do we determine if that packet is a SETUP packet or OUT packet?

Also, how do we determine when USBTXIS.EP0 means "IN transfer completed"? There are so many situations when this bit is set, and the datasheet barely glances over those cases. I sometimes get two successive interrupts with USBTXIS.EP0 set, and no other bits in CSRL0 or CSRH0 set.

  • Alexandru,

      The USB register interface is well below the level of understanding IN, OUT and SETUP phases of a control transaction, I'm afraid. This determination is up to software and explains why there is so much code involved in the EP0-related functions in the Stellaris USB Library. Software is required to track the state of the bus and remember what it last did and what it expects next. I would recommend, even if you don't want to use the USB library we supply, that you take a look through it because it contains all the code to do this already.

      As for your specific question about USBTXIS.EP0 being set while the CSRL0/CSRH0 registers are clear, this indicates that a USB transmit has completed. Depending upon where you are in your control transaction, this could indicate that the IN portion of the transaction is complete but, again, it's up to the software state machine to track this.