summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2018-07-26 17:15:45 +0700
committerhathach <thach@tinyusb.org>2018-07-26 17:16:41 +0700
commit5bdf40901fe6592ce094e3d73927b03f54f96e30 (patch)
tree4ad0c8d11ebd23e5fdfca061af189d7e5bb66dfe
parentfbfc9c39957b389fd359ed8107d1e244e9749930 (diff)
update tusb lib
m---------lib/tinyusb0
-rw-r--r--ports/nrf/usb/usb.c9
-rw-r--r--ports/nrf/usb/usb_msc_flash.c83
3 files changed, 29 insertions, 63 deletions
diff --git a/lib/tinyusb b/lib/tinyusb
-Subproject 421ae8fc82b884e087e99c8ab3fa25883a3dd62
+Subproject e362f5fd64d257e3ad70962be59fc8593a0f5d9
diff --git a/ports/nrf/usb/usb.c b/ports/nrf/usb/usb.c
index 648ee708d..76ae2ad39 100644
--- a/ports/nrf/usb/usb.c
+++ b/ports/nrf/usb/usb.c
@@ -71,7 +71,14 @@ tud_desc_set_t tud_desc_set =
.device = NULL,
.config = NULL,
.string_arr = (uint8_t const **) string_desc_arr,
- .hid_report = NULL
+ .string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
+
+ .hid_report =
+ {
+ .composite = NULL,
+ .boot_keyboard = NULL,
+ .boot_mouse = NULL
+ }
};
diff --git a/ports/nrf/usb/usb_msc_flash.c b/ports/nrf/usb/usb_msc_flash.c
index f77a9e5c5..3d832036e 100644
--- a/ports/nrf/usb/usb_msc_flash.c
+++ b/ports/nrf/usb/usb_msc_flash.c
@@ -53,90 +53,51 @@
#define FL_PAGE_SZ 4096
-static scsi_sense_fixed_data_t mscd_sense_data =
-{
- .response_code = 0x70,
- .sense_key = 0, // no errors
- .additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8
-};
-
-static scsi_mode_parameters_t const msc_dev_mode_para =
-{
- .mode_data_length = 3,
- .medium_type = 0,
- .device_specific_para = 0,
- .block_descriptor_length = 0
-};
-
//--------------------------------------------------------------------+
// tinyusb callbacks
//--------------------------------------------------------------------+
-int32_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
+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
- void const* ptr = NULL;
+ void const* resp = NULL;
uint16_t len = 0;
- // most scsi handled is input
- bool in_xfer = true;
-
- switch ( scsi_cmd[0] )
- {
- case SCSI_CMD_REQUEST_SENSE:
- ptr = &mscd_sense_data;
- len = sizeof(scsi_sense_fixed_data_t);
- break;
-
- case SCSI_CMD_MODE_SENSE_6:
- ptr = &msc_dev_mode_para;
- len = sizeof(msc_dev_mode_para);
- break;
-
+ switch ( scsi_cmd[0] ) {
case SCSI_CMD_TEST_UNIT_READY:
- ptr = NULL;
+ // Command that host uses to check our readiness before sending other commands
len = 0;
break;
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
- ptr = NULL;
+ // Host is about to read/write etc ... better not to disconnect disk
len = 0;
break;
- default:
- // negative is error -> Data stage is STALL, status = failed
- return -1;
+ 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
+ // scsi_start_stop_unit_t const * cmd_start_stop = (scsi_start_stop_unit_t const *) scsi_cmd
+ len = 0;
+ break;
+
+ // negative means error -> tusb could stall and/or response with failed status
+ default: return -1;
}
// return len must not larger than bufsize
- TU_ASSERT(bufsize >= len);
-
- if ( ptr && len )
- {
- if ( in_xfer )
- {
- memcpy(buffer, ptr, len);
- } else
- {
- // SCSI output
- }
- }
+ if ( len > bufsize ) len = bufsize;
- //------------- clear sense data if it is not request sense command -------------//
- if ( SCSI_CMD_REQUEST_SENSE != scsi_cmd[0] )
- {
- mscd_sense_data.sense_key = SCSI_SENSEKEY_NONE;
- mscd_sense_data.additional_sense_code = 0;
- mscd_sense_data.additional_sense_qualifier = 0;
+ // copy response to stack's buffer if any
+ if ( resp && len ) {
+ memcpy(buffer, resp, len);
}
return len;
}
/*------------------------------------------------------------------*/
-/* Tinyusb Flash READ10 & WRITE10
+/* tinyusb Flash READ10 & WRITE10
*------------------------------------------------------------------*/
-int32_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
- (void) rhport;
+int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
(void) lun;
(void) offset;
@@ -147,8 +108,7 @@ int32_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t o
return block_count * MSC_FLASH_BLOCK_SIZE;
}
-int32_t tud_msc_write10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
- (void) rhport;
+int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) {
(void) lun;
(void) offset;
@@ -167,8 +127,7 @@ int32_t tud_msc_write10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint32_t
return block_count * MSC_FLASH_BLOCK_SIZE;
}
-void tud_msc_write10_complete_cb (uint8_t rhport, uint8_t lun) {
- (void) rhport;
+void tud_msc_write10_complete_cb (uint8_t lun) {
(void) lun;
// flush pending cache when write10 is complete