Skip to content

Commit

Permalink
atmel-samd: Tweak mass storage code to finish read sooner.
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Nov 7, 2017
1 parent a8ee001 commit 182a946
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ports/atmel-samd/usb_mass_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.
Expand Down

0 comments on commit 182a946

Please sign in to comment.