summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/atmel-samd/asf4_conf/samd51/hpl_nvmctrl_config.h4
-rw-r--r--ports/atmel-samd/usb_mass_storage.c7
2 files changed, 6 insertions, 5 deletions
diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_nvmctrl_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_nvmctrl_config.h
index daaba85d4..53fcb593a 100644
--- a/ports/atmel-samd/asf4_conf/samd51/hpl_nvmctrl_config.h
+++ b/ports/atmel-samd/asf4_conf/samd51/hpl_nvmctrl_config.h
@@ -19,14 +19,14 @@
// <i> Indicate whether AHB0 cache is disable or not
// <id> nvm_arch_cache0
#ifndef CONF_NVM_CACHE0
-#define CONF_NVM_CACHE0 0
+#define CONF_NVM_CACHE0 1
#endif
// <q> AHB1 Cache Disable
// <i> Indicate whether AHB1 cache is disable or not
// <id> nvm_arch_cache1
#ifndef CONF_NVM_CACHE1
-#define CONF_NVM_CACHE1 0
+#define CONF_NVM_CACHE1 1
#endif
// </h>
diff --git a/ports/atmel-samd/usb_mass_storage.c b/ports/atmel-samd/usb_mass_storage.c
index f20878949..85c662e77 100644
--- a/ports/atmel-samd/usb_mass_storage.c
+++ b/ports/atmel-samd/usb_mass_storage.c
@@ -260,9 +260,6 @@ 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) {
@@ -277,6 +274,10 @@ 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);
CRITICAL_SECTION_ENTER();