From a259be6edf5bb0f8c4e77f3b321a826d8e86bd25 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 4 Mar 2013 18:01:05 +0700 Subject: refractor - remove TUSB_CFG_HOST_CONTROLLER_START_INDEX --- tinyusb/host/ehci/ehci.c | 28 ++++++++++++++++++++-------- tinyusb/tusb_option.h | 4 ---- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'tinyusb') diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index c3fda3f3d..27562974f 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -84,16 +84,27 @@ STATIC_ INLINE_ ehci_link_t* const get_period_frame_list(uint8_t list_idx) #endif } +STATIC_ INLINE_ uint8_t hostid_to_data_idx(uint8_t hostid) ATTR_ALWAYS_INLINE ATTR_CONST ATTR_WARN_UNUSED_RESULT; +STATIC_ INLINE_ uint8_t hostid_to_data_idx(uint8_t hostid) +{ + #if (CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST) + (void) hostid; + return 0; + #else + return hostid; + #endif +} + STATIC_ INLINE_ ehci_qhd_t* const get_async_head(uint8_t hostid) ATTR_ALWAYS_INLINE ATTR_PURE ATTR_WARN_UNUSED_RESULT; STATIC_ INLINE_ ehci_qhd_t* const get_async_head(uint8_t hostid) { - return &ehci_data.controller.async_head[hostid-TUSB_CFG_HOST_CONTROLLER_START_INDEX]; + return &ehci_data.controller.async_head[hostid_to_data_idx(hostid)]; } STATIC_ INLINE_ ehci_qhd_t* const get_period_head(uint8_t hostid) ATTR_ALWAYS_INLINE ATTR_PURE ATTR_WARN_UNUSED_RESULT; STATIC_ INLINE_ ehci_qhd_t* const get_period_head(uint8_t hostid) { - return &ehci_data.controller.period_head[hostid-TUSB_CFG_HOST_CONTROLLER_START_INDEX]; + return &ehci_data.controller.period_head[hostid_to_data_idx(hostid)]; } tusb_error_t hcd_controller_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT; @@ -103,15 +114,16 @@ tusb_error_t hcd_controller_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT; //--------------------------------------------------------------------+ tusb_error_t hcd_init(void) { - uint8_t i = 0; - //------------- Data Structure init -------------// memclr_(&ehci_data, sizeof(ehci_data_t)); - for(i=0; i