- fix bug when unplugged unmounted-already device (mostly plugged when power on)

- add hal_debugger_is_attached & hal_debugger_breakpoint
- assert will suspend (place breakpoint) if the condition is failed and debugger is attached. Otherwise, a message to uart is printed
- fix get control qhd function when dev_addr is not zero (shifted 1)
- fix wrong logic for unsupported class
This commit is contained in:
hathach
2013-03-22 17:08:51 +07:00
parent cd2915e78c
commit dbaf6c0d30
13 changed files with 663 additions and 1168 deletions
+3 -3
View File
@@ -142,7 +142,7 @@ void test_control_open_addr0_qhd_data(void)
void test_control_open_qhd_data(void)
{
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
//------------- Code Under TEST -------------//
hcd_pipe_control_open(dev_addr, control_max_packet_size);
@@ -170,7 +170,7 @@ void test_control_open_highspeed(void)
void test_control_open_non_highspeed(void)
{
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
usbh_device_info_pool[dev_addr].speed = TUSB_SPEED_FULL;
@@ -195,7 +195,7 @@ void test_control_addr0_close(void)
void test_control_close(void)
{
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
@@ -164,7 +164,7 @@ void test_control_addr0_xfer_get_check_qhd_qtd_mapping(void)
void test_control_xfer_get(void)
{
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
//------------- Code Under TEST -------------//
@@ -209,7 +209,7 @@ void test_control_xfer_set(void)
.wValue = 3
};
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
//------------- Code Under TEST -------------//
@@ -233,7 +233,7 @@ void test_control_xfer_set(void)
void test_control_xfer_isr(void)
{
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].control.qhd;
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr-1].control.qhd;
hcd_pipe_control_open(dev_addr, control_max_packet_size);
hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data);
@@ -78,6 +78,7 @@ void setUp(void)
usbh_device_info_pool[i].hub_addr = hub_addr;
usbh_device_info_pool[i].hub_port = hub_port;
usbh_device_info_pool[i].speed = TUSB_SPEED_HIGH;
usbh_device_info_pool[i].status = TUSB_DEVICE_STATUS_READY;
}
regs = get_operational_register(hostid);
@@ -178,3 +179,17 @@ void test_bulk_pipe_close(void)
TEST_ASSERT_FALSE(p_qtd_head->used);
TEST_ASSERT_FALSE(p_qtd_tail->used);
}
void test_device_unplugged_status(void)
{
ehci_controller_device_unplug(hostid);
hcd_isr(hostid);
regs->usb_sts_bit.async_advance = 1;
hcd_isr(hostid); // async advance
//------------- Code Under Test -------------//
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_REMOVING, usbh_device_info_pool[dev_addr].status);
}
+13
View File
@@ -162,6 +162,19 @@ void class_close_expect(void)
hidh_close_Expect(1);
}
// device is not mounted before, even the control pipe is not open, do nothing
void test_usbh_device_unplugged_isr_device_not_previously_mounted(void)
{
uint8_t dev_addr = 1;
usbh_device_info_pool[dev_addr].status = TUSB_DEVICE_STATUS_UNPLUG;
usbh_device_info_pool[dev_addr].core_id = 0;
usbh_device_info_pool[dev_addr].hub_addr = 0;
usbh_device_info_pool[dev_addr].hub_port = 0;
usbh_device_unplugged_isr(0);
}
void test_usbh_device_unplugged_isr(void)
{
uint8_t dev_addr = 1;