diff options
| author | hathach <[email protected]> | 2013-07-02 12:01:51 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-07-02 12:01:51 +0700 |
| commit | 9fea5291bfa272212d74bac0fee67d6db6272296 (patch) | |
| tree | f66b0ce4ed8c1e60fa461f761586e60b4340ced4 /tests | |
| parent | 958d390a852160f040508775202e827766fc0498 (diff) | |
refractor extract list_next
add support for TUSB_EVENT_XFER_STALL
add test for error/stall in periodic list
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c | 10 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c | 21 | ||||
| -rw-r--r-- | tests/support/ehci_controller_fake.c | 53 |
3 files changed, 74 insertions, 10 deletions
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 bb1ca6692..7ed632ad2 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 @@ -250,3 +250,13 @@ void test_control_xfer_error_isr(void) //------------- Code Under TEST -------------// ehci_controller_run_error(hostid); } + +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); + + //------------- 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 d367292a8..a53db9578 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 @@ -234,3 +234,24 @@ void test_interrupt_xfer_complete_isr_interval_2ms(void) TEST_ASSERT_FALSE(p_tail->used); } + +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_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_ERROR); + + //------------- Code Under TEST -------------// + ehci_controller_run_error(hostid); +} + +//void test_interrupt_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); +// +// //------------- 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 d3659e834..d22f8cd09 100644 --- a/tests/support/ehci_controller_fake.c +++ b/tests/support/ehci_controller_fake.c @@ -144,7 +144,23 @@ void ehci_controller_run(uint8_t hostid) hcd_isr(hostid); } -void ehci_controller_run_error(uint8_t hostid) +void complete_1st_qtd_with_error(ehci_qhd_t* p_qhd, bool halted, bool xact_err) +{ + if ( !p_qhd->qtd_overlay.halted ) + { + if(!p_qhd->qtd_overlay.next.terminate) // TODO add active check + { + ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address); + p_qtd->active = 0; + p_qtd->halted = halted ? 1 : 0; + p_qtd->xact_err = xact_err ? 1 : 0; + + p_qhd->qtd_overlay = *p_qtd; + } + } +} + +void complete_list_with_error(uint8_t hostid, bool halted, bool xact_err) { //------------- Async List -------------// ehci_registers_t* const regs = get_operational_register(hostid); @@ -152,25 +168,42 @@ void ehci_controller_run_error(uint8_t hostid) ehci_qhd_t *p_qhd = (ehci_qhd_t*) regs->async_list_base; do { - if ( !p_qhd->qtd_overlay.halted ) + complete_1st_qtd_with_error(p_qhd, halted, xact_err); + p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); + }while(p_qhd != get_async_head(hostid)); // stop if loop around + + //------------- Period List -------------// + for(uint8_t i=1; i <= EHCI_FRAMELIST_SIZE; i *= 2) + { + ehci_link_t *head = get_period_head(hostid, i); + + while(!head->terminate) { - if(!p_qhd->qtd_overlay.next.terminate) + uint32_t queue_type = head->type; + head = (ehci_link_t*) align32(head->address); + + if ( queue_type == EHCI_QUEUE_ELEMENT_QHD) { - ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address); - p_qtd->active = 0; - p_qtd->babble_err = p_qtd->buffer_err = p_qtd->xact_err = 1; - p_qhd->qtd_overlay = *p_qtd; + complete_1st_qtd_with_error((ehci_qhd_t*) head, halted, xact_err); } } - p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); - }while(p_qhd != get_async_head(hostid)); // stop if loop around - //------------- Period List -------------// + } regs->usb_sts = EHCI_INT_MASK_ERROR; hcd_isr(hostid); } +void ehci_controller_run_stall(uint8_t hostid) +{ + complete_list_with_error(hostid, true, false); +} + +void ehci_controller_run_error(uint8_t hostid) +{ + complete_list_with_error(hostid, true, true); +} + void ehci_controller_device_plug(uint8_t hostid, tusb_speed_t speed) { ehci_registers_t* const regs = get_operational_register(hostid); |
