Yes all of your considerations about by
horrible code are correct XD indeed it should be parameterized in only one function and yes gcc gives me a warning for void pointer arithmetic but it behaves like a uint8 pointer so 'till I'm in this prototyping state I'm writing this code like a stream of consciousness (a really messy one
)
BenLunt wrote:
On an IN transfer, your transfer_packets() function is waiting for a response, correct?
[...]
If the Queue for the CSW is in the same frame as the Queue for the CBW, the devices hasn't had time to respond before the controller executes the CSW
Yes correct, the function returns only when the interrupt bit on the status register is set in the uhci controller and only the last td of the packets I send has the IOC bit set, plus the uhci schedule is executed always from the start so all packets should be processed in the correct order.
So given that every call of that function is an independent (and not thread-safe) unit of execution of the TDs in the framelist, when I send the CWS it should be granted that the CBW has already been processed.
BenLunt wrote:
Since you are not using an interrupt interface, if your transfer_packets() function doesn't wait for the device to execute the Command phase, then the Response phase, your Status phase will be zeros. Just a thought, since there is no reference to your transfer_packets() function except for the call itself, it is waiting for the device to fill the result phase, correct?
I'm not sure about how to answer to this, it surely waits that all the TDs are processed but I don't know how to also achieve this other thing.
BenLunt wrote:
In experimentation, wait 10mS or so before you retrieve the CSW. See if there is something there.
Nope, no luck
BenLunt wrote:
A few more notes. Your toggle needs to be aware of short packets. If you create, for example, 6 IN packets, each toggling with an ending toggle bit of 1 (so that the next new packet will have a toggle of 0), let's say that you short packet on the fifth packet. The device will expect the next packet to have a toggle of 1, but your code will give it a toggle of 0. The error in the toggle will invalidate any remaining packets until you clear_endpoint() or fix the toggle bit.
I'm kinda leaving error handling aside for the moment, being in an emulated environment i'm pretty much assuming no errors are happening hardware side, also executing the thing more than one should eliminate any risk of a bad result caused by casual error, theoretically
BenLunt wrote:
Also, you are assuming that the LUN is zero. This is the case for most devices, however some devices will have multiple LUN values starting with 1. Have you sent the Get_Max_LUN request yet?
Yup, I get a max LUN of 0, so only 1 LUNis present (index 0)