summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/bsp/boards/printf_retarget.c7
-rw-r--r--demos/host/host_os_none/host_os_none.uvopt78
-rw-r--r--demos/host/src/main.c8
-rw-r--r--demos/host/src/msc_app.c12
-rw-r--r--demos/host/src/tusb_config.h6
-rw-r--r--tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c22
-rw-r--r--tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c1
-rw-r--r--tinyusb/class/msc.h30
-rw-r--r--tinyusb/class/msc_host.c66
-rw-r--r--tinyusb/class/msc_host.h8
-rw-r--r--tinyusb/host/ehci/ehci.c23
11 files changed, 197 insertions, 64 deletions
diff --git a/demos/bsp/boards/printf_retarget.c b/demos/bsp/boards/printf_retarget.c
index fc6db7c90..7932ab147 100644
--- a/demos/bsp/boards/printf_retarget.c
+++ b/demos/bsp/boards/printf_retarget.c
@@ -74,12 +74,7 @@ int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
return iLength;
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
- uint32_t i;
- for (i = 0; i<iLength; i++)
- {
- ITM_SendChar(pcBuffer[i]); // print each character
- }
- return iLength;
+ #error author does not know how to retarget SWO with lpcxpresso/red-suite
#else
#error Thach, did you forget something
#endif
diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt
index b2adbd490..45e4c5025 100644
--- a/demos/host/host_os_none/host_os_none.uvopt
+++ b/demos/host/host_os_none/host_os_none.uvopt
@@ -73,7 +73,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
- <IsCurrentTarget>0</IsCurrentTarget>
+ <IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>8</CpuCode>
<Books>
@@ -135,7 +135,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
- <Name></Name>
+ <Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@@ -170,6 +170,16 @@
<WinNumber>1</WinNumber>
<ItemText>msch_data</ItemText>
</Ww>
+ <Ww>
+ <count>2</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>mouse_data</ItemText>
+ </Ww>
+ <Ww>
+ <count>3</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>keyboard_data</ItemText>
+ </Ww>
</WatchWindow1>
<DebugFlag>
<trace>0</trace>
@@ -191,7 +201,7 @@
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
- <aSer4>1</aSer4>
+ <aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
@@ -202,12 +212,6 @@
</Tracepoint>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
- <SystemViewers>
- <Entry>
- <Name>System Viewer\USB0</Name>
- <WinId>35905</WinId>
- </Entry>
- </SystemViewers>
</TargetOption>
</Target>
@@ -264,7 +268,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
- <IsCurrentTarget>1</IsCurrentTarget>
+ <IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>8</CpuCode>
<Books>
@@ -336,7 +340,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
- <Name></Name>
+ <Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@@ -403,10 +407,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>71</ColumnNumber>
+ <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>166</TopLine>
- <CurrentLine>183</CurrentLine>
+ <TopLine>1</TopLine>
+ <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
@@ -421,8 +425,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>1</TopLine>
- <CurrentLine>1</CurrentLine>
+ <TopLine>95</TopLine>
+ <CurrentLine>107</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\cdc_serial_app.c</PathWithFileName>
<FilenameWithoutPath>cdc_serial_app.c</FilenameWithoutPath>
@@ -451,10 +455,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>0</ColumnNumber>
+ <ColumnNumber>43</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>1</TopLine>
- <CurrentLine>1</CurrentLine>
+ <TopLine>113</TopLine>
+ <CurrentLine>127</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\mouse_app.c</PathWithFileName>
<FilenameWithoutPath>mouse_app.c</FilenameWithoutPath>
@@ -509,7 +513,7 @@
<Focus>0</Focus>
<ColumnNumber>31</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>23</TopLine>
+ <TopLine>33</TopLine>
<CurrentLine>55</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\board.c</PathWithFileName>
@@ -525,7 +529,7 @@
<Focus>0</Focus>
<ColumnNumber>2</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>142</TopLine>
+ <TopLine>143</TopLine>
<CurrentLine>146</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName>
@@ -541,7 +545,7 @@
<Focus>0</Focus>
<ColumnNumber>1</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>97</TopLine>
+ <TopLine>96</TopLine>
<CurrentLine>106</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
@@ -677,7 +681,7 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>33</TopLine>
+ <TopLine>23</TopLine>
<CurrentLine>69</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName>
@@ -755,10 +759,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>25</ColumnNumber>
+ <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>143</TopLine>
- <CurrentLine>147</CurrentLine>
+ <TopLine>1</TopLine>
+ <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
<FilenameWithoutPath>ehci.c</FilenameWithoutPath>
@@ -803,10 +807,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>7</ColumnNumber>
+ <ColumnNumber>8</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>77</TopLine>
- <CurrentLine>112</CurrentLine>
+ <TopLine>67</TopLine>
+ <CurrentLine>77</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\hal\hal_lpc43xx.c</PathWithFileName>
<FilenameWithoutPath>hal_lpc43xx.c</FilenameWithoutPath>
@@ -867,10 +871,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>0</ColumnNumber>
+ <ColumnNumber>51</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine>
- <CurrentLine>1</CurrentLine>
+ <CurrentLine>17</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\class\cdc_host.c</PathWithFileName>
<FilenameWithoutPath>cdc_host.c</FilenameWithoutPath>
@@ -899,10 +903,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>0</ColumnNumber>
+ <ColumnNumber>63</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>0</TopLine>
- <CurrentLine>0</CurrentLine>
+ <TopLine>264</TopLine>
+ <CurrentLine>286</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\class\hid_host.c</PathWithFileName>
<FilenameWithoutPath>hid_host.c</FilenameWithoutPath>
@@ -1043,10 +1047,10 @@
<FileType>2</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
- <ColumnNumber>0</ColumnNumber>
+ <ColumnNumber>25</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
- <TopLine>145</TopLine>
- <CurrentLine>146</CurrentLine>
+ <TopLine>138</TopLine>
+ <CurrentLine>161</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
<FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
diff --git a/demos/host/src/main.c b/demos/host/src/main.c
index 6ec9fd795..14cf0b826 100644
--- a/demos/host/src/main.c
+++ b/demos/host/src/main.c
@@ -112,10 +112,16 @@ void os_none_start_scheduler(void)
msc_app_task(NULL);
cdc_serial_app_task(NULL);
rndis_app_task(NULL);
+
+// int ch = ITM_ReceiveChar();
+// if ( ch > 0 )
+// {
+// printf("%c", ch);
+// }
}
}
#endif
-
+volatile int32_t ITM_RxBuffer;
int main(void)
{
diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c
index 54de0d0cf..e2e5d7e4c 100644
--- a/demos/host/src/msc_app.c
+++ b/demos/host/src/msc_app.c
@@ -61,6 +61,18 @@
void tusbh_msc_mounted_cb(uint8_t dev_addr)
{
printf("an msc device is mounted\n");
+
+ // SCSI VendorID[8] & ProductID[16] from Inquiry Command
+ uint8_t const* p_vendor = tusbh_msc_get_vendor_name(dev_addr);
+ uint8_t const* p_product = tusbh_msc_get_product_name(dev_addr);
+
+ printf("Vendor Id: ");
+ for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
+
+ printf("\nProduct Id: ");
+ for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
+
+ putchar('\n');
}
//--------------------------------------------------------------------+
diff --git a/demos/host/src/tusb_config.h b/demos/host/src/tusb_config.h
index 30891fcbb..99edfcf7b 100644
--- a/demos/host/src/tusb_config.h
+++ b/demos/host/src/tusb_config.h
@@ -73,12 +73,12 @@
//------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0
-#define TUSB_CFG_HOST_HID_KEYBOARD 1
+#define TUSB_CFG_HOST_HID_KEYBOARD 0
#define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0
#define TUSB_CFG_HOST_MSC 1
-#define TUSB_CFG_HOST_CDC 1
-#define TUSB_CFG_HOST_CDC_RNDIS 1
+#define TUSB_CFG_HOST_CDC 0
+#define TUSB_CFG_HOST_CDC_RNDIS 0
//--------------------------------------------------------------------+
// DEVICE CONFIGURATION
diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c
index 4ddc519aa..9a3d0a36b 100644
--- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c
+++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_open.c
@@ -117,6 +117,16 @@ tusb_descriptor_endpoint_t const desc_ept_bulk_in =
.bInterval = 0
};
+tusb_descriptor_endpoint_t const desc_ept_bulk_out =
+{
+ .bLength = sizeof(tusb_descriptor_endpoint_t),
+ .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
+ .bEndpointAddress = 0x01,
+ .bmAttributes = { .xfer = TUSB_XFER_BULK },
+ .wMaxPacketSize = 512,
+ .bInterval = 0
+};
+
void verify_bulk_open_qhd(ehci_qhd_t *p_qhd, tusb_descriptor_endpoint_t const * desc_endpoint, uint8_t class_code)
{
verify_open_qhd(p_qhd, desc_endpoint->bEndpointAddress, desc_endpoint->wMaxPacketSize.size);
@@ -159,6 +169,18 @@ void test_open_bulk_qhd_data(void)
TEST_ASSERT_EQUAL(EHCI_QUEUE_ELEMENT_QHD, async_head->next.type);
}
+void test_open_bulk_hs_out_pingstate(void)
+{
+ ehci_qhd_t *p_qhd;
+ pipe_handle_t pipe_hdl;
+
+ //------------- Code Under TEST -------------//
+ pipe_hdl = hcd_pipe_open(dev_addr, &desc_ept_bulk_out, TUSB_CLASS_MSC);
+
+ p_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1 ].qhd[ pipe_hdl.index ];
+ TEST_ASSERT(p_qhd->qtd_overlay.pingstate_err);
+}
+
//--------------------------------------------------------------------+
// PIPE CLOSE
//--------------------------------------------------------------------+
diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c
index babee4482..221fe0ee2 100644
--- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c
+++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c
@@ -155,7 +155,6 @@ void test_bulk_xfer_hs_ping_out(void)
TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl, xfer_data, sizeof(xfer_data), true) );
ehci_qtd_t* p_qtd = p_qhd->p_qtd_list_head;
- TEST_ASSERT(p_qtd->pingstate_err);
}
void test_bulk_xfer(void)
diff --git a/tinyusb/class/msc.h b/tinyusb/class/msc.h
index c8662089e..f52cdc343 100644
--- a/tinyusb/class/msc.h
+++ b/tinyusb/class/msc.h
@@ -76,6 +76,20 @@ enum {
MSC_REQUEST_RESET = 255
};
+typedef enum {
+ SCSI_CMD_TEST_UNIT_READY = 0x00,
+ SCSI_CMD_INQUIRY = 0x12,
+ SCSI_CMD_READ_CAPACITY_10 = 0x25,
+ SCSI_CMD_READ_10 = 0x28,
+ SCSI_CMD_WRITE_10 = 0x2A,
+}scsi_cmd_type_t;
+
+typedef enum {
+ MSC_CSW_STATUS_PASSED = 0,
+ MSC_CSW_STATUS_FAILED,
+ MSC_CSW_STATUS_PHASE_ERROR
+}msc_csw_status_t;
+
typedef ATTR_PACKED_STRUCT(struct) {
uint32_t signature; // const 0x43425355
uint32_t tag;
@@ -100,6 +114,16 @@ STATIC_ASSERT(sizeof(msc_cmd_status_wrapper_t) == 13, "size is not correct");
//--------------------------------------------------------------------+
// SCSI Primary Command (SPC-4)
//--------------------------------------------------------------------+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t operation_code;
+ uint8_t reserve;
+ uint8_t page_code;
+ uint16_t alloc_length;
+ uint8_t control;
+} scsi_inquiry_t;
+
+STATIC_ASSERT(sizeof(scsi_inquiry_t) == 6, "size is not correct");
+
typedef ATTR_PACKED_STRUCT(struct)
{
uint8_t peripheral_device_type : 5;
@@ -141,9 +165,9 @@ typedef ATTR_PACKED_STRUCT(struct)
uint8_t vendor_id[8];
uint8_t product_id[16];
uint8_t product_revision[4];
-} msc_scsi_inquiry_t;
+} scsi_inquiry_data_t;
-STATIC_ASSERT(sizeof(msc_scsi_inquiry_t) == 36, "size is not correct");
+STATIC_ASSERT(sizeof(scsi_inquiry_data_t) == 36, "size is not correct");
//--------------------------------------------------------------------+
// SCSI Block Command (SBC-3)
@@ -153,6 +177,8 @@ typedef struct {
uint8_t block_length[4];
} msc_scsi_read_capacity10_t;
+
+
#ifdef __cplusplus
}
#endif
diff --git a/tinyusb/class/msc_host.c b/tinyusb/class/msc_host.c
index f5c4dbd25..f4d72cf9c 100644
--- a/tinyusb/class/msc_host.c
+++ b/tinyusb/class/msc_host.c
@@ -56,8 +56,12 @@ typedef struct {
uint8_t interface_number;
uint8_t max_lun;
+ uint8_t vendor_id[8];
+ uint8_t product_id[16];
+
msc_cmd_block_wrapper_t cbw;
msc_cmd_status_wrapper_t csw;
+ uint8_t buffer[100];
}msch_interface_t;
STATIC_VAR msch_interface_t msch_data[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM; // TODO to be static
@@ -70,8 +74,24 @@ STATIC_VAR uint8_t msch_buffer[10] TUSB_CFG_ATTR_USBRAM;
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+
-// IMPLEMENTATION
+// PUBLIC API
//--------------------------------------------------------------------+
+bool tusbh_msc_is_mounted(uint8_t dev_addr)
+{
+ return tusbh_device_is_configured(dev_addr) &&
+ pipehandle_is_valid(msch_data[dev_addr-1].bulk_in) &&
+ pipehandle_is_valid(msch_data[dev_addr-1].bulk_out);
+}
+
+uint8_t const * tusbh_msc_get_vendor_name(uint8_t dev_addr)
+{
+ return tusbh_msc_is_mounted(dev_addr) ? msch_data[dev_addr-1].vendor_id : NULL;
+}
+
+uint8_t const * tusbh_msc_get_product_name(uint8_t dev_addr)
+{
+ return tusbh_msc_is_mounted(dev_addr) ? msch_data[dev_addr-1].product_id : NULL;
+}
//--------------------------------------------------------------------+
// CLASS-USBH API (don't require to verify parameters)
@@ -123,7 +143,37 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
msch_data[dev_addr-1].max_lun = msch_buffer[0];
//------------- SCSI Inquiry -------------//
+ msch_data[dev_addr-1].cbw = (msc_cmd_block_wrapper_t) {
+ .signature = 0x43425355,
+ .tag = 0xCAFECAFE,
+ .xfer_bytes = sizeof(scsi_inquiry_data_t),
+ .flags = TUSB_DIR_DEV_TO_HOST_MASK,
+ .lun = 0,
+ .cmd_len = sizeof(scsi_inquiry_t),
+ };
+ scsi_inquiry_t cmd_inquiry =
+ {
+ .operation_code = SCSI_CMD_INQUIRY,
+ .alloc_length = sizeof(scsi_inquiry_data_t)
+ };
+ memcpy(msch_data[dev_addr-1].cbw.command, &cmd_inquiry, sizeof(scsi_inquiry_t));
+
+ hcd_pipe_xfer(msch_data[dev_addr-1].bulk_out, &msch_data[dev_addr-1].cbw, sizeof(msc_cmd_block_wrapper_t), false);
+ hcd_pipe_xfer(msch_data[dev_addr-1].bulk_in , msch_data[dev_addr-1].buffer, sizeof(scsi_inquiry_data_t), false);
+ hcd_pipe_xfer(msch_data[dev_addr-1].bulk_in , &msch_data[dev_addr-1].csw, sizeof(msc_cmd_status_wrapper_t), true);
+
+ // TODO timeout required, a proper synchronization
+// while( !hcd_pipe_is_idle(msch_data[dev_addr-1].bulk_in) )
+ {
+ osal_task_delay(2);
+ }
+ memcpy(msch_data[dev_addr-1].vendor_id,
+ ((scsi_inquiry_data_t*)msch_data[dev_addr-1].buffer)->vendor_id,
+ 8);
+ memcpy(msch_data[dev_addr-1].product_id,
+ ((scsi_inquiry_data_t*)msch_data[dev_addr-1].buffer)->product_id,
+ 16);
tusbh_msc_mounted_cb(dev_addr);
@@ -145,5 +195,19 @@ void msch_close(uint8_t dev_addr)
memclr_(&msch_data[dev_addr-1], sizeof(msch_interface_t));
}
+//--------------------------------------------------------------------+
+// INTERNAL & HELPER
+//--------------------------------------------------------------------+
+//static tusb_error_t scsi_command_send(msc_cmd_block_wrapper_t const * cbw, uint8_t * buffer, msc_cmd_status_wrapper_t const * csw)
+//{
+// tusb_error_t error;
+//
+// OSAL_SUBTASK_BEGIN
+//
+// hcd_pipe_xfer()
+//
+// OSAL_SUBTASK_END
+//}
+
#endif
diff --git a/tinyusb/class/msc_host.h b/tinyusb/class/msc_host.h
index d6a976397..1fd99788d 100644
--- a/tinyusb/class/msc_host.h
+++ b/tinyusb/class/msc_host.h
@@ -58,10 +58,12 @@
//--------------------------------------------------------------------+
// MASS STORAGE Application API
//--------------------------------------------------------------------+
-bool tusbh_msc_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-tusb_interface_status_t tusbh_msc_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
+bool tusbh_msc_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
+tusb_interface_status_t tusbh_msc_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
+uint8_t const * tusbh_msc_get_vendor_name(uint8_t dev_addr);
+uint8_t const * tusbh_msc_get_product_name(uint8_t dev_addr);
-tusb_error_t tusbh_msc_inquiry(uint8_t dev_addr, uint8_t instance_num, msc_scsi_inquiry_t * p_inquiry_data) ATTR_WARN_UNUSED_RESULT;
+tusb_error_t tusbh_msc_inquiry(uint8_t dev_addr, uint8_t instance_num, scsi_inquiry_data_t * p_inquiry_data) ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_msc_test_unit_ready(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_msc_read_capacity10(uint8_t dev_addr, uint8_t instance_num, msc_scsi_read_capacity10_t * p_buffer) ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_msc_read10(uint8_t dev_addr, uint8_t instance_num, void * p_buffer, uint32_t length) ATTR_WARN_UNUSED_RESULT;
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index 3a8562a36..0597c1e07 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -373,6 +373,7 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *
if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS)
return null_handle; // TODO not support ISO yet
+ //------------- Prepare Queue Head -------------//
ehci_qhd_t * const p_qhd = qhd_find_free(dev_addr);
ASSERT_PTR(p_qhd, null_handle);
@@ -380,6 +381,7 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *
p_endpoint_desc->bmAttributes.xfer, p_endpoint_desc->bInterval );
p_qhd->class_code = class_code;
+ //------------- Insert to Async List -------------//
ehci_link_t * list_head;
if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_BULK)
@@ -413,11 +415,6 @@ tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t t
qtd_init(p_qtd, (uint32_t) buffer, total_bytes);
p_qtd->pid = p_qhd->pid_non_control;
p_qtd->int_on_complete = int_on_complete ? 1 : 0;
- // do PING for Highspeed Bulk OUT, EHCI section 4.11
- if (pipe_hdl.xfer_type == TUSB_XFER_BULK && p_qhd->endpoint_speed == TUSB_SPEED_HIGH && p_qtd->pid == EHCI_PID_OUT)
- {
- p_qtd->pingstate_err = 1;
- }
//------------- insert TD to TD list -------------//
qtd_insert_to_qhd(p_qhd, p_qtd);
@@ -649,6 +646,7 @@ static void xfer_error_isr(uint8_t hostid)
max_loop++;
}while(p_qhd != async_head && max_loop < EHCI_MAX_QHD); // async list traversal, stop if loop around
+ #if EHCI_PERIODIC_LIST
//------------- TODO refractor period list -------------//
uint32_t const period_1ms_addr = (uint32_t) get_period_head(hostid, 1);
for (uint8_t interval_ms=1; interval_ms <= EHCI_FRAMELIST_SIZE; interval_ms *= 2)
@@ -682,6 +680,7 @@ static void xfer_error_isr(uint8_t hostid)
period_max_loop++;
}
}
+ #endif
}
//------------- Host Controller Driver's Interrupt Handler -------------//
@@ -910,6 +909,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
p_qhd->nak_count_reload = 0;
// Bulk/Control -> smask = cmask = 0
+ // TODO Isochronous
if (TUSB_XFER_INTERRUPT == xfer_type)
{
if (TUSB_SPEED_HIGH == p_qhd->endpoint_speed)
@@ -942,11 +942,6 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
p_qhd->hub_port = usbh_devices[dev_addr].hub_port;
p_qhd->mult = 1; // TODO not use high bandwidth/park mode yet
- //------------- active, but no TD list -------------//
- p_qhd->qtd_overlay.halted = 0;
- p_qhd->qtd_overlay.next.terminate = 1;
- p_qhd->qtd_overlay.alternate.terminate = 1;
-
//------------- HCD Management Data -------------//
p_qhd->used = 1;
p_qhd->is_removing = 0;
@@ -954,6 +949,14 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
p_qhd->p_qtd_list_tail = NULL;
p_qhd->pid_non_control = (endpoint_addr & 0x80) ? EHCI_PID_IN : EHCI_PID_OUT; // PID for TD under this endpoint
+ //------------- active, but no TD list -------------//
+ p_qhd->qtd_overlay.halted = 0;
+ p_qhd->qtd_overlay.next.terminate = 1;
+ p_qhd->qtd_overlay.alternate.terminate = 1;
+ if (TUSB_XFER_BULK == xfer_type && p_qhd->endpoint_speed == TUSB_SPEED_HIGH && p_qhd->pid_non_control == EHCI_PID_OUT)
+ {
+ p_qhd->qtd_overlay.pingstate_err = 1; // do PING for Highspeed Bulk OUT, EHCI section 4.11
+ }
}
static void qtd_init(ehci_qtd_t* p_qtd, uint32_t data_ptr, uint16_t total_bytes)