File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -280,15 +280,22 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
280
280
// drive into our cache and trigger the USB DMA to output the
281
281
// sector. Once the sector is transmitted, xfer_done will be called.
282
282
void usb_msc_background (void ) {
283
- if (active_read && !usb_busy ) {
283
+ // Check USB busy first because we never want to queue another transfer if it is. Checking
284
+ // active_read or active_write first leaves the possibility that they are true, an xfer done
285
+ // interrupt occurs (setting them false), turning off usb_busy and causing us to queue a
286
+ // spurious transfer.
287
+ if (usb_busy ) {
288
+ return ;
289
+ }
290
+ if (active_read ) {
284
291
fs_user_mount_t * vfs = get_vfs (active_lun );
285
292
disk_read (vfs , sector_buffer , active_addr , 1 );
286
293
CRITICAL_SECTION_ENTER ();
287
294
int32_t result = mscdf_xfer_blocks (true, sector_buffer , 1 );
288
295
usb_busy = result == ERR_NONE ;
289
296
CRITICAL_SECTION_LEAVE ();
290
297
}
291
- if (active_write && ! usb_busy ) {
298
+ if (active_write ) {
292
299
if (sector_loaded ) {
293
300
fs_user_mount_t * vfs = get_vfs (active_lun );
294
301
disk_write (vfs , sector_buffer , active_addr , 1 );
You can’t perform that action at this time.
0 commit comments