From 644f0d39329e634c7a3191dd657c866458dd793b Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 7 Mar 2013 17:59:07 +0700 Subject: [PATCH] make "used" member of ehci_qtd_t into reserved place of buffer[1] (with assert check in hcd init) --- tests/test/host/ehci/test_ehci_pipe_xfer.c | 3 +-- tests/test/host/ehci/test_ehci_structure.c | 1 + tinyusb/common/errors.h | 1 + tinyusb/host/ehci/ehci.c | 16 ++++++++++++++- tinyusb/host/ehci/ehci.h | 24 ++++++++++------------ tinyusb/host/hcd.h | 2 +- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/tests/test/host/ehci/test_ehci_pipe_xfer.c b/tests/test/host/ehci/test_ehci_pipe_xfer.c index 06098620..0673a3de 100644 --- a/tests/test/host/ehci/test_ehci_pipe_xfer.c +++ b/tests/test/host/ehci/test_ehci_pipe_xfer.c @@ -98,6 +98,7 @@ void setUp(void) usbh_device_info_pool[i].core_id = hostid; usbh_device_info_pool[i].hub_addr = hub_addr; usbh_device_info_pool[i].hub_port = hub_port; + usbh_device_info_pool[i].speed = TUSB_SPEED_HIGH; } async_head = get_async_head( hostid ); @@ -228,5 +229,3 @@ void test_control_xfer_set(void) TEST_ASSERT_TRUE(p_status->data_toggle); TEST_ASSERT_EQUAL(EHCI_PID_IN, p_status->pid); } - - diff --git a/tests/test/host/ehci/test_ehci_structure.c b/tests/test/host/ehci/test_ehci_structure.c index d7c54e85..0dbf2ff9 100644 --- a/tests/test/host/ehci/test_ehci_structure.c +++ b/tests/test/host/ehci/test_ehci_structure.c @@ -134,6 +134,7 @@ void test_qtd_structure(void) TEST_ASSERT_EQUAL( 31, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, data_toggle) ); TEST_ASSERT_EQUAL( 12, offsetof(ehci_qtd_t, buffer)); + TEST_ASSERT_EQUAL( 16, offsetof(ehci_qtd_t, used)); } void test_qhd_structure(void) diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index 939f6c43..81bb5cce 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -72,6 +72,7 @@ ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\ ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\ ENTRY(TUSB_ERROR_OSAL_SEMAPHORE_FAILED)\ + ENTRY(TUSB_ERROR_EHCI_NOT_ENOUGH_QTD)\ ENTRY(TUSB_ERROR_FAILED)\ diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index f654eb3b..8d15d251 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -117,6 +117,9 @@ tusb_error_t hcd_controller_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT; //--------------------------------------------------------------------+ tusb_error_t hcd_init(void) { + // oops, ehci_qtd_t:used must be at Reserved places in EHCI specs + ASSERT(offsetof(ehci_qtd_t, used) == 16, TUSB_ERROR_HCD_FAILED); // TODO can be removed after an THOROUGH checked + //------------- Data Structure init -------------// memclr_(&ehci_data, sizeof(ehci_data_t)); @@ -365,7 +368,6 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * { index++; } - ASSERT( index < EHCI_MAX_QHD, null_handle); ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].qhd[index]; @@ -390,6 +392,18 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * return (pipe_handle_t) { .dev_addr = dev_addr, .xfer_type = p_endpoint_desc->bmAttributes.xfer, .index = index}; } +tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_byte) +{ + //------------- find a free qtd -------------// +// uint8_t index=0; +// while( index cannot be declared with ATTR_ALIGNED(32) /// Queue Head (section 3.6) typedef struct { diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index f918ca33..14b8941f 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -80,7 +80,7 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc) ATTR_WARN_UNUSED_RESULT; -tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[]) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_byte) ATTR_WARN_UNUSED_RESULT; tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT; #if 0