提交 8f90e129 编写于 作者: B bernard.xiong

clean up software timer code.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@222 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 9c4ff0c1
......@@ -107,6 +107,10 @@ rt_inline rt_err_t rt_ipc_object_suspend(struct rt_ipc_object *ipc, struct rt_th
break;
}
}
/* not found a suitable position, append to the end of suspend_thread list */
if (n == &(ipc->suspend_thread))
rt_list_insert_before(&(ipc->suspend_thread), &(thread->tlist));
}
break;
}
......
......@@ -344,7 +344,7 @@ rt_err_t rt_timer_control(rt_timer_t timer, rt_uint8_t cmd, void* arg)
*
*/
#ifdef RT_USING_TIMER_SOFT
void rt_soft_timer_tick_hook (void);
void rt_soft_timer_tick_increase (void);
#endif
void rt_timer_check()
{
......@@ -405,9 +405,9 @@ void rt_timer_check()
/* enable interrupt */
rt_hw_interrupt_enable(level);
/**/
/* increase soft timer tick */
#ifdef RT_USING_TIMER_SOFT
rt_soft_timer_tick_hook ( );
rt_soft_timer_tick_increase ( );
#endif
#ifdef TIMER_DEBUG
......@@ -422,19 +422,13 @@ static struct rt_semaphore timer_sem;
static rt_uint16_t timer_ex_cnt;
rt_err_t timer_signal (void)
{
return rt_sem_release(&timer_sem);
}
void rt_soft_timer_tick_hook (void)
void rt_soft_timer_tick_increase (void)
{
timer_ex_cnt++;
if (timer_ex_cnt >= (RT_TICK_PER_SECOND / RT_TIMER_EX_TICKS_PER_SEC))
{
timer_ex_cnt = 0;
timer_signal();
rt_sem_release(&timer_sem);
}
}
......@@ -505,10 +499,9 @@ static void rt_thread_timer_entry(void* parameter)
{
while (1)
{
/* take software timer semaphore */
rt_sem_take(&timer_sem,RT_WAITING_FOREVER);
/* lock scheduler */
rt_enter_critical();
......@@ -534,7 +527,18 @@ void rt_system_timer_init()
#ifdef RT_USING_TIMER_SOFT
rt_list_init(&rt_soft_timer_list);
rt_sem_init(&timer_sem, "timer", 0, RT_IPC_FLAG_FIFO);
#endif
}
/**
* @ingroup SystemInit
*
* This function will init system timer thread
*
*/
void rt_system_timer_thread_init()
{
#ifdef RT_USING_TIMER_SOFT
/* start software timer thread */
rt_thread_init(&timer_thread,
"timer",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册