change endian conversion to native to be & be to native
completely deferred xfer isr event to usbd task complete read10, write10 sequence for large data transfer
This commit is contained in:
@@ -60,8 +60,8 @@ static scsi_inquiry_data_t mscd_inquiry_data TUSB_CFG_ATTR_USBRAM =
|
||||
ATTR_USB_MIN_ALIGNMENT
|
||||
static scsi_read_capacity10_data_t mscd_read_capacity10_data TUSB_CFG_ATTR_USBRAM =
|
||||
{
|
||||
.last_lba = __le2be(DISK_BLOCK_NUM-1), // read capacity
|
||||
.block_size = __le2be(DISK_BLOCK_SIZE)
|
||||
.last_lba = __n2be(DISK_BLOCK_NUM-1), // read capacity
|
||||
.block_size = __n2be(DISK_BLOCK_SIZE)
|
||||
};
|
||||
|
||||
ATTR_USB_MIN_ALIGNMENT
|
||||
@@ -76,9 +76,9 @@ ATTR_USB_MIN_ALIGNMENT
|
||||
static scsi_read_format_capacity_data_t mscd_format_capacity_data TUSB_CFG_ATTR_USBRAM =
|
||||
{
|
||||
.list_length = 8,
|
||||
.block_num = __le2be(DISK_BLOCK_NUM), // write capacity
|
||||
.block_num = __n2be(DISK_BLOCK_NUM), // write capacity
|
||||
.descriptor_type = 2, // TODO formatted media, refractor to const
|
||||
.block_size_u16 = __h2be_16(DISK_BLOCK_SIZE)
|
||||
.block_size_u16 = __n2be_16(DISK_BLOCK_SIZE)
|
||||
};
|
||||
|
||||
ATTR_USB_MIN_ALIGNMENT
|
||||
@@ -99,6 +99,7 @@ static scsi_mode_parameters_t msc_dev_mode_para TUSB_CFG_ATTR_USBRAM =
|
||||
//--------------------------------------------------------------------+
|
||||
msc_csw_status_t tusbd_msc_scsi_received_isr (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void ** pp_buffer, uint16_t* p_length)
|
||||
{
|
||||
// read10 & write10 has their own callback and MUST not be handled here
|
||||
switch (scsi_cmd[0])
|
||||
{
|
||||
case SCSI_CMD_INQUIRY:
|
||||
@@ -136,14 +137,6 @@ msc_csw_status_t tusbd_msc_scsi_received_isr (uint8_t coreid, uint8_t lun, uint8
|
||||
(*p_length) = 0;
|
||||
break;
|
||||
|
||||
case SCSI_CMD_READ_10:
|
||||
(*p_length) = read10(coreid, lun, (scsi_read10_t*) scsi_cmd, pp_buffer);
|
||||
break;
|
||||
|
||||
case SCSI_CMD_WRITE_10:
|
||||
(*p_length) = write10(coreid, lun, (scsi_read10_t*) scsi_cmd, pp_buffer);
|
||||
break;
|
||||
|
||||
default: return MSC_CSW_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,11 @@ enum
|
||||
DISK_BLOCK_SIZE = 512
|
||||
};
|
||||
|
||||
#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\
|
||||
issue at github.com/hathach/tinyusb"
|
||||
|
||||
#if TUSB_CFG_MCU==MCU_LPC11UXX || TUSB_CFG_MCU==MCU_LPC13UXX
|
||||
#define MSCD_APP_ROMDISK
|
||||
#else // defaults is ram disk
|
||||
|
||||
@@ -43,10 +43,6 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
#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\
|
||||
issue at github.com/hathach/tinyusb"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
@@ -64,10 +60,10 @@ uint8_t mscd_app_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] TUSB_CFG_ATTR_USBRAM =
|
||||
[510] = 0x55, [511] = 0xAA // FAT magic code
|
||||
},
|
||||
|
||||
//------------- FAT12 Table (first 2 entries are F8FF, third entry is cluster end of readme file-------------//
|
||||
//------------- FAT12 Table -------------//
|
||||
[1] =
|
||||
{
|
||||
0xF8, 0xFF, 0xFF, 0xFF, 0x0F
|
||||
0xF8, 0xFF, 0xFF, 0xFF, 0x0F // // first 2 entries must be F8FF, third entry is cluster end of readme file
|
||||
},
|
||||
|
||||
//------------- Root Directory -------------//
|
||||
@@ -95,7 +91,7 @@ uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uin
|
||||
|
||||
return min16_of(block_count, DISK_BLOCK_NUM);
|
||||
}
|
||||
uint16_t tusbh_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
uint16_t tusbd_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
{
|
||||
(*pp_buffer) = mscd_app_ramdisk[lba];
|
||||
|
||||
|
||||
@@ -47,10 +47,6 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
#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\
|
||||
issue at github.com/hathach/tinyusb"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
@@ -67,10 +63,10 @@ const uint8_t mscd_app_rommdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
||||
[510] = 0x55, [511] = 0xAA // FAT magic code
|
||||
},
|
||||
|
||||
//------------- FAT12 Table (first 2 entries are F8FF, third entry is cluster end of readme file-------------//
|
||||
//------------- FAT12 Table -------------//
|
||||
[1] =
|
||||
{
|
||||
0xF8, 0xFF, 0xFF, 0xFF, 0x0F
|
||||
0xF8, 0xFF, 0xFF, 0xFF, 0x0F // first 2 entries must be F8FF, third entry is cluster end of readme file
|
||||
},
|
||||
|
||||
//------------- Root Directory -------------//
|
||||
@@ -90,21 +86,21 @@ const uint8_t mscd_app_rommdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
||||
};
|
||||
|
||||
ATTR_USB_MIN_ALIGNMENT
|
||||
static uint8_t ramdisk_buffer[DISK_BLOCK_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
static uint8_t sector_buffer[DISK_BLOCK_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
{
|
||||
memcpy(ramdisk_buffer, mscd_app_rommdisk[lba], DISK_BLOCK_SIZE);
|
||||
(*pp_buffer) = ramdisk_buffer;
|
||||
memcpy(sector_buffer, mscd_app_rommdisk[lba], DISK_BLOCK_SIZE);
|
||||
(*pp_buffer) = sector_buffer;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Stall write10 as this is readonly disk
|
||||
uint16_t tusbh_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
uint16_t tusbd_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
{
|
||||
(*pp_buffer) = NULL;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user