Having the `active_read = false` in the background function left
a chance that a new_write occurs before active_read is set to false.
In that case, we'll read the appropriate data rather than write it
and never clear the active write.
Hopefully fixes#655.
* Be more liberal with critical sections to ensure ordering.
* Correct usb_busy so that it is busy when no errors occur on
transfer. I believe it worked before because it would be false
momentarily until a second transfer was attempted and a busy
error was returned, therefore setting usb_busy to true. That
risks the first "failed" transfer completing before a second one
is attempted.
This explicit zero length xfer leads to a second CSW packet. If
another read was started between the two CSWs then the host gets
confused and resets the device.
On reads, the CSW is automatically sent when we reply with the
total length. Writes must do it manually so they can wait for the
disk to flush the data.
* Introduce a python script to generate the USB descriptor instead of
a bunch of C macros. In the future, we can use this dynamically in
CircuitPython.
* Add support for detecting read-only mass storage mounts.
Fixes#377