msc device block count and block num
- replace CFG_TUD_MSC_BLOCK_NUM & CFG_TUD_MSC_BLOCK_SZ by tud_msc_capacity_cb() (mandatory callback)
This commit is contained in:
@@ -97,6 +97,8 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
||||
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
|
||||
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
uint8_t* addr = msc_device_ramdisk[lba] + offset;
|
||||
memcpy(buffer, addr, bufsize);
|
||||
|
||||
@@ -107,14 +109,20 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
|
||||
// Process data in buffer to disk's storage and return number of written bytes
|
||||
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
uint8_t* addr = msc_device_ramdisk[lba] + offset;
|
||||
memcpy(addr, buffer, bufsize);
|
||||
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// HELPER
|
||||
//--------------------------------------------------------------------+
|
||||
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
*block_count = DISK_BLOCK_NUM;
|
||||
*block_size = DISK_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -55,14 +55,8 @@
|
||||
#endif
|
||||
|
||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
|
||||
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
|
||||
/*------------- RTOS -------------*/
|
||||
#define CFG_TUSB_OS OPT_OS_NONE // be passed from IDE/command line for easy project switching
|
||||
//#define CFG_TUD_TASK_PRIO 0
|
||||
//#define CFG_TUD_TASK_QUEUE_SZ 16
|
||||
//#define CFG_TUD_TASK_STACK_SZ 150
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// DEVICE CONFIGURATION
|
||||
@@ -118,12 +112,6 @@
|
||||
// Buffer size of Device Mass storage
|
||||
#define CFG_TUD_MSC_BUFSIZE 512
|
||||
|
||||
// Number of Blocks
|
||||
#define CFG_TUD_MSC_BLOCK_NUM 16
|
||||
|
||||
// Block size
|
||||
#define CFG_TUD_MSC_BLOCK_SZ 512
|
||||
|
||||
// Vendor name included in Inquiry response, max 8 bytes
|
||||
#define CFG_TUD_MSC_VENDOR "tinyusb"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user