diff --git a/tests/test/host/ehci/test_ehci_init.c b/tests/test/host/ehci/test_ehci_init.c index 487df4678..99ade4e95 100644 --- a/tests/test/host/ehci/test_ehci_init.c +++ b/tests/test/host/ehci/test_ehci_init.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; //--------------------------------------------------------------------+ // Setup/Teardown + helper declare diff --git a/tests/test/host/ehci/test_ehci_isr.c b/tests/test/host/ehci/test_ehci_isr.c index af3fc0589..c25a2a8f3 100644 --- a/tests/test/host/ehci/test_ehci_isr.c +++ b/tests/test/host/ehci/test_ehci_isr.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t hostid; ehci_registers_t * regs; diff --git a/tests/test/host/ehci/test_ehci_structure.c b/tests/test/host/ehci/test_ehci_structure.c index 61634777e..744c8d53f 100644 --- a/tests/test/host/ehci/test_ehci_structure.c +++ b/tests/test/host/ehci/test_ehci_structure.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; //--------------------------------------------------------------------+ // Setup/Teardown + helper declare diff --git a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c index 3769844b6..da451d2d1 100644 --- a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c +++ b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c @@ -49,7 +49,7 @@ #include "ehci_controller.h" #define _TINY_USB_SOURCE_FILE_ -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t const control_max_packet_size = 64; uint8_t hub_addr; uint8_t hub_port; @@ -63,7 +63,7 @@ void setUp(void) { memclr_(&lpc_usb0, sizeof(LPC_USB0_Type)); memclr_(&lpc_usb1, sizeof(LPC_USB1_Type)); - memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); hub_addr = hub_port = 0; dev_addr = 1; @@ -74,11 +74,11 @@ void setUp(void) for (uint8_t i=0; iusb_sts_bit.async_advance = 1; hcd_isr(hostid); // async advance - TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_UNPLUG, usbh_device_info_pool[dev_addr].state); + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_UNPLUG, usbh_devices[dev_addr].state); } diff --git a/tests/test/host/ehci/test_pipe_bulk_open.c b/tests/test/host/ehci/test_pipe_bulk_open.c index fe2ba3bef..5fc08e30a 100644 --- a/tests/test/host/ehci/test_pipe_bulk_open.c +++ b/tests/test/host/ehci/test_pipe_bulk_open.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t const hub_addr = 2; uint8_t const hub_port = 2; @@ -61,7 +61,7 @@ ehci_qhd_t *async_head; //--------------------------------------------------------------------+ void setUp(void) { - memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); hcd_init(); @@ -70,10 +70,10 @@ void setUp(void) hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; for (uint8_t i=0; idevice_address); TEST_ASSERT_FALSE(p_qhd->non_hs_period_inactive_next_xact); TEST_ASSERT_EQUAL(endpoint_addr & 0x0F, p_qhd->endpoint_number); - TEST_ASSERT_EQUAL(usbh_device_info_pool[dev_addr].speed, p_qhd->endpoint_speed); + TEST_ASSERT_EQUAL(usbh_devices[dev_addr].speed, p_qhd->endpoint_speed); TEST_ASSERT_EQUAL(max_packet_size, p_qhd->max_package_size); TEST_ASSERT_EQUAL(0, p_qhd->nak_count_reload); // TDD NAK Reload disable diff --git a/tests/test/host/ehci/test_pipe_bulk_xfer.c b/tests/test/host/ehci/test_pipe_bulk_xfer.c index 98539c4a7..14d2b27a7 100644 --- a/tests/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/test/host/ehci/test_pipe_bulk_xfer.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t const control_max_packet_size = 64; uint8_t const hub_addr = 2; @@ -89,7 +89,7 @@ void setUp(void) memclr_(&lpc_usb0, sizeof(LPC_USB0_Type)); memclr_(&lpc_usb1, sizeof(LPC_USB1_Type)); - memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); memclr_(xfer_data, sizeof(xfer_data)); hcd_init(); @@ -99,10 +99,10 @@ void setUp(void) hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; for (uint8_t i=0; idevice_address); TEST_ASSERT_FALSE(p_qhd->non_hs_period_inactive_next_xact); TEST_ASSERT_EQUAL(endpoint_addr & 0x0F, p_qhd->endpoint_number); - TEST_ASSERT_EQUAL(usbh_device_info_pool[dev_addr].speed, p_qhd->endpoint_speed); + TEST_ASSERT_EQUAL(usbh_devices[dev_addr].speed, p_qhd->endpoint_speed); TEST_ASSERT_EQUAL(max_packet_size, p_qhd->max_package_size); TEST_ASSERT_EQUAL(0, p_qhd->nak_count_reload); // TDD NAK Reload disable @@ -150,7 +150,7 @@ void test_control_open_qhd_data(void) void test_control_open_highspeed(void) { - usbh_device_info_pool[dev_addr].speed = TUSB_SPEED_HIGH; + usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH; //------------- Code Under TEST -------------// hcd_pipe_control_open(dev_addr, control_max_packet_size); @@ -159,7 +159,7 @@ void test_control_open_highspeed(void) void test_control_open_non_highspeed(void) { - usbh_device_info_pool[dev_addr].speed = TUSB_SPEED_FULL; + usbh_devices[dev_addr].speed = TUSB_SPEED_FULL; //------------- Code Under TEST -------------// hcd_pipe_control_open(dev_addr, control_max_packet_size); diff --git a/tests/test/host/ehci/test_pipe_control_xfer.c b/tests/test/host/ehci/test_pipe_control_xfer.c index fd6f79ecc..700762ca2 100644 --- a/tests/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/test/host/ehci/test_pipe_control_xfer.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t const control_max_packet_size = 64; uint8_t const hub_addr = 2; @@ -71,7 +71,7 @@ void setUp(void) memclr_(&lpc_usb0, sizeof(LPC_USB0_Type)); memclr_(&lpc_usb1, sizeof(LPC_USB1_Type)); - memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); memclr_(xfer_data, sizeof(xfer_data)); hcd_init(); @@ -81,10 +81,10 @@ void setUp(void) hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; for (uint8_t i=0; idevice_address); TEST_ASSERT_FALSE(p_qhd->non_hs_period_inactive_next_xact); TEST_ASSERT_EQUAL(endpoint_addr & 0x0F, p_qhd->endpoint_number); - TEST_ASSERT_EQUAL(usbh_device_info_pool[dev_addr].speed, p_qhd->endpoint_speed); + TEST_ASSERT_EQUAL(usbh_devices[dev_addr].speed, p_qhd->endpoint_speed); TEST_ASSERT_EQUAL(max_packet_size, p_qhd->max_package_size); TEST_ASSERT_EQUAL(0, p_qhd->nak_count_reload); // TDD NAK Reload disable @@ -161,7 +161,7 @@ void test_open_interrupt_qhd_non_hs(void) ehci_qhd_t *p_qhd; pipe_handle_t pipe_hdl; - usbh_device_info_pool[dev_addr].speed = TUSB_SPEED_FULL; + usbh_devices[dev_addr].speed = TUSB_SPEED_FULL; //------------- Code Under TEST -------------// pipe_hdl = hcd_pipe_open(dev_addr, &desc_ept_interrupt_out, TUSB_CLASS_HID); diff --git a/tests/test/host/ehci/test_pipe_isochronous_open.c b/tests/test/host/ehci/test_pipe_isochronous_open.c index 60403750d..cb09e0ea8 100644 --- a/tests/test/host/ehci/test_pipe_isochronous_open.c +++ b/tests/test/host/ehci/test_pipe_isochronous_open.c @@ -47,7 +47,7 @@ #include "ehci.h" #include "ehci_controller.h" -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; uint8_t const hub_addr = 2; uint8_t const hub_port = 2; @@ -60,7 +60,7 @@ ehci_qhd_t *period_head; //--------------------------------------------------------------------+ void setUp(void) { - memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); hcd_init(); @@ -69,10 +69,10 @@ void setUp(void) hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX; for (uint8_t i=0; ip_qtd_list_head = p_control_qhd->p_qtd_list_tail = NULL; // Host Controller has cleaned up its cached data for this device, set state to unplug - usbh_device_info_pool[relative_dev_addr+1].state = TUSB_DEVICE_STATE_UNPLUG; + usbh_devices[relative_dev_addr+1].state = TUSB_DEVICE_STATE_UNPLUG; } // check if any other endpoints in pool is removing @@ -424,7 +424,7 @@ tusb_error_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size) { //------------- insert to async list -------------// // TODO might need to to disable async list first - list_insert( (ehci_link_t*) get_async_head(usbh_device_info_pool[dev_addr].core_id), + list_insert( (ehci_link_t*) get_async_head(usbh_devices[dev_addr].core_id), (ehci_link_t*) p_qhd, EHCI_QUEUE_ELEMENT_QHD); } @@ -481,7 +481,7 @@ tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) if (dev_addr != 0) { - ASSERT_STATUS( list_remove_qhd_from_async(get_async_head( usbh_device_info_pool[dev_addr].core_id ), p_qhd) ); + ASSERT_STATUS( list_remove_qhd_from_async(get_async_head( usbh_devices[dev_addr].core_id ), p_qhd) ); } return TUSB_ERROR_NONE; @@ -510,11 +510,11 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_BULK) { // TODO might need to to disable async list first - list_head = get_async_head(usbh_device_info_pool[dev_addr].core_id); + list_head = get_async_head(usbh_devices[dev_addr].core_id); }else if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_INTERRUPT) { // TODO might need to to disable period list first - list_head = get_period_head(usbh_device_info_pool[dev_addr].core_id); + list_head = get_period_head(usbh_devices[dev_addr].core_id); } //------------- insert to async/period list -------------// @@ -562,7 +562,7 @@ tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) if ( pipe_hdl.xfer_type == TUSB_XFER_BULK ) { ASSERT_STATUS( list_remove_qhd_from_async( - get_async_head( usbh_device_info_pool[pipe_hdl.dev_addr].core_id ), + get_async_head( usbh_devices[pipe_hdl.dev_addr].core_id ), p_qhd) ); }else { @@ -613,7 +613,7 @@ STATIC_ INLINE_ ehci_qhd_t* get_period_head(uint8_t hostid) STATIC_ INLINE_ ehci_qhd_t* get_control_qhd(uint8_t dev_addr) { return (dev_addr == 0) ? - get_async_head( usbh_device_info_pool[dev_addr].core_id ) : + get_async_head( usbh_devices[dev_addr].core_id ) : &ehci_data.device[dev_addr-1].control.qhd; } STATIC_ INLINE_ ehci_qtd_t* get_control_qtds(uint8_t dev_addr) @@ -693,18 +693,18 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si p_qhd->device_address = dev_addr; p_qhd->non_hs_period_inactive_next_xact = 0; p_qhd->endpoint_number = endpoint_addr & 0x0F; - p_qhd->endpoint_speed = usbh_device_info_pool[dev_addr].speed; + p_qhd->endpoint_speed = usbh_devices[dev_addr].speed; p_qhd->data_toggle_control = (xfer_type == TUSB_XFER_CONTROL) ? 1 : 0; p_qhd->head_list_flag = (dev_addr == 0) ? 1 : 0; // addr0's endpoint is the static asyn list head p_qhd->max_package_size = max_packet_size; - p_qhd->non_hs_control_endpoint = ((TUSB_XFER_CONTROL == xfer_type) && (usbh_device_info_pool[dev_addr].speed != TUSB_SPEED_HIGH) ) ? 1 : 0; + p_qhd->non_hs_control_endpoint = ((TUSB_XFER_CONTROL == xfer_type) && (usbh_devices[dev_addr].speed != TUSB_SPEED_HIGH) ) ? 1 : 0; p_qhd->nak_count_reload = 0; // Bulk/Control -> smask = cmask = 0 if (TUSB_XFER_INTERRUPT == xfer_type) { // Highspeed: schedule every uframe (1 us interval); Full/Low: schedule only 1st frame - p_qhd->interrupt_smask = (TUSB_SPEED_HIGH == usbh_device_info_pool[dev_addr].speed) ? 0xFF : 0x01; + p_qhd->interrupt_smask = (TUSB_SPEED_HIGH == usbh_devices[dev_addr].speed) ? 0xFF : 0x01; // Highspeed: ignored by Host Controller, Full/Low: 4.12.2.1 (EHCI) case 1 schedule complete split at 2,3,4 uframe p_qhd->non_hs_interrupt_cmask = BIN8(11100); }else @@ -712,8 +712,8 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si p_qhd->interrupt_smask = p_qhd->non_hs_interrupt_cmask = 0; } - p_qhd->hub_address = usbh_device_info_pool[dev_addr].hub_addr; - p_qhd->hub_port = usbh_device_info_pool[dev_addr].hub_port; + p_qhd->hub_address = usbh_devices[dev_addr].hub_addr; + p_qhd->hub_port = usbh_devices[dev_addr].hub_port; p_qhd->mult = 1; // TODO not use high bandwidth/park mode yet //------------- active, but no TD list -------------// diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 0dd2e6eec..e78789264 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -81,7 +81,7 @@ static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1] TUSB_CFG_ATTR_USBRAM; // including zero-address +usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1] TUSB_CFG_ATTR_USBRAM; // including zero-address //------------- Enumeration Task Data -------------// OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, OSAL_PRIO_HIGH); @@ -101,7 +101,7 @@ static inline uint8_t get_configure_number_for_device(tusb_descriptor_device_t* tusb_device_state_t tusbh_device_get_state (uint8_t const dev_addr) { ASSERT(dev_addr <= TUSB_CFG_HOST_DEVICE_MAX, TUSB_DEVICE_STATE_INVALID_PARAMETER); - return usbh_device_info_pool[dev_addr].state; + return usbh_devices[dev_addr].state; } //--------------------------------------------------------------------+ @@ -109,15 +109,15 @@ tusb_device_state_t tusbh_device_get_state (uint8_t const dev_addr) //--------------------------------------------------------------------+ tusb_error_t usbh_init(void) { - memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); + memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); ASSERT_STATUS( hcd_init() ); //------------- Semaphore for Control Pipe -------------// for(uint8_t i=0; iidVendor; - usbh_device_info_pool[new_addr].product_id = ((tusb_descriptor_device_t*) enum_data_buffer)->idProduct; - usbh_device_info_pool[new_addr].configure_count = ((tusb_descriptor_device_t*) enum_data_buffer)->bNumConfigurations; + usbh_devices[new_addr].vendor_id = ((tusb_descriptor_device_t*) enum_data_buffer)->idVendor; + usbh_devices[new_addr].product_id = ((tusb_descriptor_device_t*) enum_data_buffer)->idProduct; + usbh_devices[new_addr].configure_count = ((tusb_descriptor_device_t*) enum_data_buffer)->bNumConfigurations; configure_selected = get_configure_number_for_device((tusb_descriptor_device_t*) enum_data_buffer); - TASK_ASSERT(configure_selected <= usbh_device_info_pool[new_addr].configure_count); + TASK_ASSERT(configure_selected <= usbh_devices[new_addr].configure_count); //------------- Get 9 bytes of configuration descriptor -------------// OSAL_SUBTASK_INVOKED_AND_WAIT( @@ -369,7 +369,7 @@ OSAL_TASK_DECLARE(usbh_enumeration_task) ); // update configuration info - usbh_device_info_pool[new_addr].interface_count = ((tusb_descriptor_configuration_t*) enum_data_buffer)->bNumInterfaces; + usbh_devices[new_addr].interface_count = ((tusb_descriptor_configuration_t*) enum_data_buffer)->bNumInterfaces; //------------- parse configuration & install drivers -------------// p_desc = enum_data_buffer + sizeof(tusb_descriptor_configuration_t); @@ -415,7 +415,7 @@ OSAL_TASK_DECLARE(usbh_enumeration_task) ) ); - usbh_device_info_pool[new_addr].state = TUSB_DEVICE_STATE_CONFIGURED; + usbh_devices[new_addr].state = TUSB_DEVICE_STATE_CONFIGURED; tusbh_device_mount_succeed_cb(new_addr); OSAL_TASK_LOOP_END @@ -437,7 +437,7 @@ static inline uint8_t get_new_address(void) uint8_t addr; for (addr=1; addr <= TUSB_CFG_HOST_DEVICE_MAX; addr++) { - if (usbh_device_info_pool[addr].state == TUSB_DEVICE_STATE_UNPLUG) + if (usbh_devices[addr].state == TUSB_DEVICE_STATE_UNPLUG) break; } return addr; diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index 9d5f75eb3..9349c64e4 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -93,14 +93,15 @@ typedef struct { // TODO internal structure, re-order members volatile uint8_t state; // device state, value from enum tusbh_device_state_t //------------- control pipe -------------// - volatile uint8_t control_pipe_status; - tusb_std_request_t control_request; - OSAL_SEM_DEF(semaphore); // TODO move to semaphore pool - osal_semaphore_handle_t control_sem_hdl; - + struct { + volatile uint8_t pipe_status; + tusb_std_request_t request; + OSAL_SEM_DEF(semaphore); // TODO move to semaphore pool + osal_semaphore_handle_t sem_hdl; + } control; } usbh_device_info_t; -extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address +extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_bus_event_t event); void usbh_device_plugged_isr(uint8_t hostid, tusb_speed_t speed);