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
This commit is contained in:
hathach
2013-04-07 05:09:18 +07:00
parent 24ade0458e
commit 27f860db9f
16 changed files with 91 additions and 60 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));
}

View File

@@ -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));

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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