|
@@ -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
|
|
#ifdef RT_USING_TIMER_SOFT
|
|
-void rt_soft_timer_tick_hook (void);
|
|
|
|
|
|
+void rt_soft_timer_tick_increase (void);
|
|
#endif
|
|
#endif
|
|
void rt_timer_check()
|
|
void rt_timer_check()
|
|
{
|
|
{
|
|
@@ -405,9 +405,9 @@ void rt_timer_check()
|
|
/* enable interrupt */
|
|
/* enable interrupt */
|
|
rt_hw_interrupt_enable(level);
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
- /**/
|
|
|
|
|
|
+ /* increase soft timer tick */
|
|
#ifdef RT_USING_TIMER_SOFT
|
|
#ifdef RT_USING_TIMER_SOFT
|
|
- rt_soft_timer_tick_hook ( );
|
|
|
|
|
|
+ rt_soft_timer_tick_increase ( );
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef TIMER_DEBUG
|
|
#ifdef TIMER_DEBUG
|
|
@@ -422,19 +422,13 @@ static struct rt_semaphore timer_sem;
|
|
|
|
|
|
static rt_uint16_t timer_ex_cnt;
|
|
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++;
|
|
timer_ex_cnt++;
|
|
if (timer_ex_cnt >= (RT_TICK_PER_SECOND / RT_TIMER_EX_TICKS_PER_SEC))
|
|
if (timer_ex_cnt >= (RT_TICK_PER_SECOND / RT_TIMER_EX_TICKS_PER_SEC))
|
|
{
|
|
{
|
|
timer_ex_cnt = 0;
|
|
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)
|
|
while (1)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ /* take software timer semaphore */
|
|
rt_sem_take(&timer_sem,RT_WAITING_FOREVER);
|
|
rt_sem_take(&timer_sem,RT_WAITING_FOREVER);
|
|
|
|
|
|
-
|
|
|
|
/* lock scheduler */
|
|
/* lock scheduler */
|
|
rt_enter_critical();
|
|
rt_enter_critical();
|
|
|
|
|
|
@@ -534,7 +527,18 @@ void rt_system_timer_init()
|
|
#ifdef RT_USING_TIMER_SOFT
|
|
#ifdef RT_USING_TIMER_SOFT
|
|
rt_list_init(&rt_soft_timer_list);
|
|
rt_list_init(&rt_soft_timer_list);
|
|
rt_sem_init(&timer_sem, "timer", 0, RT_IPC_FLAG_FIFO);
|
|
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 */
|
|
/* start software timer thread */
|
|
rt_thread_init(&timer_thread,
|
|
rt_thread_init(&timer_thread,
|
|
"timer",
|
|
"timer",
|