timer.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*
  2. * File : timer.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2006-03-12 Bernard first version
  23. * 2006-04-29 Bernard implement thread timer
  24. * 2006-06-04 Bernard implement rt_timer_control
  25. * 2006-08-10 Bernard fix the periodic timer bug
  26. * 2006-09-03 Bernard implement rt_timer_detach
  27. * 2009-11-11 LiJin add soft timer
  28. * 2010-05-12 Bernard fix the timer check bug.
  29. * 2010-11-02 Charlie re-implement tick overflow issue
  30. * 2012-12-15 Bernard fix the next timeout issue in soft timer
  31. */
  32. #include <rtthread.h>
  33. #include <rthw.h>
  34. /* hard timer list */
  35. static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
  36. #ifdef RT_USING_TIMER_SOFT
  37. #ifndef RT_TIMER_THREAD_STACK_SIZE
  38. #define RT_TIMER_THREAD_STACK_SIZE 512
  39. #endif
  40. #ifndef RT_TIMER_THREAD_PRIO
  41. #define RT_TIMER_THREAD_PRIO 0
  42. #endif
  43. /* soft timer list */
  44. static rt_list_t rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
  45. static struct rt_thread timer_thread;
  46. ALIGN(RT_ALIGN_SIZE)
  47. static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
  48. #endif
  49. #ifdef RT_USING_HOOK
  50. extern void (*rt_object_take_hook)(struct rt_object *object);
  51. extern void (*rt_object_put_hook)(struct rt_object *object);
  52. static void (*rt_timer_timeout_hook)(struct rt_timer *timer);
  53. /**
  54. * @addtogroup Hook
  55. */
  56. /*@{*/
  57. /**
  58. * This function will set a hook function, which will be invoked when timer
  59. * is timeout.
  60. *
  61. * @param hook the hook function
  62. */
  63. void rt_timer_timeout_sethook(void (*hook)(struct rt_timer *timer))
  64. {
  65. rt_timer_timeout_hook = hook;
  66. }
  67. /*@}*/
  68. #endif
  69. static void _rt_timer_init(rt_timer_t timer,
  70. void (*timeout)(void *parameter),
  71. void *parameter,
  72. rt_tick_t time,
  73. rt_uint8_t flag)
  74. {
  75. int i;
  76. /* set flag */
  77. timer->parent.flag = flag;
  78. /* set deactivated */
  79. timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
  80. timer->timeout_func = timeout;
  81. timer->parameter = parameter;
  82. timer->timeout_tick = 0;
  83. timer->init_tick = time;
  84. /* initialize timer list */
  85. for (i = 0; i < RT_TIMER_SKIP_LIST_LEVEL; i++)
  86. {
  87. rt_list_init(&(timer->row[i]));
  88. }
  89. }
  90. /* the fist timer always in the last row */
  91. static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[])
  92. {
  93. struct rt_timer *timer;
  94. if (rt_list_isempty(&timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
  95. return RT_TICK_MAX;
  96. timer = rt_list_entry(timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
  97. struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
  98. return timer->timeout_tick;
  99. }
  100. rt_inline void _rt_timer_remove(rt_timer_t timer)
  101. {
  102. int i;
  103. for (i = 0; i < RT_TIMER_SKIP_LIST_LEVEL; i++)
  104. {
  105. rt_list_remove(&timer->row[i]);
  106. }
  107. }
  108. static int rt_timer_count_height(struct rt_timer *timer)
  109. {
  110. int i, cnt = 0;
  111. for (i = 0; i < RT_TIMER_SKIP_LIST_LEVEL; i++)
  112. {
  113. if (!rt_list_isempty(&timer->row[i]))
  114. cnt++;
  115. }
  116. return cnt;
  117. }
  118. void rt_timer_dump(rt_list_t timer_heads[])
  119. {
  120. rt_list_t *list;
  121. for (list = timer_heads[RT_TIMER_SKIP_LIST_LEVEL-1].next;
  122. list != &timer_heads[RT_TIMER_SKIP_LIST_LEVEL-1];
  123. list = list->next)
  124. {
  125. struct rt_timer *timer = rt_list_entry(list,
  126. struct rt_timer,
  127. row[RT_TIMER_SKIP_LIST_LEVEL-1]);
  128. rt_kprintf("%d", rt_timer_count_height(timer));
  129. }
  130. rt_kprintf("\n");
  131. }
  132. /**
  133. * @addtogroup Clock
  134. */
  135. /*@{*/
  136. /**
  137. * This function will initialize a timer, normally this function is used to
  138. * initialize a static timer object.
  139. *
  140. * @param timer the static timer object
  141. * @param name the name of timer
  142. * @param timeout the timeout function
  143. * @param parameter the parameter of timeout function
  144. * @param time the tick of timer
  145. * @param flag the flag of timer
  146. */
  147. void rt_timer_init(rt_timer_t timer,
  148. const char *name,
  149. void (*timeout)(void *parameter),
  150. void *parameter,
  151. rt_tick_t time,
  152. rt_uint8_t flag)
  153. {
  154. /* timer check */
  155. RT_ASSERT(timer != RT_NULL);
  156. /* timer object initialization */
  157. rt_object_init((rt_object_t)timer, RT_Object_Class_Timer, name);
  158. _rt_timer_init(timer, timeout, parameter, time, flag);
  159. }
  160. RTM_EXPORT(rt_timer_init);
  161. /**
  162. * This function will detach a timer from timer management.
  163. *
  164. * @param timer the static timer object
  165. *
  166. * @return the operation status, RT_EOK on OK; RT_ERROR on error
  167. */
  168. rt_err_t rt_timer_detach(rt_timer_t timer)
  169. {
  170. register rt_base_t level;
  171. /* timer check */
  172. RT_ASSERT(timer != RT_NULL);
  173. /* disable interrupt */
  174. level = rt_hw_interrupt_disable();
  175. _rt_timer_remove(timer);
  176. /* enable interrupt */
  177. rt_hw_interrupt_enable(level);
  178. rt_object_detach((rt_object_t)timer);
  179. return -RT_EOK;
  180. }
  181. RTM_EXPORT(rt_timer_detach);
  182. #ifdef RT_USING_HEAP
  183. /**
  184. * This function will create a timer
  185. *
  186. * @param name the name of timer
  187. * @param timeout the timeout function
  188. * @param parameter the parameter of timeout function
  189. * @param time the tick of timer
  190. * @param flag the flag of timer
  191. *
  192. * @return the created timer object
  193. */
  194. rt_timer_t rt_timer_create(const char *name,
  195. void (*timeout)(void *parameter),
  196. void *parameter,
  197. rt_tick_t time,
  198. rt_uint8_t flag)
  199. {
  200. struct rt_timer *timer;
  201. /* allocate a object */
  202. timer = (struct rt_timer *)rt_object_allocate(RT_Object_Class_Timer, name);
  203. if (timer == RT_NULL)
  204. {
  205. return RT_NULL;
  206. }
  207. _rt_timer_init(timer, timeout, parameter, time, flag);
  208. return timer;
  209. }
  210. RTM_EXPORT(rt_timer_create);
  211. /**
  212. * This function will delete a timer and release timer memory
  213. *
  214. * @param timer the timer to be deleted
  215. *
  216. * @return the operation status, RT_EOK on OK; RT_ERROR on error
  217. */
  218. rt_err_t rt_timer_delete(rt_timer_t timer)
  219. {
  220. register rt_base_t level;
  221. /* timer check */
  222. RT_ASSERT(timer != RT_NULL);
  223. /* disable interrupt */
  224. level = rt_hw_interrupt_disable();
  225. _rt_timer_remove(timer);
  226. /* enable interrupt */
  227. rt_hw_interrupt_enable(level);
  228. rt_object_delete((rt_object_t)timer);
  229. return -RT_EOK;
  230. }
  231. RTM_EXPORT(rt_timer_delete);
  232. #endif
  233. /**
  234. * This function will start the timer
  235. *
  236. * @param timer the timer to be started
  237. *
  238. * @return the operation status, RT_EOK on OK, -RT_ERROR on error
  239. */
  240. rt_err_t rt_timer_start(rt_timer_t timer)
  241. {
  242. int row_lvl;
  243. rt_list_t *timer_list;
  244. register rt_base_t level;
  245. rt_list_t *row_head[RT_TIMER_SKIP_LIST_LEVEL];
  246. unsigned int tst_nr;
  247. static unsigned int random_nr;
  248. /* timer check */
  249. RT_ASSERT(timer != RT_NULL);
  250. if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
  251. return -RT_ERROR;
  252. RT_OBJECT_HOOK_CALL(rt_object_take_hook, (&(timer->parent)));
  253. /*
  254. * get timeout tick,
  255. * the max timeout tick shall not great than RT_TICK_MAX/2
  256. */
  257. RT_ASSERT(timer->init_tick < RT_TICK_MAX / 2);
  258. timer->timeout_tick = rt_tick_get() + timer->init_tick;
  259. /* disable interrupt */
  260. level = rt_hw_interrupt_disable();
  261. #ifdef RT_USING_TIMER_SOFT
  262. if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
  263. {
  264. /* insert timer to soft timer list */
  265. timer_list = rt_soft_timer_list;
  266. }
  267. else
  268. #endif
  269. {
  270. /* insert timer to system timer list */
  271. timer_list = rt_timer_list;
  272. }
  273. row_head[0] = &timer_list[0];
  274. for (row_lvl = 0; row_lvl < RT_TIMER_SKIP_LIST_LEVEL; row_lvl++)
  275. {
  276. for (;row_head[row_lvl] != timer_list[row_lvl].prev;
  277. row_head[row_lvl] = row_head[row_lvl]->next)
  278. {
  279. struct rt_timer *t;
  280. rt_list_t *p = row_head[row_lvl]->next;
  281. /* fix up the entry pointer */
  282. t = rt_list_entry(p, struct rt_timer, row[row_lvl]);
  283. /* If we have two timers that timeout at the same time, it's
  284. * preferred that the timer inserted early get called early.
  285. * So insert the new timer to the end the the some-timeout timer
  286. * list.
  287. */
  288. if ((t->timeout_tick - timer->timeout_tick) == 0)
  289. {
  290. continue;
  291. }
  292. else if ((t->timeout_tick - timer->timeout_tick) < RT_TICK_MAX / 2)
  293. {
  294. break;
  295. }
  296. }
  297. if (row_lvl != RT_TIMER_SKIP_LIST_LEVEL - 1)
  298. row_head[row_lvl+1] = row_head[row_lvl]+1;
  299. }
  300. /* Interestingly, this super simple timer insert counter works very very
  301. * well on distributing the list height uniformly. By means of "very very
  302. * well", I mean it beats the randomness of timer->timeout_tick very easily
  303. * (actually, the timeout_tick is not random and easy to be attacked). */
  304. random_nr++;
  305. tst_nr = random_nr;
  306. rt_list_insert_after(row_head[RT_TIMER_SKIP_LIST_LEVEL-1],
  307. &(timer->row[RT_TIMER_SKIP_LIST_LEVEL-1]));
  308. for (row_lvl = 2; row_lvl <= RT_TIMER_SKIP_LIST_LEVEL; row_lvl++)
  309. {
  310. if (!(tst_nr & RT_TIMER_SKIP_LIST_MASK))
  311. rt_list_insert_after(row_head[RT_TIMER_SKIP_LIST_LEVEL - row_lvl],
  312. &(timer->row[RT_TIMER_SKIP_LIST_LEVEL - row_lvl]));
  313. else
  314. break;
  315. /* Shift over the bits we have tested. Works well with 1 bit and 2
  316. * bits. */
  317. tst_nr >>= (RT_TIMER_SKIP_LIST_MASK+1)>>1;
  318. }
  319. timer->parent.flag |= RT_TIMER_FLAG_ACTIVATED;
  320. /* enable interrupt */
  321. rt_hw_interrupt_enable(level);
  322. #ifdef RT_USING_TIMER_SOFT
  323. if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
  324. {
  325. /* check whether timer thread is ready */
  326. if (timer_thread.stat != RT_THREAD_READY)
  327. {
  328. /* resume timer thread to check soft timer */
  329. rt_thread_resume(&timer_thread);
  330. rt_schedule();
  331. }
  332. }
  333. #endif
  334. return -RT_EOK;
  335. }
  336. RTM_EXPORT(rt_timer_start);
  337. /**
  338. * This function will stop the timer
  339. *
  340. * @param timer the timer to be stopped
  341. *
  342. * @return the operation status, RT_EOK on OK, -RT_ERROR on error
  343. */
  344. rt_err_t rt_timer_stop(rt_timer_t timer)
  345. {
  346. register rt_base_t level;
  347. /* timer check */
  348. RT_ASSERT(timer != RT_NULL);
  349. if (!(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED))
  350. return -RT_ERROR;
  351. RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(timer->parent)));
  352. /* disable interrupt */
  353. level = rt_hw_interrupt_disable();
  354. _rt_timer_remove(timer);
  355. /* enable interrupt */
  356. rt_hw_interrupt_enable(level);
  357. /* change stat */
  358. timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
  359. return RT_EOK;
  360. }
  361. RTM_EXPORT(rt_timer_stop);
  362. /**
  363. * This function will get or set some options of the timer
  364. *
  365. * @param timer the timer to be get or set
  366. * @param cmd the control command
  367. * @param arg the argument
  368. *
  369. * @return RT_EOK
  370. */
  371. rt_err_t rt_timer_control(rt_timer_t timer, rt_uint8_t cmd, void *arg)
  372. {
  373. /* timer check */
  374. RT_ASSERT(timer != RT_NULL);
  375. switch (cmd)
  376. {
  377. case RT_TIMER_CTRL_GET_TIME:
  378. *(rt_tick_t *)arg = timer->init_tick;
  379. break;
  380. case RT_TIMER_CTRL_SET_TIME:
  381. timer->init_tick = *(rt_tick_t *)arg;
  382. break;
  383. case RT_TIMER_CTRL_SET_ONESHOT:
  384. timer->parent.flag &= ~RT_TIMER_FLAG_PERIODIC;
  385. break;
  386. case RT_TIMER_CTRL_SET_PERIODIC:
  387. timer->parent.flag |= RT_TIMER_FLAG_PERIODIC;
  388. break;
  389. }
  390. return RT_EOK;
  391. }
  392. RTM_EXPORT(rt_timer_control);
  393. /**
  394. * This function will check timer list, if a timeout event happens, the
  395. * corresponding timeout function will be invoked.
  396. *
  397. * @note this function shall be invoked in operating system timer interrupt.
  398. */
  399. void rt_timer_check(void)
  400. {
  401. struct rt_timer *t;
  402. rt_tick_t current_tick;
  403. register rt_base_t level;
  404. RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check enter\n"));
  405. current_tick = rt_tick_get();
  406. /* disable interrupt */
  407. level = rt_hw_interrupt_disable();
  408. while (!rt_list_isempty(&rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1]))
  409. {
  410. t = rt_list_entry(rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
  411. struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
  412. /*
  413. * It supposes that the new tick shall less than the half duration of
  414. * tick max.
  415. */
  416. if ((current_tick - t->timeout_tick) < RT_TICK_MAX/2)
  417. {
  418. RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));
  419. /* remove timer from timer list firstly */
  420. _rt_timer_remove(t);
  421. /* call timeout function */
  422. t->timeout_func(t->parameter);
  423. /* re-get tick */
  424. current_tick = rt_tick_get();
  425. RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
  426. if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
  427. (t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
  428. {
  429. /* start it */
  430. t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
  431. rt_timer_start(t);
  432. }
  433. else
  434. {
  435. /* stop timer */
  436. t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
  437. }
  438. }
  439. else
  440. break;
  441. }
  442. /* enable interrupt */
  443. rt_hw_interrupt_enable(level);
  444. RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check leave\n"));
  445. }
  446. /**
  447. * This function will return the next timeout tick in the system.
  448. *
  449. * @return the next timeout tick in the system
  450. */
  451. rt_tick_t rt_timer_next_timeout_tick(void)
  452. {
  453. return rt_timer_list_next_timeout(rt_timer_list);
  454. }
  455. #ifdef RT_USING_TIMER_SOFT
  456. /**
  457. * This function will check timer list, if a timeout event happens, the
  458. * corresponding timeout function will be invoked.
  459. */
  460. void rt_soft_timer_check(void)
  461. {
  462. rt_tick_t current_tick;
  463. rt_list_t *n;
  464. struct rt_timer *t;
  465. RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check enter\n"));
  466. current_tick = rt_tick_get();
  467. for (n = rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1].next;
  468. n != &(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1]);)
  469. {
  470. t = rt_list_entry(n, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL-1]);
  471. /*
  472. * It supposes that the new tick shall less than the half duration of
  473. * tick max.
  474. */
  475. if ((current_tick - t->timeout_tick) < RT_TICK_MAX / 2)
  476. {
  477. RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));
  478. /* move node to the next */
  479. n = n->next;
  480. /* remove timer from timer list firstly */
  481. _rt_timer_remove(t);
  482. /* call timeout function */
  483. t->timeout_func(t->parameter);
  484. /* re-get tick */
  485. current_tick = rt_tick_get();
  486. RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
  487. if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
  488. (t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
  489. {
  490. /* start it */
  491. t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
  492. rt_timer_start(t);
  493. }
  494. else
  495. {
  496. /* stop timer */
  497. t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
  498. }
  499. }
  500. else break; /* not check anymore */
  501. }
  502. RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n"));
  503. }
  504. /* system timer thread entry */
  505. static void rt_thread_timer_entry(void *parameter)
  506. {
  507. rt_tick_t next_timeout;
  508. while (1)
  509. {
  510. /* get the next timeout tick */
  511. next_timeout = rt_timer_list_next_timeout(rt_soft_timer_list);
  512. if (next_timeout == RT_TICK_MAX)
  513. {
  514. /* no software timer exist, suspend self. */
  515. rt_thread_suspend(rt_thread_self());
  516. rt_schedule();
  517. }
  518. else
  519. {
  520. rt_tick_t current_tick;
  521. /* get current tick */
  522. current_tick = rt_tick_get();
  523. if ((next_timeout - current_tick) < RT_TICK_MAX/2)
  524. {
  525. /* get the delta timeout tick */
  526. next_timeout = next_timeout - current_tick;
  527. rt_thread_delay(next_timeout);
  528. }
  529. }
  530. /* lock scheduler */
  531. rt_enter_critical();
  532. /* check software timer */
  533. rt_soft_timer_check();
  534. /* unlock scheduler */
  535. rt_exit_critical();
  536. }
  537. }
  538. #endif
  539. /**
  540. * @ingroup SystemInit
  541. *
  542. * This function will initialize system timer
  543. */
  544. void rt_system_timer_init(void)
  545. {
  546. int i;
  547. for (i = 0; i < sizeof(rt_timer_list)/sizeof(rt_timer_list[0]); i++)
  548. {
  549. rt_list_init(rt_timer_list+i);
  550. }
  551. }
  552. /**
  553. * @ingroup SystemInit
  554. *
  555. * This function will initialize system timer thread
  556. */
  557. void rt_system_timer_thread_init(void)
  558. {
  559. #ifdef RT_USING_TIMER_SOFT
  560. int i;
  561. for (i = 0;
  562. i < sizeof(rt_soft_timer_list)/sizeof(rt_soft_timer_list[0]);
  563. i++)
  564. {
  565. rt_list_init(rt_soft_timer_list+i);
  566. }
  567. /* start software timer thread */
  568. rt_thread_init(&timer_thread,
  569. "timer",
  570. rt_thread_timer_entry,
  571. RT_NULL,
  572. &timer_thread_stack[0],
  573. sizeof(timer_thread_stack),
  574. RT_TIMER_THREAD_PRIO,
  575. 10);
  576. /* startup */
  577. rt_thread_startup(&timer_thread);
  578. #endif
  579. }
  580. /*@}*/