diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index 2e9090db2..e71b817aa 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -80,7 +80,6 @@ static inline ehci_qhd_t* qhd_next(ehci_qhd_t const * p_qhd) ATTR_ALWAYS_INLI static inline ehci_qhd_t* qhd_find_free (uint8_t dev_addr) ATTR_PURE ATTR_ALWAYS_INLINE; static inline tusb_xfer_type_t qhd_get_xfer_type(ehci_qhd_t const * p_qhd) ATTR_ALWAYS_INLINE ATTR_PURE; static inline ehci_qhd_t* qhd_get_from_pipe_handle(uint8_t dev_addr, pipe_handle_t pipe_hdl); -static inline pipe_handle_t qhd_create_pipe_handle(ehci_qhd_t const * p_qhd); // determine if a queue head has bus-related error static inline bool qhd_has_xact_error(ehci_qhd_t * p_qhd) @@ -91,7 +90,6 @@ static inline bool qhd_has_xact_error(ehci_qhd_t * p_qhd) static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc); - static inline ehci_qtd_t* qtd_find_free(uint8_t dev_addr) ATTR_PURE ATTR_ALWAYS_INLINE; static inline ehci_qtd_t* qtd_next(ehci_qtd_t const * p_qtd ) ATTR_PURE ATTR_ALWAYS_INLINE; static inline void qtd_insert_to_qhd(ehci_qhd_t *p_qhd, ehci_qtd_t *p_qtd_new) ATTR_ALWAYS_INLINE; @@ -557,30 +555,30 @@ static void async_advance_isr(ehci_qhd_t * const async_head) _usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG; } - for(uint8_t relative_dev_addr=0; relative_dev_addr < CFG_TUSB_HOST_DEVICE_MAX; relative_dev_addr++) + for(uint8_t dev_addr=1; dev_addr < CFG_TUSB_HOST_DEVICE_MAX; dev_addr++) { // check if control endpoint is removing - ehci_qhd_t *p_control_qhd = &ehci_data.device[relative_dev_addr].control.qhd; + ehci_qhd_t *p_control_qhd = get_control_qhd(dev_addr); if ( p_control_qhd->is_removing ) { p_control_qhd->is_removing = 0; p_control_qhd->used = 0; // Host Controller has cleaned up its cached data for this device, set state to unplug - _usbh_devices[relative_dev_addr+1].state = TUSB_DEVICE_STATE_UNPLUG; + _usbh_devices[dev_addr+1].state = TUSB_DEVICE_STATE_UNPLUG; for (uint8_t i=0; ixfer_type) // qhd index for control is meaningless - { - pipe_hdl.index = qhd_get_index(p_qhd); - pipe_hdl.ep_addr = edpt_addr(p_qhd->endpoint_number, p_qhd->pid_non_control == EHCI_PID_IN ? 1 : 0); - } - - return pipe_hdl; -} - //------------- TD helper -------------// static inline ehci_qtd_t* qtd_find_free(uint8_t dev_addr) { diff --git a/src/host/ehci/ehci.h b/src/host/ehci/ehci.h index 4534c4cd3..fdb1936d3 100644 --- a/src/host/ehci/ehci.h +++ b/src/host/ehci/ehci.h @@ -456,17 +456,13 @@ typedef struct // [0] : 1ms, [1] : 2ms, [2] : 4ms, [3] : 8 ms ehci_qhd_t period_head_arr[4]; + // Note control qhd of dev0 is used as head of async list, always exists struct { - ehci_qhd_t qhd; // also used as head of async list (each for 1 controller), always exists - ehci_qtd_t qtd; - }dev0; - - struct { - struct { ehci_qhd_t qhd; ehci_qtd_t qtd; - }control; + }control[CFG_TUSB_HOST_DEVICE_MAX+1]; + struct { ehci_qhd_t qhd[HCD_MAX_ENDPOINT] ; ///< Queue Head Pool ehci_qtd_t qtd[HCD_MAX_XFER] ATTR_ALIGNED(32) ; ///< Queue Element Transfer Pool // ehci_itd_t itd[EHCI_MAX_ITD] ; ///< Iso Transfer Pool diff --git a/src/host/hcd.h b/src/host/hcd.h index 6d86ae9e5..0f83838e9 100644 --- a/src/host/hcd.h +++ b/src/host/hcd.h @@ -87,15 +87,17 @@ enum { HCD_MAX_XFER = HCD_MAX_ENDPOINT*2, }; + +//#define HCD_MAX_ENDPOINT 16 +//#define HCD_MAX_XFER 16 #endif //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ typedef struct { - uint8_t ep_addr; uint8_t index; - uint8_t reserved[2]; + uint8_t reserved[3]; } pipe_handle_t; static inline bool pipehandle_is_valid(pipe_handle_t pipe_hdl) diff --git a/src/host/usbh.c b/src/host/usbh.c index 2c2286698..1c698cb35 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -273,7 +273,7 @@ void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t ev } else { - TU_ASSERT(false, ); // something wrong, no one claims the isr's source + TU_BREAKPOINT(); // something wrong, no one claims the isr's source } } }