Skip to content

Commit b64d568

Browse files
authored
Merge pull request adafruit#677 from tannewt/usb_active_read
Move usb read finish into interrupt.
2 parents 15dd2fc + 8157248 commit b64d568

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ports/atmel-samd/usb_mass_storage.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
260260
if (active_read) {
261261
active_addr += 1;
262262
active_nblocks--;
263+
if (active_nblocks == 0) {
264+
active_read = false;
265+
}
263266
}
264267

265268
if (active_write) {
@@ -278,10 +281,6 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
278281
// sector. Once the sector is transmitted, xfer_done will be called.
279282
void usb_msc_background(void) {
280283
if (active_read && !usb_busy) {
281-
if (active_nblocks == 0) {
282-
active_read = false;
283-
return;
284-
}
285284
fs_user_mount_t * vfs = get_vfs(active_lun);
286285
disk_read(vfs, sector_buffer, active_addr, 1);
287286
CRITICAL_SECTION_ENTER();

0 commit comments

Comments
 (0)