From ee9d53477ae74dd9730d1fbca1a0fad69027479b Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 21 Apr 2013 16:24:42 +0700 Subject: [PATCH] complete the support for correct polling of 1ms 2ms 4ms 8ms --- tests/test/host/ehci/test_pipe_interrupt_open.c | 4 ++-- tinyusb/host/ehci/ehci.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/test/host/ehci/test_pipe_interrupt_open.c b/tests/test/host/ehci/test_pipe_interrupt_open.c index 020b8d034..564733990 100644 --- a/tests/test/host/ehci/test_pipe_interrupt_open.c +++ b/tests/test/host/ehci/test_pipe_interrupt_open.c @@ -269,9 +269,9 @@ void test_open_interrupt_hs_interval_8(void) pipe_hdl = hcd_pipe_open(dev_addr, &int_edp_interval, TUSB_CLASS_HID); p_int_qhd = &ehci_data.device[ pipe_hdl.dev_addr-1].qhd[ pipe_hdl.index ]; - TEST_ASSERT_EQUAL(16, p_int_qhd->interval_ms); + TEST_ASSERT_EQUAL(255, p_int_qhd->interval_ms); TEST_ASSERT_EQUAL(1, count_set_bits(p_int_qhd->interrupt_smask) ); - check_int_endpoint_link( get_period_head(hostid, 16), p_int_qhd); + check_int_endpoint_link( get_period_head(hostid, 255), p_int_qhd); check_int_endpoint_link( get_period_head(hostid, 8) , p_int_qhd); } diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 8557ccd94..2f61afe78 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -524,13 +524,15 @@ void async_list_process_isr(ehci_qhd_t * const async_head) // TODO abstract max loop guard for async } -void period_list_process_isr(ehci_qhd_t const * const period_head) +void period_list_process_isr(uint8_t hostid, uint8_t interval_ms) { uint8_t max_loop = 0; - ehci_link_t next_item = period_head->next; + ehci_link_t next_item = * get_period_head(hostid, interval_ms); // TODO abstract max loop guard for period - while( !next_item.terminate && max_loop < (EHCI_MAX_QHD + EHCI_MAX_ITD + EHCI_MAX_SITD)) + while( !next_item.terminate && + !(interval_ms > 1 && align32(next_item.address) == get_period_head(hostid, 1)) && + max_loop < (EHCI_MAX_QHD + EHCI_MAX_ITD + EHCI_MAX_SITD)) { switch ( next_item.type ) { @@ -641,12 +643,15 @@ void hcd_isr(uint8_t hostid) //------------- some QTD/SITD/ITD with IOC set is completed -------------// if (int_status & EHCI_INT_MASK_NXP_ASYNC) { - async_list_process_isr(get_async_head(hostid)); + async_list_process_isr( get_async_head(hostid) ); } if (int_status & EHCI_INT_MASK_NXP_PERIODIC) { - period_list_process_isr( get_period_head(hostid, 1) ); + for (uint8_t i=1; i <= EHCI_FRAMELIST_SIZE; i *= 2) + { + period_list_process_isr( hostid, i ); + } } //------------- There is some removed async previously -------------//