usbh rename vars

This commit is contained in:
hathach
2018-12-07 00:47:16 +07:00
parent 2fe9abe71f
commit c93fb23693
17 changed files with 171 additions and 159 deletions

View File

@@ -51,7 +51,7 @@
#include "mock_osal.h"
#include "mock_usbh_hcd.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t hostid;

View File

@@ -50,7 +50,7 @@
#include "mock_osal.h"
#include "mock_usbh_hcd.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t hostid;
static ehci_registers_t * regs;

View File

@@ -51,7 +51,7 @@
#include "mock_osal.h"
#include "mock_usbh_hcd.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
//--------------------------------------------------------------------+
// Setup/Teardown + helper declare

View File

@@ -51,7 +51,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t const hub_addr = 2;
static uint8_t const hub_port = 2;
@@ -70,7 +70,7 @@ void setUp(void)
dev_addr = 1;
hostid = RANDOM(CONTROLLER_HOST_NUMBER) + TEST_CONTROLLER_HOST_START_INDEX;
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
helper_usbh_device_emulate(dev_addr, hub_addr, hub_port, hostid, TUSB_SPEED_HIGH);
async_head = get_async_head( hostid );
@@ -85,7 +85,7 @@ void verify_open_qhd(ehci_qhd_t *p_qhd, uint8_t endpoint_addr, uint16_t max_pack
TEST_ASSERT_EQUAL(dev_addr, p_qhd->device_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_devices[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

View File

@@ -51,7 +51,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t hub_addr = 2;
static uint8_t hub_port = 2;
@@ -91,7 +91,7 @@ void setUp(void)
{
ehci_controller_init();
tu_memclr(xfer_data, sizeof(xfer_data));
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
TEST_ASSERT_STATUS( hcd_init() );
@@ -146,7 +146,7 @@ void verify_qtd(ehci_qtd_t *p_qtd, uint8_t p_data[], uint16_t length)
void test_bulk_xfer_hs_ping_out(void)
{
usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH;
_usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH;
pipe_handle_t pipe_hdl = hcd_pipe_open(dev_addr, &desc_ept_bulk_out, TUSB_CLASS_MSC);
ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle(pipe_hdl);

View File

@@ -51,7 +51,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t const control_max_packet_size = 64;
static uint8_t const hub_addr = 2;
@@ -67,7 +67,7 @@ static ehci_qhd_t *p_control_qhd;
//--------------------------------------------------------------------+
void setUp(void)
{
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
TEST_ASSERT_STATUS( hcd_init() );
@@ -90,7 +90,7 @@ void verify_open_qhd(ehci_qhd_t *p_qhd, uint8_t endpoint_addr, uint16_t max_pack
TEST_ASSERT_EQUAL(dev_addr, p_qhd->device_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_devices[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
@@ -149,7 +149,7 @@ void test_control_open_qhd_data(void)
void test_control_open_highspeed(void)
{
usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH;
_usbh_devices[dev_addr].speed = TUSB_SPEED_HIGH;
//------------- Code Under TEST -------------//
TEST_ASSERT_STATUS( hcd_pipe_control_open(dev_addr, control_max_packet_size) );
@@ -158,7 +158,7 @@ void test_control_open_highspeed(void)
void test_control_open_non_highspeed(void)
{
usbh_devices[dev_addr].speed = TUSB_SPEED_FULL;
_usbh_devices[dev_addr].speed = TUSB_SPEED_FULL;
//------------- Code Under TEST -------------//
TEST_ASSERT_STATUS( hcd_pipe_control_open(dev_addr, control_max_packet_size) );

View File

@@ -51,7 +51,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t const control_max_packet_size = 64;
static uint8_t const hub_addr = 2;
@@ -74,7 +74,7 @@ void setUp(void)
{
ehci_controller_init();
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(xfer_data, sizeof(xfer_data));
TEST_ASSERT_STATUS( hcd_init() );

View File

@@ -50,7 +50,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t const hub_addr = 2;
static uint8_t const hub_port = 2;
@@ -67,7 +67,7 @@ static pipe_handle_t pipe_hdl;
//--------------------------------------------------------------------+
void setUp(void)
{
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
hcd_init();
@@ -90,7 +90,7 @@ void verify_open_qhd(ehci_qhd_t *p_qhd, uint8_t endpoint_addr, uint16_t max_pack
TEST_ASSERT_EQUAL(dev_addr, p_qhd->device_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_devices[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
@@ -272,7 +272,7 @@ void test_open_interrupt_hs_interval_8(void)
void test_open_interrupt_qhd_non_hs(void)
{
usbh_devices[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);
@@ -294,7 +294,7 @@ void test_open_interrupt_qhd_non_hs_9(void)
tusb_desc_endpoint_t int_edp_interval = desc_ept_interrupt_out;
int_edp_interval.bInterval = 32;
usbh_devices[dev_addr].speed = TUSB_SPEED_FULL;
_usbh_devices[dev_addr].speed = TUSB_SPEED_FULL;
//------------- Code Under TEST -------------//
pipe_hdl = hcd_pipe_open(dev_addr, &int_edp_interval, TUSB_CLASS_HID);

View File

@@ -51,7 +51,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t const hub_addr = 2;
static uint8_t const hub_port = 2;
@@ -91,7 +91,7 @@ void setUp(void)
{
ehci_controller_init();
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(xfer_data, sizeof(xfer_data));
TEST_ASSERT_STATUS( hcd_init() );

View File

@@ -50,7 +50,7 @@
#include "ehci_controller_fake.h"
#include "host_helper.h"
usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
static uint8_t const hub_addr = 2;
static uint8_t const hub_port = 2;
@@ -63,7 +63,7 @@ static ehci_qhd_t *period_head_arr;
//--------------------------------------------------------------------+
void setUp(void)
{
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
hcd_init();

View File

@@ -69,11 +69,11 @@ static inline void helper_usbh_init_expect(void)
static inline void helper_usbh_device_emulate(uint8_t dev_addr, uint8_t hub_addr, uint8_t hub_port, uint8_t hostid, tusb_speed_t speed)
{
usbh_devices[dev_addr].core_id = hostid;
usbh_devices[dev_addr].hub_addr = hub_addr;
usbh_devices[dev_addr].hub_port = hub_port;
usbh_devices[dev_addr].speed = speed;
usbh_devices[dev_addr].state = dev_addr ? TUSB_DEVICE_STATE_CONFIGURED : TUSB_DEVICE_STATE_UNPLUG;
_usbh_devices[dev_addr].core_id = hostid;
_usbh_devices[dev_addr].hub_addr = hub_addr;
_usbh_devices[dev_addr].hub_port = hub_port;
_usbh_devices[dev_addr].speed = speed;
_usbh_devices[dev_addr].state = dev_addr ? TUSB_DEVICE_STATE_CONFIGURED : TUSB_DEVICE_STATE_UNPLUG;
}

View File

@@ -51,7 +51,7 @@
#include "mock_cdc_host.h"
#include "mock_msc_host.h"
extern usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
extern usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
extern uint8_t enum_data_buffer[CFG_TUSB_HOST_ENUM_BUFFER_SIZE];
usbh_enumerate_t const enum_connect = {
@@ -73,7 +73,7 @@ enum {
void setUp(void)
{
tu_memclr(usbh_devices, sizeof(usbh_device_info_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
tu_memclr(_usbh_devices, sizeof(usbh_device_t)*(CFG_TUSB_HOST_DEVICE_MAX+1));
osal_queue_receive_StubWithCallback(queue_recv_stub);
osal_semaphore_wait_StubWithCallback(semaphore_wait_success_stub);
@@ -89,8 +89,8 @@ void setUp(void)
osal_task_delay_Expect(RESET_DELAY);
hcd_port_speed_get_ExpectAndReturn(enum_connect.core_id, device_speed);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
osal_semaphore_reset_Expect( _usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( _usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(0, 8, TUSB_ERROR_NONE);
}
@@ -222,53 +222,53 @@ void test_addr0_failed_dev_desc(void)
usbh_enumeration_task(NULL);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_devices[0].state);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, _usbh_devices[0].state);
}
void test_addr0_failed_set_address(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(1));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_port_reset_Expect( _usbh_devices[0].core_id );
osal_task_delay_Expect(RESET_DELAY);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_devices[0].state);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, _usbh_devices[0].state);
TEST_ASSERT_EQUAL_MEMORY(&desc_device, enum_data_buffer, 8);
}
void test_enum_failed_get_full_dev_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(2));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_port_reset_Expect( _usbh_devices[0].core_id );
osal_task_delay_Expect(RESET_DELAY);
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
osal_semaphore_reset_Expect( _usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( _usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
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);
TEST_ASSERT_EQUAL(enum_connect.hub_addr, usbh_devices[1].hub_addr);
TEST_ASSERT_EQUAL(enum_connect.hub_port, usbh_devices[1].hub_port);
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);
TEST_ASSERT_EQUAL(enum_connect.hub_addr, _usbh_devices[1].hub_addr);
TEST_ASSERT_EQUAL(enum_connect.hub_port, _usbh_devices[1].hub_port);
}
void test_enum_failed_get_9byte_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(3));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_port_reset_Expect( _usbh_devices[0].core_id );
osal_task_delay_Expect(RESET_DELAY);
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
osal_semaphore_reset_Expect( _usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( _usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_attached_cb_ExpectAndReturn((tusb_desc_device_t*) enum_data_buffer, 1);
@@ -276,19 +276,19 @@ void test_enum_failed_get_9byte_config_desc(void)
usbh_enumeration_task(NULL);
TEST_ASSERT_EQUAL(desc_device.idVendor, usbh_devices[1].vendor_id);
TEST_ASSERT_EQUAL(desc_device.idProduct, usbh_devices[1].product_id);
TEST_ASSERT_EQUAL(desc_device.bNumConfigurations, usbh_devices[1].configure_count);
TEST_ASSERT_EQUAL(desc_device.idVendor, _usbh_devices[1].vendor_id);
TEST_ASSERT_EQUAL(desc_device.idProduct, _usbh_devices[1].product_id);
TEST_ASSERT_EQUAL(desc_device.bNumConfigurations, _usbh_devices[1].configure_count);
}
void test_enum_failed_get_full_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(4));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_port_reset_Expect( _usbh_devices[0].core_id );
osal_task_delay_Expect(RESET_DELAY);
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
osal_semaphore_reset_Expect( _usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( _usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_attached_cb_ExpectAndReturn((tusb_desc_device_t*) enum_data_buffer, 1);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
@@ -299,11 +299,11 @@ void test_enum_failed_get_full_config_desc(void)
void test_enum_parse_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_port_reset_Expect( _usbh_devices[0].core_id );
osal_task_delay_Expect(RESET_DELAY);
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
osal_semaphore_reset_Expect( _usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( _usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_attached_cb_ExpectAndReturn((tusb_desc_device_t*) enum_data_buffer, 1);
@@ -311,17 +311,17 @@ void test_enum_parse_config_desc(void)
usbh_enumeration_task(NULL);
TEST_ASSERT_EQUAL(desc_configuration.configuration.bNumInterfaces, usbh_devices[1].interface_count);
TEST_ASSERT_EQUAL(desc_configuration.configuration.bNumInterfaces, _usbh_devices[1].interface_count);
}
void test_enum_set_configure(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(6));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_port_reset_Expect( _usbh_devices[0].core_id );
osal_task_delay_Expect(RESET_DELAY);
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
osal_semaphore_reset_Expect( _usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( _usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_attached_cb_ExpectAndReturn((tusb_desc_device_t*) enum_data_buffer, 1);
@@ -335,5 +335,5 @@ void test_enum_set_configure(void)
usbh_enumeration_task(NULL);
TEST_ASSERT_EQUAL( BIT_(TUSB_CLASS_HID) | BIT_(TUSB_CLASS_MSC) | BIT_(TUSB_CLASS_CDC),
usbh_devices[1].flag_supported_class); // TODO change later
_usbh_devices[1].flag_supported_class); // TODO change later
}

View File

@@ -68,7 +68,7 @@ void tearDown(void)
//--------------------------------------------------------------------+
void test_usbh_status_get_fail(void)
{
usbh_devices[dev_addr].state = 0;
_usbh_devices[dev_addr].state = 0;
TEST_ASSERT_EQUAL( TUSB_DEVICE_STATE_INVALID_PARAMETER, tusbh_device_get_state(CFG_TUSB_HOST_DEVICE_MAX+1) );
TEST_ASSERT_EQUAL( TUSB_DEVICE_STATE_UNPLUG, tusbh_device_get_state(dev_addr) );
@@ -76,7 +76,7 @@ void test_usbh_status_get_fail(void)
void test_usbh_status_get_succeed(void)
{
usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
_usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
TEST_ASSERT_EQUAL( TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr) );
}
@@ -136,7 +136,7 @@ void test_usbh_init_ok(void)
for (uint8_t i=0; i<CFG_TUSB_HOST_DEVICE_MAX+1; i++)
{
TEST_ASSERT_NOT_NULL(usbh_devices[i].control.sem_hdl);
TEST_ASSERT_NOT_NULL(_usbh_devices[i].control.sem_hdl);
}
}
@@ -146,10 +146,10 @@ void test_usbh_hcd_rhport_unplugged_isr_device_not_previously_mounted(void)
{
uint8_t dev_addr = 1;
usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_UNPLUG;
usbh_devices[dev_addr].core_id = 0;
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].core_id = 0;
_usbh_devices[dev_addr].hub_addr = 0;
_usbh_devices[dev_addr].hub_port = 0;
usbh_hcd_rhport_unplugged_isr(0);
}
@@ -158,11 +158,11 @@ void test_usbh_hcd_rhport_unplugged_isr(void)
{
uint8_t dev_addr = 1;
usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
usbh_devices[dev_addr].core_id = 0;
usbh_devices[dev_addr].hub_addr = 0;
usbh_devices[dev_addr].hub_port = 0;
usbh_devices[dev_addr].flag_supported_class = BIT_(TUSB_CLASS_HID);
_usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
_usbh_devices[dev_addr].core_id = 0;
_usbh_devices[dev_addr].hub_addr = 0;
_usbh_devices[dev_addr].hub_port = 0;
_usbh_devices[dev_addr].flag_supported_class = BIT_(TUSB_CLASS_HID);
hidh_close_Expect(dev_addr);
hcd_pipe_control_close_ExpectAndReturn(dev_addr, TUSB_ERROR_NONE);
@@ -170,18 +170,18 @@ void test_usbh_hcd_rhport_unplugged_isr(void)
//------------- Code Under Test -------------//
usbh_hcd_rhport_unplugged_isr(0);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_REMOVING, usbh_devices[dev_addr].state);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_REMOVING, _usbh_devices[dev_addr].state);
}
void test_usbh_device_unplugged_multple_class(void)
{
uint8_t dev_addr = 1;
usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
usbh_devices[dev_addr].core_id = 0;
usbh_devices[dev_addr].hub_addr = 0;
usbh_devices[dev_addr].hub_port = 0;
usbh_devices[dev_addr].flag_supported_class = BIT_(TUSB_CLASS_HID) | BIT_(TUSB_CLASS_MSC) | BIT_(TUSB_CLASS_CDC);
_usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
_usbh_devices[dev_addr].core_id = 0;
_usbh_devices[dev_addr].hub_addr = 0;
_usbh_devices[dev_addr].hub_port = 0;
_usbh_devices[dev_addr].flag_supported_class = BIT_(TUSB_CLASS_HID) | BIT_(TUSB_CLASS_MSC) | BIT_(TUSB_CLASS_CDC);
cdch_close_Expect(dev_addr);
hidh_close_Expect(dev_addr);
@@ -192,7 +192,7 @@ void test_usbh_device_unplugged_multple_class(void)
//------------- Code Under Test -------------//
usbh_hcd_rhport_unplugged_isr(0);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_REMOVING, usbh_devices[dev_addr].state);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_REMOVING, _usbh_devices[dev_addr].state);
}
#endif
@@ -219,7 +219,7 @@ void test_usbh_control_xfer_mutex_failed(void)
};
osal_mutex_wait_StubWithCallback(mutex_wait_failed_stub);
osal_mutex_release_ExpectAndReturn(usbh_devices[dev_addr].control.mutex_hdl, TUSB_ERROR_NONE);
osal_mutex_release_ExpectAndReturn(_usbh_devices[dev_addr].control.mutex_hdl, TUSB_ERROR_NONE);
//------------- Code Under Test -------------//
usbh_control_xfer_subtask(dev_addr, 1, 2, 3, 4, 0, NULL);
@@ -241,7 +241,7 @@ void test_usbh_control_xfer_ok(void)
hcd_pipe_control_xfer_ExpectAndReturn(dev_addr, &a_request, NULL, TUSB_ERROR_NONE);
osal_semaphore_wait_StubWithCallback(semaphore_wait_success_stub);
osal_mutex_release_ExpectAndReturn(usbh_devices[dev_addr].control.mutex_hdl, TUSB_ERROR_NONE);
osal_mutex_release_ExpectAndReturn(_usbh_devices[dev_addr].control.mutex_hdl, TUSB_ERROR_NONE);
//------------- Code Under Test -------------//
usbh_control_xfer_subtask(dev_addr, 1, 2, 3, 4, 0, NULL);

View File

@@ -54,7 +54,7 @@
LPC_USB0_Type lpc_usb0;
LPC_USB1_Type lpc_usb1;
extern usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
extern usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1];
//--------------------------------------------------------------------+
// IMPLEMENTATION
@@ -67,7 +67,7 @@ void ehci_controller_init(void)
void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[])
{
ehci_registers_t* const regs = get_operational_register( usbh_devices[dev_addr].core_id );
ehci_registers_t* const regs = get_operational_register( _usbh_devices[dev_addr].core_id );
ehci_qhd_t * p_qhd = get_control_qhd(dev_addr);
ehci_qtd_t * p_qtd_setup = get_control_qtds(dev_addr);
ehci_qtd_t * p_qtd_data = p_qtd_setup + 1;
@@ -86,7 +86,7 @@ void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[])
regs->usb_sts = EHCI_INT_MASK_NXP_ASYNC | EHCI_INT_MASK_NXP_PERIODIC;
hcd_isr( usbh_devices[dev_addr].core_id );
hcd_isr( _usbh_devices[dev_addr].core_id );
}
void complete_qtd_in_qhd(ehci_qhd_t *p_qhd)