diff --git a/tests/test/host/test_enum_task.c b/tests/test/host/test_enum_task.c index c64a7ce3..43238b06 100644 --- a/tests/test/host/test_enum_task.c +++ b/tests/test/host/test_enum_task.c @@ -186,6 +186,7 @@ void test_enum_failed_get_full_dev_desc(void) { osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(2)); + hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); @@ -202,6 +203,7 @@ void test_enum_failed_get_9byte_config_desc(void) { osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(3)); + hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1); tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); @@ -216,6 +218,7 @@ void test_enum_failed_get_9byte_config_desc(void) void test_enum_failed_get_full_config_desc(void) { osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(4)); + hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1); tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); @@ -231,6 +234,7 @@ void class_install_expect(void) void test_enum_parse_config_desc(void) { osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5)); + hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1); @@ -245,6 +249,7 @@ void test_enum_parse_config_desc(void) void test_enum_set_configure(void) { osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(6)); + hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1); class_install_expect(); diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index ee1113d9..1d415981 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -274,6 +274,7 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * { pipe_handle_t const null_handle = { .dev_addr = 0, .xfer_type = 0, .index = 0 }; + //------------- find a free queue head -------------// uint8_t index=0; while( indexbmAttributes.xfer == TUSB_XFER_BULK) { - //------------- insert to async list -------------// // TODO might need to to disable async list first list_head = get_async_head(usbh_device_info_pool[dev_addr].core_id); }else if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_INTERRUPT) { - //------------- insert to period list -------------// // TODO might need to to disable period list first list_head = get_period_head(usbh_device_info_pool[dev_addr].core_id); } + //------------- insert to async/period list -------------// p_qhd->next = list_head->next; list_head->next.address = (uint32_t) p_qhd; list_head->next.type = EHCI_QUEUE_ELEMENT_QHD; diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index d180d1c5..f918ca33 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -77,15 +77,13 @@ void hcd_isr(uint8_t hostid); //--------------------------------------------------------------------+ tusb_error_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size) ATTR_WARN_UNUSED_RESULT; tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * p_request, uint8_t data[]) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; + pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[]) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT; #if 0 -//tusb_error_t hcd_pipe_open( -// uint8_t hostid, uint8_t device_address, -// -// )ATTR_WARN_UNUSED_RESULT; -tusb_error_t hcd_pipe_close()ATTR_WARN_UNUSED_RESULT; -tusb_error_t hcd_pipe_transfer()ATTR_WARN_UNUSED_RESULT; tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT; #endif diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 794074f8..3c2010c0 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -173,12 +173,15 @@ OSAL_TASK_DECLARE(usbh_enumeration_task) ) ); - //------------- update port info & open control pipe for new address -------------// + //------------- update port info & close control pipe of addr0 -------------// usbh_device_info_pool[new_addr].core_id = usbh_device_info_pool[0].core_id; usbh_device_info_pool[new_addr].hub_addr = usbh_device_info_pool[0].hub_addr; usbh_device_info_pool[new_addr].hub_port = usbh_device_info_pool[0].hub_port; usbh_device_info_pool[new_addr].speed = usbh_device_info_pool[0].speed; usbh_device_info_pool[new_addr].status = TUSB_DEVICE_STATUS_ADDRESSED; + hcd_pipe_control_close(0); + + // open control pipe for new address TASK_ASSERT_STATUS ( hcd_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) ); //------------- Get full device descriptor -------------//