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.