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 ccf30d724..ff68be458 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 @@ -208,7 +208,7 @@ void test_bulk_xfer_complete_isr(void) ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; - usbh_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, TUSB_EVENT_XFER_COMPLETE); + usbh_xfer_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, TUSB_EVENT_XFER_COMPLETE); //------------- Code Under Test -------------// ehci_controller_run(hostid); diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c index 266cf0ef2..bb1ca6692 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c @@ -227,7 +227,7 @@ void test_control_xfer_complete_isr(void) { TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); - usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_COMPLETE); + usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_COMPLETE); //------------- Code Under TEST -------------// ehci_controller_run(hostid); @@ -245,7 +245,7 @@ void test_control_xfer_error_isr(void) { TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); - usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_ERROR); + usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_ERROR); //------------- Code Under TEST -------------// ehci_controller_run_error(hostid); diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c index f72b5d3ae..d367292a8 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c @@ -200,7 +200,7 @@ void test_interrupt_xfer_complete_isr_interval_less_than_1ms(void) TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_interrupt, data2, sizeof(data2), true) ); - usbh_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_COMPLETE); + usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_COMPLETE); ehci_qtd_t* p_head = p_qhd_interrupt->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_interrupt->p_qtd_list_tail; diff --git a/tinyusb/class/cdc_host.h b/tinyusb/class/cdc_host.h index a40cea64e..5eee3670b 100644 --- a/tinyusb/class/cdc_host.h +++ b/tinyusb/class/cdc_host.h @@ -57,6 +57,11 @@ //--------------------------------------------------------------------+ // APPLICATION PUBLIC API //--------------------------------------------------------------------+ +bool tusbh_cdc_acm_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; +bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; +bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; + +tusb_interface_status_t tusbh_cdc_send(void const * p_data, uint32_t length); //--------------------------------------------------------------------+ // USBH-CLASS API diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 0a15f9355..cbac11c99 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -519,19 +519,24 @@ void async_list_process_isr(ehci_qhd_t * const async_head) { // TD need to be freed and removed from qhd, before invoking callback bool is_ioc = (p_qhd->p_qtd_list_head->int_on_complete != 0); + uint16_t actual_bytes_xferred = p_qhd->p_qtd_list_head->expected_bytes - p_qhd->p_qtd_list_head->total_bytes; p_qhd->p_qtd_list_head->used = 0; // free QTD qtd_remove_1st_from_qhd(p_qhd); if (is_ioc) // end of request { - pipe_handle_t pipe_hdl = { .dev_addr = p_qhd->device_address }; + pipe_handle_t pipe_hdl = { + .dev_addr = p_qhd->device_address, + .xfer_type = TUSB_XFER_CONTROL + }; + if (p_qhd->endpoint_number) // if not Control, can only be Bulk { pipe_hdl.xfer_type = TUSB_XFER_BULK; pipe_hdl.index = qhd_get_index(p_qhd); } - usbh_isr( pipe_hdl, p_qhd->class_code, TUSB_EVENT_XFER_COMPLETE); // call USBH callback + usbh_xfer_isr( pipe_hdl, p_qhd->class_code, TUSB_EVENT_XFER_COMPLETE); // call USBH callback } } @@ -572,7 +577,7 @@ void period_list_process_isr(uint8_t hostid, uint8_t interval_ms) if (is_ioc) // end of request { - usbh_isr( (pipe_handle_t) + usbh_xfer_isr( (pipe_handle_t) { .dev_addr = p_qhd_int->device_address, .xfer_type = TUSB_XFER_INTERRUPT, @@ -617,13 +622,17 @@ void xfer_error_isr(uint8_t hostid) p_qhd->p_qtd_list_head->used = 0; // free QTD qtd_remove_1st_from_qhd(p_qhd); - pipe_handle_t pipe_hdl = { .dev_addr = p_qhd->device_address }; + pipe_handle_t pipe_hdl = { + .dev_addr = p_qhd->device_address, + .xfer_type = TUSB_XFER_CONTROL + }; + if (p_qhd->endpoint_number) // if not Control, can only be Bulk { pipe_hdl.xfer_type = TUSB_XFER_BULK; - pipe_hdl.index = qhd_get_index(p_qhd); + pipe_hdl.index = qhd_get_index(p_qhd); } - usbh_isr( pipe_hdl, p_qhd->class_code, TUSB_EVENT_XFER_ERROR); // call USBH callback + usbh_xfer_isr( pipe_hdl, p_qhd->class_code, TUSB_EVENT_XFER_ERROR); // call USBH callback } p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h index 79526079f..ab2571df9 100644 --- a/tinyusb/host/ehci/ehci.h +++ b/tinyusb/host/ehci/ehci.h @@ -128,6 +128,8 @@ typedef struct { struct { uint32_t : 5; uint32_t used : 1; + uint32_t : 10; + uint32_t expected_bytes : 16; }; }; diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 628cf637a..e4c20883b 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -236,7 +236,7 @@ tusb_interface_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) // USBH-HCD ISR/Callback API //--------------------------------------------------------------------+ // interrupt caused by a TD (with IOC=1) in pipe of class class_code -void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event) +void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event) { uint8_t class_index = std_class_code_to_index(class_code); if (class_index == 0) // Control transfer diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index fbb7379a7..c8b0a9f4a 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -113,7 +113,7 @@ extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; // including //--------------------------------------------------------------------+ // callback from HCD ISR //--------------------------------------------------------------------+ -void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event); +void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event); void usbh_device_plugged_isr(uint8_t hostid); void usbh_device_unplugged_isr(uint8_t hostid);