summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-07-26 22:44:11 +0700
committerhathach <[email protected]>2018-07-26 22:44:11 +0700
commitf5cbc0f4af38fea76022cf1c51b1d374723b1ae8 (patch)
treec5ce43f2e95b96c1e6e50416893c02e0c33ff9af /examples
parent72b600c393e543361b073abee3da823d41383660 (diff)
house keeping
Diffstat (limited to 'examples')
-rw-r--r--examples/device/nrf52840/src/msc_device_app.c7
-rw-r--r--examples/device/nrf52840/src/msc_device_ramdisk.c8
2 files changed, 10 insertions, 5 deletions
diff --git a/examples/device/nrf52840/src/msc_device_app.c b/examples/device/nrf52840/src/msc_device_app.c
index aa6b2fb43..96dea077e 100644
--- a/examples/device/nrf52840/src/msc_device_app.c
+++ b/examples/device/nrf52840/src/msc_device_app.c
@@ -57,6 +57,9 @@ void msc_app_umount(uint8_t rhport)
}
+// Callback invoked when received an SCSI command not in built-in list below
+// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
+// - READ10 and WRITE10 has their own callbacks
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
{
// read10 & write10 has their own callback and MUST not be handled here
@@ -80,12 +83,12 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
break;
case SCSI_CMD_START_STOP_UNIT:
- // Host try to eject/safe remove/powerof us. We could safely disconnect with disk storage, or go into lower power
+ // Host try to eject/safe remove/poweroff us. We could safely disconnect with disk storage, or go into lower power
// scsi_start_stop_unit_t const * cmd_start_stop = (scsi_start_stop_unit_t const *) scsi_cmd
len = 0;
break;
- // negative is error -> Data stage is STALL, status = failed
+ // negative means error -> tusb could stall and/or response with failed status
default: return -1;
}
diff --git a/examples/device/nrf52840/src/msc_device_ramdisk.c b/examples/device/nrf52840/src/msc_device_ramdisk.c
index 3d2fca1d6..91ef442db 100644
--- a/examples/device/nrf52840/src/msc_device_ramdisk.c
+++ b/examples/device/nrf52840/src/msc_device_ramdisk.c
@@ -88,9 +88,9 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
[3] = README_CONTENTS
};
-//--------------------------------------------------------------------+
-// IMPLEMENTATION
-//--------------------------------------------------------------------+
+
+// 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)
{
uint8_t* addr = msc_device_ramdisk[lba] + offset;
@@ -99,6 +99,8 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
return bufsize;
}
+// Callback invoked when received WRITE10 command.
+// Process data in buffer to disk's storage and return number of written bytes
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{
uint8_t* addr = msc_device_ramdisk[lba] + offset;