diff options
| author | hathach <[email protected]> | 2013-03-07 17:59:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-03-07 17:59:07 +0700 |
| commit | 644f0d39329e634c7a3191dd657c866458dd793b (patch) | |
| tree | 150a320f2e28ad6dfa6e499a101a0734a883843e | |
| parent | 1b610cf26f98344af0ef4752709aced467d03e7a (diff) | |
make "used" member of ehci_qtd_t into reserved place of buffer[1] (with assert check in hcd init)
| -rw-r--r-- | tests/test/host/ehci/test_ehci_pipe_xfer.c | 3 | ||||
| -rw-r--r-- | tests/test/host/ehci/test_ehci_structure.c | 1 | ||||
| -rw-r--r-- | tinyusb/common/errors.h | 1 | ||||
| -rw-r--r-- | tinyusb/host/ehci/ehci.c | 16 | ||||
| -rw-r--r-- | tinyusb/host/ehci/ehci.h | 24 | ||||
| -rw-r--r-- | 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 06098620d..0673a3de1 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 d7c54e852..0dbf2ff98 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 939f6c433..81bb5cce6 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 f654eb3b5..8d15d2516 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<EHCI_MAX_QTD && ehci_data.device[dev_addr].qtd[index].used ) +// { +// index++; +// } +// ASSERT( index < EHCI_MAX_QHD, TUSB_ERROR_EHCI_NOT_ENOUGH_QTD); + + return TUSB_ERROR_NONE; +} //--------------------------------------------------------------------+ // HELPER //--------------------------------------------------------------------+ diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h index ca123605c..c77ebdc37 100644 --- a/tinyusb/host/ehci/ehci.h +++ b/tinyusb/host/ehci/ehci.h @@ -124,17 +124,7 @@ typedef struct { ehci_link_t next; /// Word 1: Alternate Next QTD Pointer (not used) - /// Used to store management information - union{ - ehci_link_t alternate; ///< Alternate Next QTD Pointer (not used) - struct { - uint32_t : 5; ///< reserved this for alternate - - // HCD information - uint32_t used : 1; ///< indicate this qTD is occupied - uint32_t : 0; // padding to the end of current storage unit - }; - }; + ehci_link_t alternate; /// Word 2: qTQ Token volatile uint32_t pingstate_err : 1 ; ///< If the QH.EPSfield indicates a High-speed device and the PID_Codeindicates an OUT endpoint, then this is the state bit for the Ping protocol. 0b=OUT 1b=PING @@ -157,8 +147,16 @@ typedef struct { // End of Word 2 /// Buffer Page Pointer List, Each element in the list is a 4K page aligned, physical memory address. The lower 12 bits in each pointer are reserved (except for the first one) as each memory pointer must reference the start of a 4K page - uint32_t buffer[5]; -} ehci_qtd_t; // XXX qtd is used to declare overlay in ehci_qhd_t, we cannot put ATTR_ALIGNED(32) here + union { + uint32_t buffer[5]; + struct { + uint32_t reserve_1; + uint8_t used; // used is the LSB of buffer[1] + uint8_t reserved_2[3]; + uint32_t reserved_3[3]; + }; + }; +} ehci_qtd_t; // XXX qtd is used to declare overlay in ehci_qhd_t -> 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 f918ca33a..14b8941fa 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 |
