finalize msc cb API with tud_msc_read10_cb and tud_msc_write10_cb

This commit is contained in:
hathach
2018-04-19 16:10:52 +07:00
parent 8c0a5f7d3b
commit c7e924b4be
4 changed files with 64 additions and 43 deletions

View File

@@ -91,17 +91,19 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
//--------------------------------------------------------------------+
// IMPLEMENTATION
//--------------------------------------------------------------------+
uint16_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint16_t block_count, void** pp_buffer)
uint32_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
(*pp_buffer) = msc_device_ramdisk[lba];
uint8_t* addr = msc_device_ramdisk[lba] + offset;
memcpy(buffer, addr, bufsize);
return min16_of(block_count, DISK_BLOCK_NUM);
return bufsize;
}
uint16_t tud_msc_write10_cb(uint8_t rhport, uint8_t lun, uint32_t lba, uint16_t block_count, void** pp_buffer)
uint32_t tud_msc_write10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
(*pp_buffer) = msc_device_ramdisk[lba];
uint8_t* addr = msc_device_ramdisk[lba] + offset;
memcpy(addr, buffer, bufsize);
return min16_of(block_count, DISK_BLOCK_NUM);
return bufsize;
}
//--------------------------------------------------------------------+

View File

@@ -83,6 +83,13 @@
// If not enabled, application must call tud_cdc_flush() periodically
#define CFG_TUD_CDC_FLUSH_ON_SOF 1
// Number of supported Logical Unit Number
#define CFG_TUD_MSC_MAXLUN 1
#define CFG_TUD_MSC_BUFSIZE 512
//--------------------------------------------------------------------+
// USB RAM PLACEMENT
//--------------------------------------------------------------------+