1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <rtthread.h>
static rt_thread_t timer1; static rt_thread_t timer2;
static void timerout1(void *paramer){ rt_kprintf("one_shot timeout"); }
static void timerout2(void *paramer){ rt_kprintf("periodic timeout"); }
int main(void) { timer1 = rt_timer_create("timer1", timerout1, RT_NULL, 100, RT_TIMER_FLAG_PERIODIC);
if(timer1 != RT_NULL) rt_timer_start(timer1);
timer2 = rt_timer_create("timer2", timerout2, RT_NULL, 100, RT_TIMER_FLAG_ONE_SHOT);
if(timer2 != RT_NULL) rt_timer_start(timer2);
return 0; }
|