summaryrefslogtreecommitdiff
path: root/examples/device/msc_dual_lun/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-05-06 16:48:50 +0700
committerhathach <[email protected]>2019-05-06 16:48:50 +0700
commit6e4dc2f23dd6fe7725b145f49b49116859916b5c (patch)
treee208050ed7987977b03c32607e4c54a1c819f6fe /examples/device/msc_dual_lun/src
parentefefbd3a4ef9d867d4aaa05e3c06e51b441aca6e (diff)
adding msc Start Stop to buitin command, but not complate yet
add tud_msc_start_stop_cb() as optional callback
Diffstat (limited to 'examples/device/msc_dual_lun/src')
-rw-r--r--examples/device/msc_dual_lun/src/msc_disk_dual.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/examples/device/msc_dual_lun/src/msc_disk_dual.c b/examples/device/msc_dual_lun/src/msc_disk_dual.c
index 48f5cfb18..fd6347300 100644
--- a/examples/device/msc_dual_lun/src/msc_disk_dual.c
+++ b/examples/device/msc_dual_lun/src/msc_disk_dual.c
@@ -234,15 +234,36 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun)
return true; // RAM disk is always ready
}
-// Callback invoked to determine disk's size
+// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
+// Application update block count and block size
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
{
- (void) lun; // both LUNs have same size
+ (void) lun;
*block_count = DISK_BLOCK_NUM;
*block_size = DISK_BLOCK_SIZE;
}
+// Invoked when received Start Stop Unit command
+// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
+// - Start = 1 : active mode, if load_eject = 1 : load disk storage
+void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
+{
+ (void) lun;
+ (void) power_condition;
+
+ if ( load_eject )
+ {
+ if (start)
+ {
+ // load disk storage
+ }else
+ {
+ // unload disk storage
+ }
+ }
+}
+
// Callback invoked when received READ10 command.
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)