diff options
| author | WBI\nxf44444 <[email protected]> | 2022-01-26 01:43:05 +0800 |
|---|---|---|
| committer | WBI\nxf44444 <[email protected]> | 2022-01-26 01:43:05 +0800 |
| commit | 8b0f50b7e211ee32ab08ba085ecd74588c3a3c63 (patch) | |
| tree | 75440be5ecd30cc1403a9387851c0530ed057981 /examples/kernel/timer_timeout.c | |
| parent | 3be35fecae513b07c35bd6f3992bf7824434bdd6 (diff) | |
| parent | 32a5668593c578b85560338c29d76f3a252c8dbc (diff) | |
Update i2c driver, add read ACK and BUS status check
Diffstat (limited to 'examples/kernel/timer_timeout.c')
| -rw-r--r-- | examples/kernel/timer_timeout.c | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/examples/kernel/timer_timeout.c b/examples/kernel/timer_timeout.c deleted file mode 100644 index d1a7099e2e..0000000000 --- a/examples/kernel/timer_timeout.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * �����嵥����Ϣ�������� - * - * �������ᴴ��3����̬�̣߳�һ���̻߳����Ϣ��������ȡ��Ϣ��һ���̻߳ᶨʱ���� - * Ϣ���з�����Ϣ��һ���̻߳ᶨʱ����Ϣ���з��ͽ�����Ϣ�� - */ -#include <rtthread.h> -#include "tc_comm.h" - -/* ָ���߳̿��ƿ��ָ�� */ -static rt_thread_t tid = RT_NULL; - -/* ��Ϣ���п��ƿ� */ -static struct rt_messagequeue mq; -/* ��Ϣ�������õ��ķ�����Ϣ���ڴ�� */ -static char msg_pool[2048]; - -/* ��ʱ���Ŀ��ƿ� */ -static struct rt_timer timer; -static rt_uint16_t no = 0; -static void timer_timeout(void* parameter) -{ - char buf[32]; - rt_uint32_t length; - - length = rt_snprintf(buf, sizeof(buf), "message %d", no++); - rt_mq_send(&mq, &buf[0], length); -} - -/* �߳���ں��� */ -static void thread_entry(void* parameter) -{ - char buf[64]; - rt_err_t result; - - /* ��ʼ����ʱ�� */ - rt_timer_init(&timer, "timer", /* ��ʱ�������� timer1 */ - timer_timeout, /* ��ʱʱ�ص��Ĵ������� */ - RT_NULL, /* ��ʱ��������ڲ��� */ - 1, /* ��ʱ���ȣ���OS TickΪ��λ����1��OS Tick */ - RT_TIMER_FLAG_PERIODIC); /* �����Զ�ʱ�� */ - - while (1) - { - rt_memset(&buf[0], 0, sizeof(buf)); - - /* ����Ϣ�����н�����Ϣ */ - result = rt_mq_recv(&mq, &buf[0], sizeof(buf), 1); - if (result == RT_EOK) - { - rt_kprintf("recv msg: %s\n", buf); - } - else if (result == -RT_ETIMEOUT) - { - rt_kprintf("recv msg timeout\n"); - } - } -} - -int timer_timeout_init() -{ - /* ��ʼ����Ϣ���� */ - rt_mq_init(&mq, "mqt", - &msg_pool[0], /* �ڴ��ָ��msg_pool */ - 128 - sizeof(void*), /* ÿ����Ϣ�Ĵ�С�� 128 - void* */ - sizeof(msg_pool), /* �ڴ�صĴ�С��msg_pool�Ĵ�С */ - RT_IPC_FLAG_FIFO); /* ����ж���̵߳ȴ������������ȵõ��ķ���������Ϣ */ - - /* �����߳� */ - tid = rt_thread_create("t", - thread_entry, RT_NULL, /* �߳������thread_entry, ��ڲ�����RT_NULL */ - THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE); - if (tid != RT_NULL) - rt_thread_startup(tid); - else - tc_stat(TC_STAT_END | TC_STAT_FAILED); - - return 0; -} - -#ifdef RT_USING_TC -static void _tc_cleanup() -{ - /* �����������������������л��������̣߳�����Ӧ�ж� */ - rt_enter_critical(); - - /* ɾ���߳� */ - if (tid != RT_NULL && tid->stat != RT_THREAD_CLOSE) - rt_thread_delete(tid); - - /* ִ����Ϣ���ж������� */ - rt_mq_detach(&mq); - /* ִ�ж�ʱ������ */ - rt_timer_detach(&timer); - - /* ���������� */ - rt_exit_critical(); - - /* ����TestCase״̬ */ - tc_done(TC_STAT_PASSED); -} - -int _tc_timer_timeout() -{ - /* ����TestCase�����ص����� */ - tc_cleanup(_tc_cleanup); - timer_timeout_init(); - - /* ����TestCase���е��ʱ�� */ - return 100; -} -/* ����������finsh shell�� */ -FINSH_FUNCTION_EXPORT(_tc_timer_timeout, a thread timer testcase); -#else -/* �û�Ӧ����� */ -int rt_application_init() -{ - timer_timeout_init(); - - return 0; -} -#endif |
