change osal_timeout_t to uint32_t
implement osal_tick_get & osal_tick_tock for osal_none implement timeout for osal_semaphore_wait
This commit is contained in:
@@ -126,7 +126,7 @@ usbh_enumerate_t enum_connect =
|
||||
.connect_status = 1
|
||||
};
|
||||
|
||||
void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, osal_timeout_t msec, tusb_error_t *p_error, int num_call)
|
||||
void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_PTR(enumeration_queue_hdl, queue_hdl);
|
||||
memcpy(p_data, &enum_connect, 4);
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
#define TUSB_CFG_DEBUG 3
|
||||
|
||||
#define TUSB_CFG_OS TUSB_OS_NONE
|
||||
#define TUSB_CFG_OS_TICK_PER_SECOND 1000 // 1 ms tick
|
||||
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000 // 1 ms tick
|
||||
|
||||
#ifdef __CODE_RED // make use of code red's support for ram region macros
|
||||
#if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX)
|
||||
|
||||
@@ -123,15 +123,18 @@ void sample_task_semaphore(void)
|
||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
statements[3]++;
|
||||
|
||||
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)
|
||||
{
|
||||
uint32_t i;
|
||||
// several invoke before sempahore is available
|
||||
for(i=0; i<10; i++)
|
||||
for(uint32_t i=0; i<10; i++)
|
||||
sample_task_semaphore();
|
||||
TEST_ASSERT_EQUAL(1, statements[0]);
|
||||
|
||||
@@ -148,7 +151,12 @@ void test_task_with_semaphore(void)
|
||||
TEST_ASSERT_EQUAL(1, statements[3]);
|
||||
|
||||
// timeout
|
||||
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 ; i++) // not enough time
|
||||
osal_tick_tock();
|
||||
sample_task_semaphore();
|
||||
TEST_ASSERT_EQUAL(0, statements[4]);
|
||||
osal_tick_tock();
|
||||
sample_task_semaphore();
|
||||
|
||||
// reach end of task loop, back to beginning
|
||||
sample_task_semaphore();
|
||||
|
||||
Reference in New Issue
Block a user