diff options
| author | Ha Thach <[email protected]> | 2020-11-23 23:25:55 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-23 23:25:55 +0700 |
| commit | 308028e17cb4ba5e93413431a51bbe94d2afcc53 (patch) | |
| tree | 79ac511381d953b0ef35e70924da375b4bb0320b /examples/device/cdc_msc/src | |
| parent | 339b1a772350321d0f9d4f84e93c5360247e3f17 (diff) | |
| parent | b870d932e5e1c6ece4227a5d49cc71e53a744149 (diff) | |
Merge branch 'master' into cdc_without_dtr
Diffstat (limited to 'examples/device/cdc_msc/src')
| -rw-r--r-- | examples/device/cdc_msc/src/msc_disk.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/device/cdc_msc/src/msc_disk.c b/examples/device/cdc_msc/src/msc_disk.c index 5aa7befc9..503baace9 100644 --- a/examples/device/cdc_msc/src/msc_disk.c +++ b/examples/device/cdc_msc/src/msc_disk.c @@ -28,6 +28,9 @@ #if CFG_TUD_MSC +// whether host does safe-eject +static bool ejected = false; + // 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 // CFG_EXAMPLE_MSC_READONLY defined @@ -137,7 +140,13 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) { (void) lun; - return true; // RAM disk is always ready + // RAM disk is ready until 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 @@ -166,6 +175,7 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo }else { // unload disk storage + ejected = true; } } |
