USB Mass Storage Device Block Device
Dependents: mini_piano_player play_wav BlueCrutch FTHR_USBMSD_Demo_27
Fork of USBMSD_SD by
Revision 5:13fed87fb66f, committed 2018-02-24
- Comitter:
- switches
- Date:
- Sat Feb 24 18:04:35 2018 +0000
- Parent:
- 4:6b2f29de40d3
- Commit message:
- Now reads block size from bd pointer, and erases before programming in wirtes.
Changed in this revision
USBMSD_BD.cpp | Show annotated file Show diff for this revision Revisions of this file |
USBMSD_BD.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBMSD_BD.cpp Fri Feb 23 23:25:58 2018 +0000 +++ b/USBMSD_BD.cpp Sat Feb 24 18:04:35 2018 +0000 @@ -119,9 +119,8 @@ #define SD_DBG 0 -USBMSD_BD::USBMSD_BD(BlockDevice* bd, bd_size_t ssize) { +USBMSD_BD::USBMSD_BD(BlockDevice* bd) { _bd = bd; - _ssize = ssize; //no init _status = 0x01; @@ -129,6 +128,8 @@ } int USBMSD_BD::disk_initialize() { + _bd->init(); + _ssize = _bd->get_erase_size(); _sectors = _bd->size() / _ssize; // OK @@ -141,7 +142,8 @@ { bd_addr_t addr = (bd_addr_t)sector*_ssize; bd_size_t size = (bd_size_t)count*_ssize; - int err = _bd->program(buff, addr, size); + int err = _bd->erase(addr, size); + err = _bd->program(buff, addr, size); return err; } @@ -156,7 +158,7 @@ int USBMSD_BD::disk_status() { return _status; } int USBMSD_BD::disk_sync() { return 0; } uint64_t USBMSD_BD::disk_sectors() { return _sectors; } -uint64_t USBMSD_BD::disk_size() { return (*_bd).size(); } +uint64_t USBMSD_BD::disk_size() { return _bd->size(); } // PRIVATE FUNCTIONS
--- a/USBMSD_BD.h Fri Feb 23 23:25:58 2018 +0000 +++ b/USBMSD_BD.h Sat Feb 24 18:04:35 2018 +0000 @@ -52,7 +52,7 @@ * @param cs DigitalOut pin used as SD Card chip select * @param name The name used to access the virtual filesystem */ - USBMSD_BD(BlockDevice *bd, bd_size_t ssize); + USBMSD_BD(BlockDevice *bd); virtual int disk_initialize(); virtual int disk_status(); virtual int disk_read(uint8_t * buffer, uint64_t block_number, uint8_t count);