diff options
| author | hathach <[email protected]> | 2018-12-03 16:30:39 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-12-03 16:30:39 +0700 |
| commit | b2b1704f10e18cd7ae8a1448c299f34ca2c183c6 (patch) | |
| tree | 9e2b2c0addc5043b37412c11580cb1c01adf58e0 /examples/device/cdc_msc_hid | |
| parent | 786b04e19d52a904a4faf2bc9a7b022e9cd0237c (diff) | |
use flash for msc_disk_ram in case mcu does have enough sram
Diffstat (limited to 'examples/device/cdc_msc_hid')
| -rw-r--r-- | examples/device/cdc_msc_hid/src/msc_disk_ram.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/device/cdc_msc_hid/src/msc_disk_ram.c b/examples/device/cdc_msc_hid/src/msc_disk_ram.c index 08cef5f25..2293ec0c9 100644 --- a/examples/device/cdc_msc_hid/src/msc_disk_ram.c +++ b/examples/device/cdc_msc_hid/src/msc_disk_ram.c @@ -41,6 +41,12 @@ #if CFG_TUD_MSC +// Some MCU doesn't have enough 8KB SRAM to store the whole disk +// We will use Flash as read-only disk +#if CFG_TUSB_MCU == OPT_MCU_LPC13XX +#define DISK_READONLY 1 +#endif + #define README_CONTENTS \ "This is tinyusb's MassStorage Class demo.\r\n\r\n\ If you find any bugs or get any questions, feel free to file an\r\n\ @@ -52,7 +58,10 @@ enum DISK_BLOCK_SIZE = 512 }; -uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = +#if DISK_READONLY +const +#endif +static uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = { //------------- Boot Sector -------------// // byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM; @@ -99,7 +108,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff { (void) lun; - uint8_t* addr = msc_device_ramdisk[lba] + offset; + uint8_t* addr = msc_disk[lba] + offset; memcpy(buffer, addr, bufsize); return bufsize; @@ -111,8 +120,10 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* { (void) lun; - uint8_t* addr = msc_device_ramdisk[lba] + offset; +#if !DISK_READONLY + uint8_t* addr = msc_disk[lba] + offset; memcpy(addr, buffer, bufsize); +#endif return bufsize; } |
