From 79e277d323a4c20070dbd9d34d058ea3b6b55e7d Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 13 Mar 2013 00:02:45 +0700 Subject: [PATCH] go through all the enumeration (up to get full configuration) - fix init_qhd for address 0 (clear queue head --> ehci controller halted) - fix bug in usbh_init missing address0 for semaphore create TUSB_CFG_DEBUG == 3: --> ATTR_ALWAYS_INLINE is null --> allow gcc to export "normal inline" function --- demos/bsp/boards/board.h | 16 ++++++++-------- demos/bsp/boards/board_ea4357.c | 3 --- tests/test/host/test_usbh.c | 6 +++--- tinyusb/common/compiler/compiler.h | 4 ++++ tinyusb/host/ehci/ehci.c | 20 ++++++++++++++------ tinyusb/host/usbh.c | 2 +- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/demos/bsp/boards/board.h b/demos/bsp/boards/board.h index 611386c8..b64c0adf 100644 --- a/demos/bsp/boards/board.h +++ b/demos/bsp/boards/board.h @@ -63,20 +63,20 @@ #define BOARD_NGX4330 3 #define BOARD_EA4357 4 -#define PRINTF_TARGET_DEBUG_CONSOLE 0 // IDE semihosting console -#define PRINTF_TARGET_UART 1 -#define PRINTF_TARGET_SWO 2 // aka SWV, ITM +#define PRINTF_TARGET_DEBUG_CONSOLE 1 // IDE semihosting console +#define PRINTF_TARGET_UART 2 +#define PRINTF_TARGET_SWO 3 // aka SWV, ITM #if BOARD == 0 - #error BOARD is not defined or supported yet + #error BOARD is not defined or supported yet #elif BOARD == BOARD_NGX4330 - #include "board_ngx4330.h" + #include "board_ngx4330.h" #elif BOARD == BOARD_LPCXPRESSO1347 - #include "board_lpcxpresso1347.h" + #include "board_lpcxpresso1347.h" #elif BOARD == BOARD_AT86RF2XX - #include "board_at86rf2xx.h" + #include "board_at86rf2xx.h" #elif BOARD == BOARD_EA4357 - #include "board_ea4357.h" + #include "board_ea4357.h" #else #error BOARD is not defined or supported yet #endif diff --git a/demos/bsp/boards/board_ea4357.c b/demos/bsp/boards/board_ea4357.c index 00a2af7b..a019645d 100644 --- a/demos/bsp/boards/board_ea4357.c +++ b/demos/bsp/boards/board_ea4357.c @@ -84,9 +84,6 @@ void board_init(void) #endif #if CFG_PRINTF_TARGET == PRINTF_TARGET_SWO - tttt -// LPC_IOCON->PIO0_9 &= ~0x07; /* UART I/O config */ -// LPC_IOCON->PIO0_9 |= 0x03; /* UART RXD */ #endif } diff --git a/tests/test/host/test_usbh.c b/tests/test/host/test_usbh.c index 315fdee5..27bceb69 100644 --- a/tests/test/host/test_usbh.c +++ b/tests/test/host/test_usbh.c @@ -87,7 +87,7 @@ void test_usbh_init_hcd_failed(void) void test_usbh_init_enum_task_create_failed(void) { hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); - for (uint8_t i=0; ip_qtd_list_head == NULL) // empty list { p_qhd->p_qtd_list_head = p_qhd->p_qtd_list_tail = p_qtd_new; - p_qhd->qtd_overlay.next.address = (uint32_t) p_qhd->p_qtd_list_head; + p_qhd->qtd_overlay.next.address = (uint32_t) p_qtd_new; }else { p_qhd->p_qtd_list_tail->next.address = (uint32_t) p_qtd_new; @@ -450,7 +450,6 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * init_qtd(p_setup, (uint32_t) p_request, 8); p_setup->pid = EHCI_PID_SETUP; p_setup->next.address = (uint32_t) p_data; - insert_qtd_to_qhd(p_qhd, p_setup); //------------- DATA Phase -------------// if (p_request->wLength > 0) @@ -458,12 +457,10 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * init_qtd(p_data, (uint32_t) data, p_request->wLength); p_data->data_toggle = 1; p_data->pid = p_request->bmRequestType.direction ? EHCI_PID_IN : EHCI_PID_OUT; - insert_qtd_to_qhd(p_qhd, p_data); }else { p_data = p_setup; } - p_data->next.address = (uint32_t) p_status; //------------- STATUS Phase -------------// @@ -472,7 +469,12 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * p_status->data_toggle = 1; p_status->pid = p_request->bmRequestType.direction ? EHCI_PID_OUT : EHCI_PID_IN; // reverse direction of data phase p_status->next.terminate = 1; - insert_qtd_to_qhd(p_qhd, p_status); + + //------------- Attach TDs list to Control Endpoint -------------// + p_qhd->p_qtd_list_head = p_setup; + p_qhd->p_qtd_list_tail = p_status; + + p_qhd->qtd_overlay.next.address = (uint32_t) p_setup; return TUSB_ERROR_NONE; } @@ -576,7 +578,10 @@ static inline ehci_qtd_t* get_control_qtds(uint8_t dev_addr) static void init_qhd(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_size, uint8_t endpoint_addr, uint8_t xfer_type) { - memclr_(p_qhd, sizeof(ehci_qhd_t)); + if (dev_addr != 0) + { + memclr_(p_qhd, sizeof(ehci_qhd_t)); + } p_qhd->device_address = dev_addr; p_qhd->inactive_next_xact = 0; @@ -595,6 +600,9 @@ static void init_qhd(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si p_qhd->interrupt_smask = (TUSB_SPEED_HIGH == usbh_device_info_pool[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 + { + p_qhd->interrupt_smask = p_qhd->non_hs_interrupt_cmask = 0; } p_qhd->hub_address = usbh_device_info_pool[dev_addr].hub_addr; diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index b7deaee8..dc37b9e3 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -112,7 +112,7 @@ tusb_error_t usbh_init(void) ASSERT_STATUS( hcd_init() ); //------------- Semaphore for Control Pipe -------------// - for(uint8_t i=0; i