mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-23 13:20:54 +00:00
refractor
- remove TUSB_CFG_HOST_CONTROLLER_START_INDEX
This commit is contained in:
parent
e1033b9b3c
commit
a259be6edf
@ -58,16 +58,12 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROLLER CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST)
|
||||
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_NONE)
|
||||
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_HOST)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// HOST CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//------------- CONTROLLER -------------//
|
||||
#define TUSB_CFG_HOST_CONTROLLER_START_INDEX 0
|
||||
|
||||
#define TUSB_CFG_HOST_DEVICE_MAX 1
|
||||
#define TUSB_CFG_CONFIGURATION_MAX 1
|
||||
|
||||
|
@ -83,7 +83,7 @@ void test_hcd_init_usbint(void)
|
||||
|
||||
for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
ehci_registers_t* const regs = get_operational_register(i+TUSB_CFG_HOST_CONTROLLER_START_INDEX);
|
||||
ehci_registers_t* const regs = get_operational_register(i+CONTROLLER_HOST_START_INDEX);
|
||||
|
||||
//------------- USB INT Enable-------------//
|
||||
TEST_ASSERT(regs->usb_int_enable_bit.usb_error);
|
||||
@ -107,7 +107,7 @@ void test_hcd_init_async_list(void)
|
||||
|
||||
for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
uint8_t hostid = i+TUSB_CFG_HOST_CONTROLLER_START_INDEX;
|
||||
uint8_t hostid = i+CONTROLLER_HOST_START_INDEX;
|
||||
|
||||
ehci_registers_t * const regs = get_operational_register(hostid);
|
||||
ehci_qhd_t * const async_head = get_async_head(hostid);
|
||||
@ -132,7 +132,7 @@ void test_hcd_init_period_list(void)
|
||||
|
||||
for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
uint8_t const hostid = i+TUSB_CFG_HOST_CONTROLLER_START_INDEX;
|
||||
uint8_t const hostid = i+CONTROLLER_HOST_START_INDEX;
|
||||
ehci_registers_t* const regs = get_operational_register(hostid);
|
||||
ehci_qhd_t * const period_head = get_period_head(hostid);
|
||||
ehci_link_t * const framelist = get_period_frame_list(hostid);
|
||||
@ -160,7 +160,7 @@ void test_hcd_init_tt_control(void)
|
||||
|
||||
for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
uint8_t const hostid = i+TUSB_CFG_HOST_CONTROLLER_START_INDEX;
|
||||
uint8_t const hostid = i+CONTROLLER_HOST_START_INDEX;
|
||||
ehci_registers_t* const regs = get_operational_register(hostid);
|
||||
|
||||
TEST_ASSERT_EQUAL(0, regs->tt_control);
|
||||
@ -173,7 +173,7 @@ void test_hcd_init_usbcmd(void)
|
||||
|
||||
for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
uint8_t const hostid = i+TUSB_CFG_HOST_CONTROLLER_START_INDEX;
|
||||
uint8_t const hostid = i+CONTROLLER_HOST_START_INDEX;
|
||||
ehci_registers_t* const regs = get_operational_register(hostid);
|
||||
|
||||
TEST_ASSERT(regs->usb_cmd_bit.async_enable);
|
||||
|
@ -305,7 +305,7 @@ void test_ehci_data(void)
|
||||
{
|
||||
for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
uint8_t hostid = i+TUSB_CFG_HOST_CONTROLLER_START_INDEX;
|
||||
uint8_t hostid = i+CONTROLLER_HOST_START_INDEX;
|
||||
TEST_ASSERT_BITS_LOW(4096-1, (uint32_t)get_period_frame_list(hostid) );
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,6 @@
|
||||
// HOST CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
//------------- CORE -------------//
|
||||
#define TUSB_CFG_HOST_CONTROLLER_START_INDEX 0
|
||||
|
||||
#define TUSB_CFG_HOST_DEVICE_MAX 2
|
||||
#define TUSB_CFG_CONFIGURATION_MAX 2
|
||||
|
||||
@ -79,6 +77,8 @@
|
||||
#define HOST_HCD_XFER_BULK
|
||||
#define HOST_HCD_XFER_ISOCHRONOUS
|
||||
|
||||
// Test support
|
||||
#define CONTROLLER_HOST_START_INDEX ( ((CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)) ? 1 : 0)
|
||||
//--------------------------------------------------------------------+
|
||||
// DEVICE CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -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<CONTROLLER_HOST_NUMBER; i++)
|
||||
{
|
||||
ASSERT_STATUS (hcd_controller_init(TUSB_CFG_HOST_CONTROLLER_START_INDEX + i));
|
||||
}
|
||||
#if (TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST)
|
||||
ASSERT_STATUS (hcd_controller_init(0));
|
||||
#endif
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)
|
||||
ASSERT_STATUS (hcd_controller_init(1));
|
||||
#endif
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
@ -117,10 +117,6 @@
|
||||
// HOST OPTIONS
|
||||
//--------------------------------------------------------------------+
|
||||
#if MODE_HOST_SUPPORTED
|
||||
#ifndef TUSB_CFG_HOST_CONTROLLER_START_INDEX
|
||||
#error TUSB_CFG_HOST_CONTROLLER_START_INDEX is not defined
|
||||
#endif
|
||||
|
||||
#ifndef TUSB_CFG_HOST_DEVICE_MAX
|
||||
#define TUSB_CFG_HOST_DEVICE_MAX 1
|
||||
#warning TUSB_CFG_HOST_DEVICE_MAX is not defined, default value is 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user