summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-11-06 16:29:28 -0800
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-11-06 16:30:11 -0800
commit182a946b0ef12f6f031e846af788cdeb2eecd3a6 (patch)
tree593a0a77447af3c6990e8f50a4f9359c67b8d501
parenta8ee0012d715182eeb608f867be0403cd96137d1 (diff)
atmel-samd: Tweak mass storage code to finish read sooner.
-rw-r--r--ports/atmel-samd/usb_mass_storage.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ports/atmel-samd/usb_mass_storage.c b/ports/atmel-samd/usb_mass_storage.c
index 8001cc097..d9d9d9f39 100644
--- a/ports/atmel-samd/usb_mass_storage.c
+++ b/ports/atmel-samd/usb_mass_storage.c
@@ -259,6 +259,9 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
if (active_read) {
active_addr += 1;
active_nblocks--;
+ if (active_nblocks == 0) {
+ active_read = false;
+ }
}
if (active_write) {
@@ -272,10 +275,6 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
// The start_read callback begins a read transaction which we accept but delay our response until the "main thread" calls usb_msc_background. Once it does, we read immediately from the drive into our cache and trigger the USB DMA to output the sector. Once the sector is transmitted, xfer_done will be called.
void usb_msc_background(void) {
if (active_read && !usb_busy) {
- if (active_nblocks == 0) {
- active_read = false;
- return;
- }
fs_user_mount_t * vfs = get_vfs(active_lun);
disk_read(vfs, sector_buffer, active_addr, 1);
// TODO(tannewt): Check the read result.