fix bug (wrong logic) with osal_task_delay in non OS configure

complete keyboard app with key state & event TODO handle & check for non-printable(control) keycode
add unit test for osal_task_delay for non OS
This commit is contained in:
hathach
2013-04-27 00:24:15 +07:00
parent 33feba5cbc
commit 8bd077fa5c
5 changed files with 101 additions and 31 deletions
+2 -2
View File
@@ -53,11 +53,11 @@ tusb_keyboard_report_t sample_key[2] =
{
{
.modifier = KEYBOARD_MODIFIER_LEFTCTRL,
.keycode = {KEYBOARD_KEYCODE_a}
.keycode = {4}//{KEYBOARD_KEYCODE_a} TODO ascii to key code table
},
{
.modifier = KEYBOARD_MODIFIER_RIGHTALT,
.keycode = {KEYBOARD_KEYCODE_z}
.keycode = {5}//{KEYBOARD_KEYCODE_z}
}
};
+29 -1
View File
@@ -163,7 +163,7 @@ void test_task_with_semaphore(void)
}
//--------------------------------------------------------------------+
// TASK SEMAPHORE
// TASK QUEUE
//--------------------------------------------------------------------+
tusb_error_t sample_task_with_queue(void)
{
@@ -233,6 +233,34 @@ void test_task_with_queue(void)
TEST_ASSERT_EQUAL(2, statements[0]);
}
//--------------------------------------------------------------------+
// TASK DELAY
//--------------------------------------------------------------------+
tusb_error_t sample_task_with_delay(void)
{
tusb_error_t error;
OSAL_TASK_LOOP_BEGIN
osal_task_delay(1000);
statements[0]++;
OSAL_TASK_LOOP_END
}
void test_task_with_delay(void)
{
sample_task_with_delay();
TEST_ASSERT_EQUAL(0, statements[0]);
for(uint32_t i=0; i<TUSB_CFG_OS_TICKS_PER_SECOND*1000; i++) // not enough time
osal_tick_tock();
sample_task_with_delay();
TEST_ASSERT_EQUAL(1, statements[0]);
}
//--------------------------------------------------------------------+
// TASK FLOW CONTROL
//--------------------------------------------------------------------+