diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-16 23:08:36 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-16 23:08:36 +0100 |
commit | 6d983539bcff2a540dd136a7e84e1db2b334528f (patch) | |
tree | a5ba1e873fe2ee63a6bc7b8603ce3ff9ce7c2e81 /stmhal/usbdev/class | |
parent | f6be480bda92486c3185ceaf8f25f461dfb2aa72 (diff) |
stmhal: Improve flash storage cache management.
Internal flash used for the filesystem is now written (from the cache)
only after a 5s delay, or when a file is closed, or when the drive is
unmounted from the host. This delay means that multiple writes can
accumulate in the cache, and leads to less writes to the flash, making
it last longer.
It's implemented by a high-priority interrupt that takes care of flash
erase and write, and flushing the cache.
This is still only an interim solution for the flash filesystem. It
eventually needs to be replaced with something that uses less RAM for
the cache, something that can use more of the flash, and something that
does proper wear levelling.
Diffstat (limited to 'stmhal/usbdev/class')
-rw-r--r-- | stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h | 1 | ||||
-rw-r--r-- | stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h b/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h index 934399493..e1ae578e3 100644 --- a/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h +++ b/stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h @@ -54,6 +54,7 @@ typedef struct _USBD_STORAGE { int8_t (* IsReady) (uint8_t lun); int8_t (* IsWriteProtected) (uint8_t lun); int8_t (* StopUnit)(uint8_t lun); + int8_t (* PreventAllowMediumRemoval)(uint8_t lun, uint8_t param0); int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); int8_t (* GetMaxLun)(void); diff --git a/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c b/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c index b00d1ae2c..60258d64d 100644 --- a/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c +++ b/stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c @@ -472,6 +472,7 @@ static int8_t SCSI_AllowMediumRemoval(USBD_HandleTypeDef *pdev, uint8_t lun, ui {
USBD_MSC_BOT_HandleTypeDef *hmsc = pdev->pClassData;
hmsc->bot_data_length = 0;
+ ((USBD_StorageTypeDef *)pdev->pUserData)->PreventAllowMediumRemoval(lun, params[0]);
return 0;
}
|