I'm working with a CY7C68013A-FX2LP. We started with the provided mass storage device example firmware and added a second interface that uses endpoint 1.
We use winusb to communicate over this second interface, with a custom protocol, when the device receives something on endpoint 1 it results in an I2C transaction / GPIO wiggling.
This works perfectly as it is, I plug in the dongle, it loads it's firmware, enumerates, the windows "what shall we do with this mass storage thing" pops up. I run my windows code to do a set of sample transactions over the second interface, which runs as expected.
I can also read, write and delete from the mass storage device correctly.
However I have a problem if I am doing a mass storage transfer (say writting 50MB to the dongle) and running my custom code at the same time. The first request tends to go through OK (sending 01 00), however the second request fails. Debugging has told me that the bytes I send are on the wire (02 00 0A). The EP1 OUT BUSY bit is 0 in the EP01STAT register, meaning there is data to read. However the EP1OUTBC register is 0. Meaning there is no data to read. If I ignore this and read 10 bytes anyway fromthe EP1OUTBUF buffer, I see (01 00 .....) which matches the first packet I read in.
After this request fails, about 1s later the USB reset interrupt fires and the device resets (although the mass storage transfer continues running). This doesn't always happen, but it does quite often. Also using a USB analyser I was unable to see a reset condition on the line.
So as far as I can tell, I send a request, it's defintiely on the wire, the dongle receives it and notifies that it has been received, yet the buffer and byte count registers haven't been updated.
USB descriptors: http://slexy.org/view/s21Tk2YNtj
Endpoint setup: http://slexy.org/view/s20U5otzq5
EP1 poll code: http://slexy.org/view/s21itwaq6L (the autoptrs are commented out for debugging, the problem happens either way).
Apologies if any of the code is messy / un-needed, I've been trying not to touch stuff that works, with the aim of tidying it all up later.
Any help would be greatly appeciated, as I can't figure out where to go from here.