summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-07-04 15:00:46 +0700
committerhathach <[email protected]>2018-07-04 15:00:46 +0700
commitfc139b009f4c49d4fdbf1b80097c94c8dabb1ee1 (patch)
treee8f7bc53384762c6baed35ea1f49d6b81df922bc /src
parent3eb410cf8521755874fb9900a7f711bcafdc81d5 (diff)
add CFG_TUD_MSC_VENDOR,CFG_TUD_MSC_PRODUCT, CFG_TUD_MSC_PRODUCT_REV for msc inquiry response
Diffstat (limited to 'src')
-rw-r--r--src/class/msc/msc.h6
-rw-r--r--src/class/msc/msc_device.c34
2 files changed, 36 insertions, 4 deletions
diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h
index a8af2b886..fc0b8730c 100644
--- a/src/class/msc/msc.h
+++ b/src/class/msc/msc.h
@@ -226,9 +226,9 @@ typedef struct ATTR_PACKED
uint8_t wbus16 : 1;
uint8_t : 2;
- uint8_t vendor_id[8] ; ///< 8 bytes of ASCII data identifying the vendor of the product. The T10 vendor identification shall be one assigned by INCITS. A list of assigned T10 vendor identifications is in Annex E and on the T10 web site (http://www.t10.org).
- uint8_t product_id[16] ; ///< 16 bytes of ASCII data defined by the vendor.
- uint8_t product_revision[4] ; ///< 4 bytes of ASCII data defined by the vendor.
+ uint8_t vendor_id[8] ; ///< 8 bytes of ASCII data identifying the vendor of the product.
+ uint8_t product_id[16]; ///< 16 bytes of ASCII data defined by the vendor.
+ uint8_t product_rev[4]; ///< 4 bytes of ASCII data defined by the vendor.
} scsi_inquiry_data_t;
VERIFY_STATIC(sizeof(scsi_inquiry_data_t) == 36, "size is not correct");
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index f8fa33de8..5a92d2470 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -71,6 +71,18 @@ VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
#error CFG_TUD_MSC_BUFSIZE must be defined, value of CFG_TUD_MSC_BLOCK_SZ should work well, the more the better
#endif
+#ifndef CFG_TUD_MSC_VENDOR
+ #error CFG_TUD_MSC_VENDOR 8-byte name must be defined
+#endif
+
+#ifndef CFG_TUD_MSC_PRODUCT
+ #error CFG_TUD_MSC_PRODUCT 16-byte name must be defined
+#endif
+
+#ifndef CFG_TUD_MSC_PRODUCT_REV
+ #error CFG_TUD_MSC_PRODUCT_REV 4-byte string must be defined
+#endif
+
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
@@ -252,6 +264,7 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, u
int32_t cb_result;
+ // TODO refactor later
if (SCSI_CMD_READ_CAPACITY_10 == p_cbw->command[0])
{
scsi_read_capacity10_data_t read_capa10 =
@@ -269,13 +282,32 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, u
{
.list_length = 8,
.block_num = ENDIAN_BE(CFG_TUD_MSC_BLOCK_NUM), // write capacity
- .descriptor_type = 2, // formatted media
+ .descriptor_type = 2, // formatted media
.block_size_u16 = ENDIAN_BE16(CFG_TUD_MSC_BLOCK_SZ)
};
cb_result = sizeof(read_fmt_capa);
memcpy(_mscd_buf, &read_fmt_capa, cb_result);
}
+ else if (SCSI_CMD_INQUIRY == p_cbw->command[0])
+ {
+ scsi_inquiry_data_t inquiry_rsp =
+ {
+ .is_removable = 1,
+ .version = 2,
+ .response_data_format = 2,
+ .vendor_id = "Adafruit",
+ .product_id = "Feather52840",
+ .product_rev = "1.0"
+ };
+
+ strncpy((char*) inquiry_rsp.vendor_id , CFG_TUD_MSC_VENDOR , sizeof(inquiry_rsp.vendor_id));
+ strncpy((char*) inquiry_rsp.product_id , CFG_TUD_MSC_PRODUCT , sizeof(inquiry_rsp.product_id));
+ strncpy((char*) inquiry_rsp.product_rev, CFG_TUD_MSC_PRODUCT_REV, sizeof(inquiry_rsp.product_rev));
+
+ cb_result = sizeof(inquiry_rsp);
+ memcpy(_mscd_buf, &inquiry_rsp, cb_result);
+ }
else
{
cb_result = tud_msc_scsi_cb(rhport, p_cbw->lun, p_cbw->command, _mscd_buf, p_msc->data_len);