mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-16 06:40:11 +00:00
update example
This commit is contained in:
parent
a0849fee9f
commit
2d79023a5a
@ -87,6 +87,7 @@ void virtual_com_task(void)
|
||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||
|
||||
tud_cdc_write(buf, count);
|
||||
tud_cdc_flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,22 +46,6 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
static scsi_inquiry_data_t const mscd_inquiry_data =
|
||||
{
|
||||
.is_removable = 1,
|
||||
.version = 2,
|
||||
.response_data_format = 2,
|
||||
.vendor_id = "tinyusb",
|
||||
.product_id = "MSC Example",
|
||||
.product_revision = "0.01"
|
||||
};
|
||||
|
||||
static scsi_read_capacity10_data_t const mscd_read_capacity10_data =
|
||||
{
|
||||
.last_lba = ENDIAN_BE(DISK_BLOCK_NUM-1), // read capacity
|
||||
.block_size = ENDIAN_BE(DISK_BLOCK_SIZE)
|
||||
};
|
||||
|
||||
scsi_sense_fixed_data_t mscd_sense_data =
|
||||
{
|
||||
.response_code = 0x70,
|
||||
@ -69,14 +53,6 @@ scsi_sense_fixed_data_t mscd_sense_data =
|
||||
.additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8
|
||||
};
|
||||
|
||||
static scsi_read_format_capacity_data_t const mscd_format_capacity_data =
|
||||
{
|
||||
.list_length = 8,
|
||||
.block_num = ENDIAN_BE(DISK_BLOCK_NUM), // write capacity
|
||||
.descriptor_type = 2, // TODO formatted media, refractor to const
|
||||
.block_size_u16 = ENDIAN_BE16(DISK_BLOCK_SIZE)
|
||||
};
|
||||
|
||||
static scsi_mode_parameters_t const msc_dev_mode_para =
|
||||
{
|
||||
.mode_data_length = 3,
|
||||
@ -110,26 +86,11 @@ int32_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t const scsi_cmd[16]
|
||||
|
||||
switch (scsi_cmd[0])
|
||||
{
|
||||
case SCSI_CMD_INQUIRY:
|
||||
ptr = &mscd_inquiry_data;
|
||||
len = sizeof(scsi_inquiry_data_t);
|
||||
break;
|
||||
|
||||
case SCSI_CMD_READ_CAPACITY_10:
|
||||
ptr = &mscd_read_capacity10_data;
|
||||
len = sizeof(scsi_read_capacity10_data_t);
|
||||
break;
|
||||
|
||||
case SCSI_CMD_REQUEST_SENSE:
|
||||
ptr = &mscd_sense_data;
|
||||
len = sizeof(scsi_sense_fixed_data_t);
|
||||
break;
|
||||
|
||||
case SCSI_CMD_READ_FORMAT_CAPACITY:
|
||||
ptr = &mscd_format_capacity_data;
|
||||
len = sizeof(scsi_read_format_capacity_data_t);
|
||||
break;
|
||||
|
||||
case SCSI_CMD_MODE_SENSE_6:
|
||||
ptr = &msc_dev_mode_para;
|
||||
len = sizeof(msc_dev_mode_para);
|
||||
@ -175,22 +136,5 @@ int32_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t const scsi_cmd[16]
|
||||
return len;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CODE
|
||||
//--------------------------------------------------------------------+
|
||||
void msc_app_task(void* param)
|
||||
{ // no need to implement the task yet
|
||||
(void) param;
|
||||
|
||||
OSAL_TASK_BEGIN
|
||||
|
||||
OSAL_TASK_END
|
||||
}
|
||||
|
||||
void msc_app_init (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -78,17 +78,20 @@
|
||||
#define CFG_TUD_HID_GENERIC 0 // TODO need update
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* CLASS DRIVER
|
||||
/* CDC DEVICE
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
// FIFO size of CDC TX and RX
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 64
|
||||
#define CFG_TUD_CDC_TX_BUFSIZE 64
|
||||
|
||||
|
||||
// TX is sent automatically every Start of Frame event.
|
||||
// If not enabled, application must call tud_cdc_flush() periodically
|
||||
#define CFG_TUD_CDC_FLUSH_ON_SOF 1
|
||||
#define CFG_TUD_CDC_FLUSH_ON_SOF 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* MSC DEVICE
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
// Number of supported Logical Unit Number (At least 1)
|
||||
#define CFG_TUD_MSC_MAXLUN 1
|
||||
@ -96,6 +99,21 @@
|
||||
// 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"
|
||||
|
||||
// Product name included in Inquiry response, max 16 bytes
|
||||
#define CFG_TUD_MSC_PRODUCT "tusb msc"
|
||||
|
||||
// Product revision string included in Inquiry response, max 4 bytes
|
||||
#define CFG_TUD_MSC_PRODUCT_REV "1.0"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB RAM PLACEMENT
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -41,51 +41,27 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// STRING DESCRIPTORS
|
||||
//--------------------------------------------------------------------+
|
||||
#define STRING_LEN_UNICODE(n) (2 + (2*(n))) // also includes 2 byte header
|
||||
#define ENDIAN_BE16_FROM( high, low) ENDIAN_BE16(high << 8 | low)
|
||||
|
||||
// array of pointer to string descriptors
|
||||
uint16_t const * const string_desc_arr [] =
|
||||
{
|
||||
[0] = (uint16_t []) { // supported language
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(1), TUSB_DESC_STRING ),
|
||||
0x0409 // English
|
||||
},
|
||||
// 0: is supported language = English
|
||||
TUD_DESC_STRCONV(0x0409),
|
||||
|
||||
[1] = (uint16_t []) { // manufacturer
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(11), TUSB_DESC_STRING),
|
||||
't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'o', 'r', 'g' // len = 11
|
||||
},
|
||||
// 1: Manufacturer
|
||||
TUD_DESC_STRCONV('t', 'i', 'n', 'y', 'u', 's', 'b', '.', 'o', 'r', 'g'),
|
||||
|
||||
[2] = (uint16_t []) { // product
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(14), TUSB_DESC_STRING),
|
||||
't', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'd', 'e', 'v', 'i', 'c', 'e' // len = 14
|
||||
},
|
||||
// 2: Product
|
||||
TUD_DESC_STRCONV('t', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'd', 'e', 'v', 'i', 'c', 'e'),
|
||||
|
||||
[3] = (uint16_t []) { // serials
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(4), TUSB_DESC_STRING),
|
||||
'1', '2', '3', '4' // len = 4
|
||||
},
|
||||
// 3: Serials TODO use chip ID
|
||||
TUD_DESC_STRCONV('1', '2', '3', '4', '5', '6'),
|
||||
|
||||
[4] = (uint16_t []) { // CDC Interface
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(3), TUSB_DESC_STRING),
|
||||
'c', 'd', 'c' // len = 3
|
||||
},
|
||||
// 4: CDC Interface
|
||||
TUD_DESC_STRCONV('t','u','s','b',' ','c','d','c'),
|
||||
|
||||
[5] = (uint16_t []) { // Keyboard Interface
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(5), TUSB_DESC_STRING),
|
||||
'm', 'o', 'u', 's', 'e' // len = 5
|
||||
},
|
||||
|
||||
[6] = (uint16_t []) { // Keyboard Interface
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(8), TUSB_DESC_STRING),
|
||||
'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd' // len = 8
|
||||
},
|
||||
|
||||
[7] = (uint16_t []) { // MSC Interface
|
||||
ENDIAN_BE16_FROM( STRING_LEN_UNICODE(3), TUSB_DESC_STRING),
|
||||
'm', 's', 'c' // len = 3
|
||||
}
|
||||
// 5: MSC Interface
|
||||
TUD_DESC_STRCONV('t','u','s','b',' ','m','s','c'),
|
||||
};
|
||||
|
||||
// tud_desc_set is required by tinyusb stack
|
||||
|
Loading…
x
Reference in New Issue
Block a user