summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-07-02 17:37:55 +0700
committerhathach <[email protected]>2013-07-02 17:37:55 +0700
commit539c7cdbe16d7805eac053a6779f509a4c9b4c68 (patch)
treec6dd166cb24c60c17dbe33ee78c25a0811300465
parente1ad7b62cf453735b3f8b9d97abe2b3e6579a099 (diff)
update usbh_xfer_isr to take actual byte transferred and correct tests
-rw-r--r--tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c2
-rw-r--r--tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c6
-rw-r--r--tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c6
-rw-r--r--tests/support/ehci_controller_fake.c1
-rw-r--r--tinyusb/host/ehci/ehci.c6
-rw-r--r--tinyusb/host/usbh.c2
-rw-r--r--tinyusb/host/usbh_hcd.h2
7 files changed, 14 insertions, 11 deletions
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 d792d358d..6a30e64f8 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
@@ -209,7 +209,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_xfer_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, sizeof(data2));
//------------- 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 7ed632ad2..4b760fe0e 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_xfer_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, 0);
//------------- 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_xfer_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, 0);
//------------- Code Under TEST -------------//
ehci_controller_run_error(hostid);
@@ -255,7 +255,7 @@ void test_control_xfer_error_stall(void)
{
TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) );
- usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_STALLED);
+ usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_STALLED, 0);
//------------- Code Under TEST -------------//
ehci_controller_run_stall(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 1cb6ae8af..8222a3d86 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
@@ -201,7 +201,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_xfer_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, sizeof(data2));
ehci_qtd_t* p_head = p_qhd_interrupt->p_qtd_list_head;
ehci_qtd_t* p_tail = p_qhd_interrupt->p_qtd_list_tail;
@@ -240,7 +240,7 @@ void test_interrupt_xfer_error_isr(void)
{
TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), true) );
- usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_ERROR);
+ usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_ERROR, 0);
//------------- Code Under TEST -------------//
ehci_controller_run_error(hostid);
@@ -250,7 +250,7 @@ void test_interrupt_xfer_error_stall(void)
{
TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), true) );
- usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_STALLED);
+ usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_STALLED, 0);
//------------- Code Under TEST -------------//
ehci_controller_run_stall(hostid);
diff --git a/tests/support/ehci_controller_fake.c b/tests/support/ehci_controller_fake.c
index d22f8cd09..51f149591 100644
--- a/tests/support/ehci_controller_fake.c
+++ b/tests/support/ehci_controller_fake.c
@@ -95,6 +95,7 @@ void complete_qtd_in_qhd(ehci_qhd_t *p_qhd)
{
ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address);
p_qtd->active = 0;
+ p_qtd->total_bytes = 0;
p_qhd->qtd_overlay = *p_qtd;
}
}
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index c016a3a3c..c1ea9a7ed 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -529,7 +529,7 @@ void qhd_xfer_complete_isr(ehci_qhd_t * p_qhd, tusb_xfer_type_t xfer_type)
if (is_ioc) // end of request
{
usbh_xfer_isr( qhd_create_pipe_handle(p_qhd, xfer_type),
- p_qhd->class_code, TUSB_EVENT_XFER_COMPLETE); // call USBH callback
+ p_qhd->class_code, TUSB_EVENT_XFER_COMPLETE, actual_bytes_xferred); // call USBH callback
}
}
}
@@ -602,13 +602,15 @@ void qhd_xfer_error_isr(ehci_qhd_t * p_qhd, tusb_xfer_type_t xfer_type)
error_event = ( !(p_qhd->qtd_overlay.buffer_err || p_qhd->qtd_overlay.babble_err ||
p_qhd->qtd_overlay.xact_err) ) ? TUSB_EVENT_XFER_STALLED : TUSB_EVENT_XFER_ERROR;
+ uint16_t actual_bytes_xferred = p_qhd->p_qtd_list_head->expected_bytes - p_qhd->p_qtd_list_head->total_bytes;
+
hal_debugger_breakpoint();
p_qhd->p_qtd_list_head->used = 0; // free QTD
qtd_remove_1st_from_qhd(p_qhd);
usbh_xfer_isr( qhd_create_pipe_handle(p_qhd, xfer_type),
- p_qhd->class_code, error_event); // call USBH callback
+ p_qhd->class_code, error_event, actual_bytes_xferred); // call USBH callback
}
}
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index f5689b07c..794fd3be7 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_xfer_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, uint32_t xferred_bytes)
{
uint8_t class_index = std_class_code_to_index(class_code);
if (TUSB_XFER_CONTROL == pipe_hdl.xfer_type)
diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h
index c8b0a9f4a..cda043541 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_xfer_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, uint32_t xferred_bytes);
void usbh_device_plugged_isr(uint8_t hostid);
void usbh_device_unplugged_isr(uint8_t hostid);