@@ -56,6 +56,13 @@ uint8_t Adafruit_USBD_MSC::getMaxLun(void)
56
56
return _maxlun;
57
57
}
58
58
59
+ void Adafruit_USBD_MSC::setID (uint8_t lun, const char * vendor_id, const char * product_id, const char * product_rev)
60
+ {
61
+ _lun[lun]._inquiry_vid = vendor_id;
62
+ _lun[lun]._inquiry_pid = product_id;
63
+ _lun[lun]._inquiry_rev = product_rev;
64
+ }
65
+
59
66
void Adafruit_USBD_MSC::setCapacity (uint8_t lun, uint32_t block_count, uint16_t block_size)
60
67
{
61
68
_lun[lun].block_count = block_count;
@@ -88,12 +95,36 @@ extern "C"
88
95
{
89
96
90
97
// Invoked to determine max LUN
91
- uint8_t tud_msc_maxlun_cb (void )
98
+ uint8_t tud_msc_get_maxlun_cb (void )
92
99
{
93
100
if (!_msc_dev) return 0 ;
94
101
return _msc_dev->getMaxLun ();
95
102
}
96
103
104
+ // Invoked when received SCSI_CMD_INQUIRY
105
+ // Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
106
+ void tud_msc_inquiry_cb (uint8_t lun, uint8_t vendor_id[8 ], uint8_t product_id[16 ], uint8_t product_rev[4 ])
107
+ {
108
+ if (!_msc_dev) return ;
109
+
110
+ const char * vid = (_msc_dev->_lun [lun]._inquiry_vid ? _msc_dev->_lun [lun]._inquiry_vid : " Adafruit" );
111
+ const char * pid = (_msc_dev->_lun [lun]._inquiry_pid ? _msc_dev->_lun [lun]._inquiry_pid : " Mass Storage" );
112
+ const char * rev = (_msc_dev->_lun [lun]._inquiry_rev ? _msc_dev->_lun [lun]._inquiry_rev : " 1.0" );
113
+
114
+ memcpy (vendor_id , vid, tu_min32 (strlen (vid), 8 ));
115
+ memcpy (product_id , pid, tu_min32 (strlen (pid), 16 ));
116
+ memcpy (product_rev, rev, tu_min32 (strlen (rev), 4 ));
117
+ }
118
+
119
+ // Invoked when received Test Unit Ready command.
120
+ // return true allowing host to read/write this LUN e.g SD card inserted
121
+ bool tud_msc_test_unit_ready_cb (uint8_t lun)
122
+ {
123
+ (void ) lun;
124
+
125
+ return true ; // RAM disk is always ready
126
+ }
127
+
97
128
// Callback invoked to determine disk's size
98
129
void tud_msc_capacity_cb (uint8_t lun, uint32_t * block_count, uint16_t * block_size)
99
130
{
@@ -111,27 +142,11 @@ int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer,
111
142
112
143
switch ( scsi_cmd[0 ] )
113
144
{
114
- case SCSI_CMD_TEST_UNIT_READY:
115
- // Command that host uses to check our readiness before sending other commands
116
- resplen = 0 ;
117
- break ;
118
-
119
145
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
120
146
// Host is about to read/write etc ... better not to disconnect disk
121
147
resplen = 0 ;
122
148
break ;
123
149
124
- case SCSI_CMD_START_STOP_UNIT:
125
- // Host try to eject/safe remove/poweroff us. We could safely disconnect with disk storage, or go into lower power
126
- /* scsi_start_stop_unit_t const * start_stop = (scsi_start_stop_unit_t const *) scsi_cmd;
127
- // Start bit = 0 : low power mode, if load_eject = 1 : unmount disk storage as well
128
- // Start bit = 1 : Ready mode, if load_eject = 1 : mount disk storage
129
- start_stop->start;
130
- start_stop->load_eject;
131
- */
132
- resplen = 0 ;
133
- break ;
134
-
135
150
default :
136
151
// Set Sense = Invalid Command Operation
137
152
tud_msc_set_sense (lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20 , 0x00 );
0 commit comments