From 97a4a41b8266a345624b77b20daba93c0b8949d5 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 6 Mar 2013 11:24:20 +0700 Subject: [PATCH] refractor - remove unnecessary assign next pointer of asyn/period head in hcd_controller_init --- tests/test/host/ehci/test_ehci_init.c | 4 --- tests/test/host/ehci/test_ehci_pipe.c | 2 ++ tinyusb/host/ehci/ehci.c | 40 ++++++++++++--------------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/tests/test/host/ehci/test_ehci_init.c b/tests/test/host/ehci/test_ehci_init.c index 146c75b8..546853d4 100644 --- a/tests/test/host/ehci/test_ehci_init.c +++ b/tests/test/host/ehci/test_ehci_init.c @@ -122,8 +122,6 @@ void test_hcd_init_async_list(void) TEST_ASSERT_FALSE(async_head->next.terminate); TEST_ASSERT(async_head->head_list_flag); - TEST_ASSERT(async_head->qtd_overlay.next.terminate); - TEST_ASSERT(async_head->qtd_overlay.alternate.terminate); TEST_ASSERT(async_head->qtd_overlay.halted); } } @@ -150,8 +148,6 @@ void test_hcd_init_period_list(void) TEST_ASSERT(period_head->smask) TEST_ASSERT_TRUE(period_head->next.terminate); - TEST_ASSERT(period_head->qtd_overlay.next.terminate); - TEST_ASSERT(period_head->qtd_overlay.alternate.terminate); TEST_ASSERT(period_head->qtd_overlay.halted); } #endif diff --git a/tests/test/host/ehci/test_ehci_pipe.c b/tests/test/host/ehci/test_ehci_pipe.c index 42694d45..0625cffd 100644 --- a/tests/test/host/ehci/test_ehci_pipe.c +++ b/tests/test/host/ehci/test_ehci_pipe.c @@ -114,6 +114,8 @@ void verify_open_qhd(ehci_qhd_t *p_qhd) TEST_ASSERT_EQUAL(hub_addr, p_qhd->hub_address); TEST_ASSERT_EQUAL(hub_port, p_qhd->hub_port); TEST_ASSERT_EQUAL(1, p_qhd->mult); + + TEST_ASSERT_FALSE(p_qhd->qtd_overlay.halted); TEST_ASSERT(p_qhd->qtd_overlay.next.terminate); TEST_ASSERT(p_qhd->qtd_overlay.alternate.terminate); diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 2e2b950e..c5051104 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -158,13 +158,10 @@ tusb_error_t hcd_controller_init(uint8_t hostid) ehci_qhd_t * const async_head = get_async_head(hostid); memclr_(async_head, sizeof(ehci_qhd_t)); - async_head->next.address = align32( (uint32_t) async_head); // circular list, next is itself + async_head->next.address = (uint32_t) async_head; // circular list, next is itself async_head->next.type = EHCI_QUEUE_ELEMENT_QHD; async_head->head_list_flag = 1; - - async_head->qtd_overlay.next.terminate = 1; - async_head->qtd_overlay.alternate.terminate = 1; - async_head->qtd_overlay.halted = 1; + async_head->qtd_overlay.halted = 1; // inactive most of time regs->async_list_base = (uint32_t) async_head; @@ -182,9 +179,7 @@ tusb_error_t hcd_controller_init(uint8_t hostid) period_head->smask = 1; // queue head in period list must have smask non-zero period_head->next.terminate = 1; - period_head->qtd_overlay.next.terminate = 1; - period_head->qtd_overlay.alternate.terminate = 1; - period_head->qtd_overlay.halted = 1; + period_head->qtd_overlay.halted = 1; // dummy node, always inactive regs->periodic_list_base = (uint32_t) framelist; #else @@ -349,23 +344,24 @@ static inline ehci_qtd_t* get_control_qtds(uint8_t dev_addr) static void queue_head_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_size, uint8_t endpoint_addr, uint8_t xfer_type) { - p_qhd->device_address = dev_addr; - p_qhd->inactive_next_xact = 0; - p_qhd->endpoint_number = endpoint_addr & 0x0F; - p_qhd->endpoint_speed = usbh_device_info_pool[dev_addr].speed; - p_qhd->data_toggle_control = (xfer_type == TUSB_XFER_CONTROL) ? 1 : 0; - p_qhd->head_list_flag = (dev_addr == 0) ? 1 : 0; // addr0's endpoint is the static asyn list head - p_qhd->max_package_size = max_packet_size; + p_qhd->device_address = dev_addr; + p_qhd->inactive_next_xact = 0; + p_qhd->endpoint_number = endpoint_addr & 0x0F; + p_qhd->endpoint_speed = usbh_device_info_pool[dev_addr].speed; + p_qhd->data_toggle_control = (xfer_type == TUSB_XFER_CONTROL) ? 1 : 0; + p_qhd->head_list_flag = (dev_addr == 0) ? 1 : 0; // addr0's endpoint is the static asyn list head + p_qhd->max_package_size = max_packet_size; p_qhd->non_hs_control_endpoint = ((TUSB_XFER_CONTROL == xfer_type) && (usbh_device_info_pool[dev_addr].speed != TUSB_SPEED_HIGH) ) ? 1 : 0; - p_qhd->nak_count_reload = 0; + p_qhd->nak_count_reload = 0; - p_qhd->smask = 0; - p_qhd->cmask = 0; - p_qhd->hub_address = usbh_device_info_pool[dev_addr].hub_addr; - p_qhd->hub_port = usbh_device_info_pool[dev_addr].hub_port; - p_qhd->mult = 1; // TODO not use high bandwidth/park mode yet + p_qhd->smask = 0; + p_qhd->cmask = 0; + p_qhd->hub_address = usbh_device_info_pool[dev_addr].hub_addr; + p_qhd->hub_port = usbh_device_info_pool[dev_addr].hub_port; + p_qhd->mult = 1; // TODO not use high bandwidth/park mode yet - //------------- inactive when just opened -------------// + //------------- active, but no TD list -------------// + p_qhd->qtd_overlay.halted = 0; p_qhd->qtd_overlay.next.terminate = 1; p_qhd->qtd_overlay.alternate.terminate = 1;