rp2/msc_disk: Allow configuring the USB MSC inquiry response.

This was previously hard-coded to "Micropy" / "Mass Storage" / "1.0".

Now allow it to be overridden by a board.

Also change "Micropy" to "MicroPy" and "1.0" to "1.00" to match stm32.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2023-09-01 16:03:27 +10:00 committed by Damien George
parent 61f331374d
commit da6f1e1d1e
2 changed files with 15 additions and 7 deletions

View File

@ -44,13 +44,9 @@ static bool ejected = false;
// Invoked when received SCSI_CMD_INQUIRY // Invoked when received SCSI_CMD_INQUIRY
// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively // Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) { void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
const char vid[] = "Micropy"; memcpy(vendor_id, MICROPY_HW_USB_MSC_INQUIRY_VENDOR_STRING, MIN(strlen(MICROPY_HW_USB_MSC_INQUIRY_VENDOR_STRING), 8));
const char pid[] = "Mass Storage"; memcpy(product_id, MICROPY_HW_USB_MSC_INQUIRY_PRODUCT_STRING, MIN(strlen(MICROPY_HW_USB_MSC_INQUIRY_PRODUCT_STRING), 16));
const char rev[] = "1.0"; memcpy(product_rev, MICROPY_HW_USB_MSC_INQUIRY_REVISION_STRING, MIN(strlen(MICROPY_HW_USB_MSC_INQUIRY_REVISION_STRING), 4));
strncpy((char *)vendor_id, vid, 8);
strncpy((char *)product_id, pid, 16);
strncpy((char *)product_rev, rev, 4);
} }
// Invoked when received Test Unit Ready command. // Invoked when received Test Unit Ready command.

View File

@ -43,6 +43,18 @@
#define MICROPY_HW_USB_CDC_INTERFACE_STRING "Board CDC" #define MICROPY_HW_USB_CDC_INTERFACE_STRING "Board CDC"
#endif #endif
#ifndef MICROPY_HW_USB_MSC_INQUIRY_VENDOR_STRING
#define MICROPY_HW_USB_MSC_INQUIRY_VENDOR_STRING "MicroPy"
#endif
#ifndef MICROPY_HW_USB_MSC_INQUIRY_PRODUCT_STRING
#define MICROPY_HW_USB_MSC_INQUIRY_PRODUCT_STRING "Mass Storage"
#endif
#ifndef MICROPY_HW_USB_MSC_INQUIRY_REVISION_STRING
#define MICROPY_HW_USB_MSC_INQUIRY_REVISION_STRING "1.00"
#endif
#ifndef CFG_TUSB_RHPORT0_MODE #ifndef CFG_TUSB_RHPORT0_MODE
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE)
#endif #endif