参考代码

This commit is contained in:
LokLiang
2024-03-28 12:19:52 +08:00
commit 7b86aa3362
96 changed files with 19986 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include "os_test.h"
void os_test_sleep(uint TestTime)
{
vuint start_tick;
vuint test_tick;
int offset;
SYS_LOG_INF("测试延时");
SYS_LOG_DBG("测试 os_thread_sleep()");
os_thread_sleep(1);
start_tick = os_get_sys_ticks();
os_thread_sleep(10);
test_tick = os_get_sys_ticks();
offset = test_tick - start_tick;
SYS_ASSERT_FALSE(offset != 10 && offset != 11, "offset = %d", offset);
SYS_LOG_DBG("测试 os_thread_sleep_until()");
os_thread_sleep(1);
start_tick = os_get_sys_ticks();
os_thread_sleep(30);
test_tick = os_get_sys_ticks();
offset = test_tick - start_tick;
SYS_ASSERT_FALSE(offset < 30 || offset > 31, "offset = %d", offset); //使用软件测试时允许有1毫秒的误差
}