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 /tinyusb | |
| parent | 1b610cf26f98344af0ef4752709aced467d03e7a (diff) | |
make "used" member of ehci_qtd_t into reserved place of buffer[1] (with assert check in hcd init)
Diffstat (limited to 'tinyusb')
| -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 |
4 files changed, 28 insertions, 15 deletions
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 |
