rename ExternalFS updateCache()
This commit is contained in:
4 files changed
+9
-20
No files matched your search
@@ -76,8 +76,6 @@ bool Adafruit_USBDev_MSC::begin(void)
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#include "flash/flash_qspi.h"
|
||||
|
||||
// Callback invoked when received an SCSI command not in built-in list below
|
||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||
// - READ10 and WRITE10 has their own callbacks
|
||||
|
||||
@@ -68,22 +68,25 @@ void loop()
|
||||
|
||||
int32_t fl_read_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) lun;
|
||||
return flash_qspi_read(buffer, lba * USB_MSC_BLOCK_SIZE + offset, bufsize);
|
||||
}
|
||||
|
||||
int32_t fl_write_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
uint32_t wrcount = flash_qspi_write(lba * USB_MSC_BLOCK_SIZE + offset, buffer, bufsize);
|
||||
|
||||
// update fatfs's cache if address matches
|
||||
extern void ExternalFS_usbmsc_write (uint32_t lba, void const* buffer, uint32_t bufsize);
|
||||
if ( ExternalFS_usbmsc_write ) ExternalFS_usbmsc_write(lba, buffer, bufsize);
|
||||
// update ExternalFS cache since USB write it out of its awareness
|
||||
ExternalFS.updateCache(lba, buffer, bufsize);
|
||||
|
||||
return wrcount;
|
||||
}
|
||||
|
||||
void fl_flush_cb (uint8_t lun)
|
||||
{
|
||||
(void) lun;
|
||||
flash_qspi_flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ void FatFS::_f_rewindDirectory (void* fhdl)
|
||||
}
|
||||
|
||||
// for USB MSC to check and update fatfs sector cache
|
||||
void FatFS::_usbmsc_write (uint32_t lba, void const* buffer, uint32_t bufsize)
|
||||
void FatFS::updateCache (uint32_t lba, void const* buffer, uint32_t bufsize)
|
||||
{
|
||||
VERIFY(_fs,);
|
||||
if ( (lba <= _fs->winsect) && (_fs->winsect < (lba + bufsize / FF_MAX_SS)) )
|
||||
@@ -386,12 +386,4 @@ void FatFS::_usbmsc_write (uint32_t lba, void const* buffer, uint32_t bufsize)
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void ExternalFS_usbmsc_write (uint32_t lba, void const* buffer, uint32_t bufsize)
|
||||
{
|
||||
ExternalFS._usbmsc_write(lba, buffer, bufsize);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -70,8 +70,8 @@ class FatFS: public BluefruitFS::FileSystemClass
|
||||
virtual BluefruitFS::File _f_openNextFile (void* fhdl, char const* cwd, uint8_t mode);
|
||||
virtual void _f_rewindDirectory (void* fhdl);
|
||||
|
||||
// called when Flash contents is changed out of the awareness of ExternalFS such as USB MSC write
|
||||
void _usbmsc_write (uint32_t lba, void const* buffer, uint32_t bufsize);
|
||||
// Should call when flash contents is changed out of the awareness of ExternalFS such as USB MSC write
|
||||
void updateCache (uint32_t lba, void const* buffer, uint32_t bufsize);
|
||||
|
||||
private:
|
||||
FATFS* _fs;
|
||||
@@ -83,8 +83,4 @@ class FatFS: public BluefruitFS::FileSystemClass
|
||||
|
||||
extern FatFS ExternalFS;
|
||||
|
||||
// C to CPP call bridge for update fatfs cached sector
|
||||
extern "C" void ExternalFS_usbmsc_write (uint32_t lba, void const* buffer, uint32_t bufsize);
|
||||
|
||||
|
||||
#endif /* EXTERNALFS_H_ */
|
||||
Reference in new issue
Block a user