|
@@ -28,6 +28,8 @@
|
|
|
|
|
|
|
|
#if CFG_TUD_MSC
|
|
#if CFG_TUD_MSC
|
|
|
|
|
|
|
|
|
|
+static bool ejected = false;
|
|
|
|
|
+
|
|
|
// Some MCU doesn't have enough 8KB SRAM to store the whole disk
|
|
// Some MCU doesn't have enough 8KB SRAM to store the whole disk
|
|
|
// We will use Flash as read-only disk with board that has
|
|
// We will use Flash as read-only disk with board that has
|
|
|
// CFG_EXAMPLE_MSC_READONLY defined
|
|
// CFG_EXAMPLE_MSC_READONLY defined
|
|
@@ -137,7 +139,13 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun)
|
|
|
{
|
|
{
|
|
|
(void) lun;
|
|
(void) lun;
|
|
|
|
|
|
|
|
- return true; // RAM disk is always ready
|
|
|
|
|
|
|
+ // RAM disk is ready until is not ejected
|
|
|
|
|
+ if (ejected) {
|
|
|
|
|
+ tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x3a, 0x00);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
|
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
|
@@ -166,6 +174,7 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
|
|
|
}else
|
|
}else
|
|
|
{
|
|
{
|
|
|
// unload disk storage
|
|
// unload disk storage
|
|
|
|
|
+ ejected = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|