refractor extract list_next

add support for TUSB_EVENT_XFER_STALL
add test for error/stall in periodic list
This commit is contained in:
hathach
2013-07-02 12:01:51 +07:00
parent 958d390a85
commit 9fea5291bf
4 changed files with 94 additions and 26 deletions
@@ -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);
}
@@ -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);
//}
+44 -11
View File
@@ -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 )
{
if(!p_qhd->qtd_overlay.next.terminate)
{
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(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)
{
uint32_t queue_type = head->type;
head = (ehci_link_t*) align32(head->address);
if ( queue_type == EHCI_QUEUE_ELEMENT_QHD)
{
complete_1st_qtd_with_error((ehci_qhd_t*) head, halted, xact_err);
}
}
}
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);