refine OSAL_TASK_LOOP_BEGIN & OSAL_TASK_LOOP_END
- add TASK_ASSERT & TASK_ASSERT_STATUS add more code for enumerate task add control requests & its type def add API for HCD - hcd_pipe_addr0_open - hcd_pipe_control_open - hcd_pipe_control_xfer - hcd_pipe_open - hcd_port_speed
This commit is contained in:
@@ -46,7 +46,7 @@ tusb_handle_device_t dev_hdl;
|
||||
void setUp(void)
|
||||
{
|
||||
dev_hdl = 0;
|
||||
device_info_pool[dev_hdl].status = TUSB_DEVICE_STATUS_READY;
|
||||
memset(device_info_pool, 0, TUSB_CFG_HOST_DEVICE_MAX*sizeof(usbh_device_info_t));
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
@@ -133,10 +133,60 @@ void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uin
|
||||
(*p_error) = TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
tusb_error_t pipe_control_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t * const p_request, uint8_t data[], int num_call)
|
||||
{
|
||||
tusb_descriptor_device_t dev_desc =
|
||||
{
|
||||
.bLength = sizeof(tusb_descriptor_device_t),
|
||||
.bDescriptorType = TUSB_DESC_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = 0x00,
|
||||
.bDeviceSubClass = 0x00,
|
||||
.bDeviceProtocol = 0x00,
|
||||
|
||||
.bMaxPacketSize0 = 64,
|
||||
|
||||
.idVendor = 0x1FC9,
|
||||
.idProduct = 0x4000,
|
||||
.bcdDevice = 0x0100,
|
||||
|
||||
.iManufacturer = 0x01,
|
||||
.iProduct = 0x02,
|
||||
.iSerialNumber = 0x03,
|
||||
|
||||
.bNumConfigurations = 0x02
|
||||
};
|
||||
|
||||
if (p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR)
|
||||
{
|
||||
switch (p_request->wValue >> 8)
|
||||
{
|
||||
case TUSB_DESC_DEVICE:
|
||||
memcpy(data, &dev_desc, p_request->wLength);
|
||||
break;
|
||||
|
||||
default:
|
||||
TEST_FAIL();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
void test_enum_task_connect(void)
|
||||
{
|
||||
pipe_handle_t pipe_addr0 = 12;
|
||||
|
||||
|
||||
|
||||
osal_queue_receive_StubWithCallback(queue_recv_stub);
|
||||
hcd_port_connect_status_ExpectAndReturn(enum_connect.core_id, true);
|
||||
hcd_port_speed_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL);
|
||||
hcd_pipe_addr0_open_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL, 0, 0, pipe_addr0);
|
||||
|
||||
hcd_pipe_control_xfer_StubWithCallback(pipe_control_stub);
|
||||
// hcd_pipe_control_open_ExpectAnd(1, );
|
||||
|
||||
usbh_enumeration_task();
|
||||
}
|
||||
|
||||
+28
-33
@@ -108,27 +108,25 @@ void test_queue_send(void)
|
||||
void sample_task_semaphore(void)
|
||||
{
|
||||
tusb_error_t error = TUSB_ERROR_NONE;
|
||||
OSAL_TASK_LOOP
|
||||
{
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
statements[0]++;
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[1]++;
|
||||
statements[0]++;
|
||||
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[2]++;
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[1]++;
|
||||
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[3]++;
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[2]++;
|
||||
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
||||
statements[4]++;
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, error);
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[3]++;
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
||||
statements[4]++;
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, error);
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
|
||||
void test_task_with_semaphore(void)
|
||||
@@ -168,30 +166,27 @@ void sample_task_with_queue(void)
|
||||
uint32_t data;
|
||||
tusb_error_t error;
|
||||
|
||||
OSAL_TASK_LOOP
|
||||
{
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
statements[0]++;
|
||||
statements[0]++;
|
||||
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
TEST_ASSERT_EQUAL(0x1111, data);
|
||||
statements[1]++;
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
TEST_ASSERT_EQUAL(0x1111, data);
|
||||
statements[1]++;
|
||||
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
TEST_ASSERT_EQUAL(0x2222, data);
|
||||
statements[2]++;
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
TEST_ASSERT_EQUAL(0x2222, data);
|
||||
statements[2]++;
|
||||
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
TEST_ASSERT_EQUAL(0x3333, data);
|
||||
statements[3]++;
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
TEST_ASSERT_EQUAL(0x3333, data);
|
||||
statements[3]++;
|
||||
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_NORMAL, &error);
|
||||
statements[4]++;
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, error);
|
||||
osal_queue_receive(queue_hdl, &data, OSAL_TIMEOUT_NORMAL, &error);
|
||||
statements[4]++;
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, error);
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
|
||||
void test_task_with_queue(void)
|
||||
|
||||
Reference in New Issue
Block a user