From 27f860db9ffd46bb8cb43046f9203f510a554d7c Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 7 Apr 2013 05:09:18 +0700 Subject: [PATCH] rename hidh_keyboard_info_t to hidh_interface_info_t rename tusb_bus_event_t to tusb_event_t add test_mouse_init and more stuff for hidh mouse move delay after port reset to only for speed detection prioritize port change interrupt over xfer interrupt - in case of unplugged, current connect change & xfer error both set - xfer error only break to debugger if not because of unplugged fix bug: set dev addr0 state to UNPLUG after close its control pipe in enumeration process --- tests/test/host/ehci/test_pipe_bulk_xfer.c | 2 +- tests/test/host/ehci/test_pipe_control_xfer.c | 4 +- .../test/host/ehci/test_pipe_interrupt_xfer.c | 2 +- tests/test/host/hid/test_hid_host.c | 4 +- tests/test/host/hid/test_hidh_keyboard.c | 8 ++-- tests/test/host/hid/test_hidh_mouse.c | 17 +++++++ tests/test/host/usbh/test_enum_task.c | 1 + tests/test/support/tusb_callback.h | 4 ++ tinyusb/class/hid_host.c | 22 ++++----- tinyusb/class/hid_host.h | 17 ++++--- tinyusb/class/msc_host.h | 2 +- tinyusb/core/tusb_types.h | 8 ++-- tinyusb/host/ehci/ehci.c | 45 ++++++++++--------- tinyusb/host/usbh.c | 11 +++-- tinyusb/host/usbh.h | 2 +- tinyusb/host/usbh_hcd.h | 2 +- 16 files changed, 91 insertions(+), 60 deletions(-) diff --git a/tests/test/host/ehci/test_pipe_bulk_xfer.c b/tests/test/host/ehci/test_pipe_bulk_xfer.c index 15e33d63..d91f632d 100644 --- a/tests/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/test/host/ehci/test_pipe_bulk_xfer.c @@ -208,7 +208,7 @@ void test_bulk_xfer_complete_isr(void) ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; - usbh_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, BUS_EVENT_XFER_COMPLETE); + usbh_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, TUSB_EVENT_XFER_COMPLETE); //------------- Code Under Test -------------// ehci_controller_run(hostid); diff --git a/tests/test/host/ehci/test_pipe_control_xfer.c b/tests/test/host/ehci/test_pipe_control_xfer.c index 3c062dae..53c1df0a 100644 --- a/tests/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/test/host/ehci/test_pipe_control_xfer.c @@ -226,7 +226,7 @@ void test_control_xfer_set(void) void test_control_xfer_complete_isr(void) { hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); - usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, BUS_EVENT_XFER_COMPLETE); + usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_COMPLETE); //------------- Code Under TEST -------------// ehci_controller_run(hostid); @@ -243,7 +243,7 @@ void test_control_xfer_complete_isr(void) void test_control_xfer_error_isr(void) { hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data); - usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, BUS_EVENT_XFER_ERROR); + usbh_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_ERROR); //------------- Code Under TEST -------------// ehci_controller_run_error(hostid); diff --git a/tests/test/host/ehci/test_pipe_interrupt_xfer.c b/tests/test/host/ehci/test_pipe_interrupt_xfer.c index d1ef66fb..b2180fbe 100644 --- a/tests/test/host/ehci/test_pipe_interrupt_xfer.c +++ b/tests/test/host/ehci/test_pipe_interrupt_xfer.c @@ -194,7 +194,7 @@ void test_interrupt_xfer_complete_isr(void) ehci_qtd_t* p_head = p_qhd_interrupt->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_interrupt->p_qtd_list_tail; - usbh_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, BUS_EVENT_XFER_COMPLETE); + usbh_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_COMPLETE); //------------- Code Under Test -------------// ehci_controller_run(hostid); diff --git a/tests/test/host/hid/test_hid_host.c b/tests/test/host/hid/test_hid_host.c index f96f20eb..cae28cce 100644 --- a/tests/test/host/hid/test_hid_host.c +++ b/tests/test/host/hid/test_hid_host.c @@ -52,7 +52,7 @@ uint8_t dev_addr; pipe_handle_t pipe_hdl; -extern hidh_keyboard_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; +extern hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; tusb_descriptor_interface_t const *p_kbd_interface_desc = &desc_configuration.keyboard_interface; tusb_hid_descriptor_hid_t const *p_kbh_hid_desc = &desc_configuration.keyboard_hid; @@ -92,5 +92,5 @@ void test_hidh_close(void) //------------- Code Under TEST -------------// hidh_close(dev_addr); - TEST_ASSERT_MEM_ZERO(&keyboard_data[dev_addr-1], sizeof(hidh_keyboard_info_t)); + TEST_ASSERT_MEM_ZERO(&keyboard_data[dev_addr-1], sizeof(hidh_interface_info_t)); } diff --git a/tests/test/host/hid/test_hidh_keyboard.c b/tests/test/host/hid/test_hidh_keyboard.c index 9e95f0aa..a3ef3454 100644 --- a/tests/test/host/hid/test_hidh_keyboard.c +++ b/tests/test/host/hid/test_hidh_keyboard.c @@ -45,7 +45,7 @@ #include "mock_hcd.h" #include "descriptor_test.h" -extern hidh_keyboard_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; +extern hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; tusb_keyboard_report_t sample_key[2] = { @@ -61,7 +61,7 @@ tusb_keyboard_report_t sample_key[2] = uint8_t dev_addr; tusb_keyboard_report_t report; -hidh_keyboard_info_t *p_hidh_kbd; +hidh_interface_info_t *p_hidh_kbd; tusb_descriptor_interface_t const *p_kbd_interface_desc = &desc_configuration.keyboard_interface; tusb_descriptor_endpoint_t const *p_kdb_endpoint_desc = &desc_configuration.keyboard_endpoint; @@ -92,7 +92,7 @@ void test_keyboard_init(void) { hidh_init(); - TEST_ASSERT_MEM_ZERO(keyboard_data, sizeof(hidh_keyboard_info_t)*TUSB_CFG_HOST_DEVICE_MAX); + TEST_ASSERT_MEM_ZERO(keyboard_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX); } void test_keyboard_is_supported_fail_unplug(void) @@ -191,7 +191,7 @@ void test_keyboard_get_ok() void test_keyboard_isr_event_complete(void) { //------------- Code Under TEST -------------// - hidh_isr(p_hidh_kbd->pipe_hdl, BUS_EVENT_XFER_COMPLETE); + hidh_isr(p_hidh_kbd->pipe_hdl, TUSB_EVENT_XFER_COMPLETE); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_keyboard_status(dev_addr, 0)); diff --git a/tests/test/host/hid/test_hidh_mouse.c b/tests/test/host/hid/test_hidh_mouse.c index a366482b..e1e0d8fa 100644 --- a/tests/test/host/hid/test_hidh_mouse.c +++ b/tests/test/host/hid/test_hidh_mouse.c @@ -45,6 +45,8 @@ #include "mock_hcd.h" #include "descriptor_test.h" +extern hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX]; + void setUp(void) { } @@ -53,3 +55,18 @@ void tearDown(void) { } + +void test_mouse_init(void) +{ + hidh_init(); + + TEST_ASSERT_MEM_ZERO(mouse_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX); +} + + + + + + + + diff --git a/tests/test/host/usbh/test_enum_task.c b/tests/test/host/usbh/test_enum_task.c index 28a6a3c9..f942af74 100644 --- a/tests/test/host/usbh/test_enum_task.c +++ b/tests/test/host/usbh/test_enum_task.c @@ -200,6 +200,7 @@ void test_enum_failed_get_full_dev_desc(void) usbh_enumeration_task(); + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_UNPLUG, usbh_devices[0].state); TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_devices[1].state); TEST_ASSERT_EQUAL(TUSB_SPEED_FULL, usbh_devices[1].speed); TEST_ASSERT_EQUAL(enum_connect.core_id, usbh_devices[1].core_id); diff --git a/tests/test/support/tusb_callback.h b/tests/test/support/tusb_callback.h index c5e4ae25..99219416 100644 --- a/tests/test/support/tusb_callback.h +++ b/tests/test/support/tusb_callback.h @@ -58,10 +58,14 @@ #include "common/common.h" #include "usbh.h" +//------------- core -------------// uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; void tusbh_device_mount_succeed_cb (uint8_t dev_addr) ATTR_WEAK; void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK; +//------------- hidh -------------// +void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event); + #ifdef __cplusplus } #endif diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index db68f01a..61e184db 100644 --- a/tinyusb/class/hid_host.c +++ b/tinyusb/class/hid_host.c @@ -59,10 +59,10 @@ //--------------------------------------------------------------------+ #if TUSB_CFG_HOST_HID_KEYBOARD -STATIC_ hidh_keyboard_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 +STATIC_ hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 -static inline hidh_keyboard_info_t* get_kbd_data(uint8_t dev_addr) ATTR_PURE ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; -static inline hidh_keyboard_info_t* get_kbd_data(uint8_t dev_addr) +static inline hidh_interface_info_t* get_kbd_data(uint8_t dev_addr) ATTR_PURE ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; +static inline hidh_interface_info_t* get_kbd_data(uint8_t dev_addr) { return &keyboard_data[dev_addr-1]; } @@ -80,7 +80,7 @@ tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_nu (void) instance_num; - hidh_keyboard_info_t *p_keyboard = get_kbd_data(dev_addr); + hidh_interface_info_t *p_keyboard = get_kbd_data(dev_addr); ASSERT(TUSB_INTERFACE_STATUS_BUSY != p_keyboard->status, TUSB_ERROR_INTERFACE_IS_BUSY); @@ -100,7 +100,7 @@ tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t inst static inline tusb_error_t hidh_keyboard_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc) ATTR_ALWAYS_INLINE; static inline tusb_error_t hidh_keyboard_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc) { - hidh_keyboard_info_t *p_keyboard = get_kbd_data(dev_addr); + hidh_interface_info_t *p_keyboard = get_kbd_data(dev_addr); p_keyboard->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID); p_keyboard->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor @@ -116,7 +116,7 @@ static inline void hidh_keyboard_close(uint8_t dev_addr) pipe_handle_t pipe_hdl = keyboard_data[dev_addr-1].pipe_hdl; if ( pipehandle_is_valid(pipe_hdl) ) { - memclr_(&keyboard_data[dev_addr-1], sizeof(hidh_keyboard_info_t)); + memclr_(&keyboard_data[dev_addr-1], sizeof(hidh_interface_info_t)); ASSERT_INT( TUSB_ERROR_NONE, hcd_pipe_close(pipe_hdl), (void) 0 ); } } @@ -128,6 +128,8 @@ static inline void hidh_keyboard_close(uint8_t dev_addr) //--------------------------------------------------------------------+ #if TUSB_CFG_HOST_HID_MOUSE +STATIC_ hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 + //------------- Internal API -------------// static inline tusb_error_t hidh_mouse_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc) ATTR_ALWAYS_INLINE; static inline tusb_error_t hidh_mouse_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc) @@ -150,11 +152,11 @@ static inline void hidh_mouse_close(uint8_t dev_addr) void hidh_init(void) { #if TUSB_CFG_HOST_HID_KEYBOARD - memclr_(&keyboard_data, sizeof(hidh_keyboard_info_t)*TUSB_CFG_HOST_DEVICE_MAX); + memclr_(&keyboard_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX); #endif #if TUSB_CFG_HOST_HID_MOUSE -// hidh_mouse_init(); + memclr_(&mouse_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX); #endif #if TUSB_CFG_HOST_HID_GENERIC @@ -207,12 +209,12 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con return TUSB_ERROR_NONE; } -void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) +void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event) { #if TUSB_CFG_HOST_HID_KEYBOARD if ( pipehandle_is_equal(pipe_hdl, keyboard_data[pipe_hdl.dev_addr-1].pipe_hdl) ) { - keyboard_data[pipe_hdl.dev_addr-1].status = (event == BUS_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR; + keyboard_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR; return; } #endif diff --git a/tinyusb/class/hid_host.h b/tinyusb/class/hid_host.h index 5d5fa1fc..81a443bd 100644 --- a/tinyusb/class/hid_host.h +++ b/tinyusb/class/hid_host.h @@ -62,12 +62,6 @@ //--------------------------------------------------------------------+ // KEYBOARD Public API //--------------------------------------------------------------------+ -typedef struct { - pipe_handle_t pipe_hdl; - uint16_t report_size; - volatile tusb_interface_status_t status; -}hidh_keyboard_info_t; - bool tusbh_hid_keyboard_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_num, uint8_t * const report) ATTR_WARN_UNUSED_RESULT; tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT; @@ -75,6 +69,9 @@ tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t inst //--------------------------------------------------------------------+ // MOUSE Public API //--------------------------------------------------------------------+ +bool tusbh_hid_mouse_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; +tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, uint8_t instance_num, uint8_t * const report) ATTR_WARN_UNUSED_RESULT; +tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT; //--------------------------------------------------------------------+ // GENERIC Public API @@ -85,9 +82,15 @@ tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t inst //--------------------------------------------------------------------+ #ifdef _TINY_USB_SOURCE_FILE_ +typedef struct { + pipe_handle_t pipe_hdl; + uint16_t report_size; + volatile tusb_interface_status_t status; +}hidh_interface_info_t; + void hidh_init(void); tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; -void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event); +void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event); void hidh_close(uint8_t dev_addr); #endif diff --git a/tinyusb/class/msc_host.h b/tinyusb/class/msc_host.h index 5d0a87a6..525eb929 100644 --- a/tinyusb/class/msc_host.h +++ b/tinyusb/class/msc_host.h @@ -70,7 +70,7 @@ void msch_init(void) ATTR_WEAK; tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; -void msch_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) ATTR_WEAK; +void msch_isr(pipe_handle_t pipe_hdl, tusb_event_t event) ATTR_WEAK; void msch_close(uint8_t dev_addr) ATTR_WEAK; #endif diff --git a/tinyusb/core/tusb_types.h b/tinyusb/core/tusb_types.h index 8dd9a529..33baf670 100644 --- a/tinyusb/core/tusb_types.h +++ b/tinyusb/core/tusb_types.h @@ -190,9 +190,11 @@ typedef enum tusb_device_state_{ }tusb_device_state_t; typedef enum { - BUS_EVENT_XFER_COMPLETE, - BUS_EVENT_XFER_ERROR -}tusb_bus_event_t; + TUSB_EVENT_XFER_COMPLETE, + TUSB_EVENT_XFER_ERROR, + TUSB_EVENT_INTERFACE_OPEN, + TUSB_EVENT_INTERFACE_CLOSE +}tusb_event_t; enum { DESCRIPTOR_OFFSET_LENGTH = 0, diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 7a8ad8f3..7293c264 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -135,11 +135,6 @@ void hcd_port_reset(uint8_t hostid) // NXP specific, port reset will automatically be 0 when reset sequence complete // there is chance device is unplugged while reset sequence is not complete while( regs->portsc_bit.port_reset) {} - - // TODO finalize delay after reset, hack delay 100 ms, otherwise speed is detected as LOW in most cases - volatile uint32_t delay_us = 100000; - delay_us *= (SystemCoreClock / 1000000) / 3; - while(delay_us--); #endif } @@ -457,6 +452,14 @@ void port_connect_status_change_isr(uint8_t hostid) if (regs->portsc_bit.current_connect_status) // device plugged { hcd_port_reset(hostid); + + #ifndef _TEST_ + // TODO finalize delay after reset, hack delay 100 ms, otherwise speed is detected as LOW in most cases + volatile uint32_t delay_us = 100000; + delay_us *= (SystemCoreClock / 1000000) / 3; + while(delay_us--); + #endif + usbh_device_plugged_isr(hostid, regs->portsc_bit.nxp_port_speed); // NXP specific port speed }else // device unplugged { @@ -485,7 +488,7 @@ void async_list_process_isr(ehci_qhd_t * const async_head) pipe_hdl.xfer_type = TUSB_XFER_BULK; pipe_hdl.index = qhd_get_index(p_qhd); } - usbh_isr( pipe_hdl, p_qhd->class_code, BUS_EVENT_XFER_COMPLETE); // call USBH callback + usbh_isr( pipe_hdl, p_qhd->class_code, TUSB_EVENT_XFER_COMPLETE); // call USBH callback } p_qhd->p_qtd_list_head->used = 0; // free QTD @@ -525,7 +528,7 @@ void period_list_process_isr(ehci_qhd_t const * const period_head) pipe_hdl.xfer_type = TUSB_XFER_INTERRUPT; pipe_hdl.index = qhd_get_index(p_qhd_int); } - usbh_isr( pipe_hdl, p_qhd_int->class_code, BUS_EVENT_XFER_COMPLETE); // call USBH callback + usbh_isr( pipe_hdl, p_qhd_int->class_code, TUSB_EVENT_XFER_COMPLETE); // call USBH callback } p_qhd_int->p_qtd_list_head->used = 0; // free QTD @@ -565,7 +568,8 @@ void xfer_error_isr(uint8_t hostid) pipe_hdl.xfer_type = TUSB_XFER_BULK; pipe_hdl.index = qhd_get_index(p_qhd); } - usbh_isr( pipe_hdl, p_qhd->class_code, BUS_EVENT_XFER_ERROR); // call USBH callback + hal_debugger_breakpoint(); + usbh_isr( pipe_hdl, p_qhd->class_code, TUSB_EVENT_XFER_ERROR); // call USBH callback } p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address); @@ -585,10 +589,21 @@ void hcd_isr(uint8_t hostid) if (int_status == 0) return; + if (int_status & EHCI_INT_MASK_PORT_CHANGE) + { + uint32_t port_status = regs->portsc & EHCI_PORTSC_MASK_ALL; + + if (regs->portsc_bit.connect_status_change) + { + port_connect_status_change_isr(hostid); + } + + regs->portsc |= port_status; // Acknowledge change bits in portsc + } + if (int_status & EHCI_INT_MASK_ERROR) { // TODO handle Queue Head halted - hal_debugger_breakpoint(); xfer_error_isr(hostid); } @@ -603,18 +618,6 @@ void hcd_isr(uint8_t hostid) period_list_process_isr( get_period_head(hostid) ); } - if (int_status & EHCI_INT_MASK_PORT_CHANGE) - { - uint32_t port_status = regs->portsc & EHCI_PORTSC_MASK_ALL; - - if (regs->portsc_bit.connect_status_change) - { - port_connect_status_change_isr(hostid); - } - - regs->portsc |= port_status; // Acknowledge change bits in portsc - } - if (int_status & EHCI_INT_MASK_ASYNC_ADVANCE) // need to place after EHCI_INT_MASK_NXP_ASYNC { async_advance_isr( get_async_head(hostid) ); diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index eada2d6c..8c3b2070 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -187,11 +187,11 @@ tusb_interface_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) // USBH-HCD ISR/Callback API //--------------------------------------------------------------------+ // interrupt caused by a TD (with IOC=1) in pipe of class class_code -void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_bus_event_t event) +void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event) { if (class_code == 0) // Control transfer { - usbh_devices[ pipe_hdl.dev_addr ].control.pipe_status = (event == BUS_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR; + usbh_devices[ pipe_hdl.dev_addr ].control.pipe_status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR; osal_semaphore_post( usbh_devices[ pipe_hdl.dev_addr ].control.sem_hdl ); }else if (usbh_class_drivers[class_code].isr) { @@ -217,9 +217,7 @@ void usbh_device_unplugged_isr(uint8_t hostid) !(usbh_devices[dev_addr].core_id == hostid && usbh_devices[dev_addr].hub_addr == 0 && usbh_devices[dev_addr].hub_port == 0 && - usbh_devices[dev_addr].state != TUSB_DEVICE_STATE_UNPLUG - ) - ) + usbh_devices[dev_addr].state != TUSB_DEVICE_STATE_UNPLUG ) ) { dev_addr++; } @@ -290,7 +288,7 @@ OSAL_TASK_DECLARE(usbh_enumeration_task) ) ); - hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor +// hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor //------------- Set new address -------------// new_addr = get_new_address(); @@ -317,6 +315,7 @@ OSAL_TASK_DECLARE(usbh_enumeration_task) usbh_devices[new_addr].state = TUSB_DEVICE_STATE_ADDRESSED; usbh_pipe_control_close(0); + usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG; // open control pipe for new address TASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) ); diff --git a/tinyusb/host/usbh.h b/tinyusb/host/usbh.h index 68450547..2eac1d88 100644 --- a/tinyusb/host/usbh.h +++ b/tinyusb/host/usbh.h @@ -74,7 +74,7 @@ typedef enum tusb_interface_status_{ typedef struct { void (* const init) (void); tusb_error_t (* const open_subtask)(uint8_t, tusb_descriptor_interface_t const *, uint16_t*); - void (* const isr) (pipe_handle_t, tusb_bus_event_t); + void (* const isr) (pipe_handle_t, tusb_event_t); void (* const close) (uint8_t); } host_class_driver_t; //--------------------------------------------------------------------+ diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index 815d35b3..f235c317 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -106,7 +106,7 @@ typedef struct { // TODO internal structure, re-order members extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address //------------- callback from HCD ISR-------------// -void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_bus_event_t event); +void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event); void usbh_device_plugged_isr(uint8_t hostid, tusb_speed_t speed); void usbh_device_unplugged_isr(uint8_t hostid);