MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / rt_timer_start

Function rt_timer_start

src/timer.c:562–616  ·  view source on GitHub ↗

* @brief This function will start the timer * * @param timer the timer to be started * * @return the operation status, RT_EOK on OK, -RT_ERROR on error */

Source from the content-addressed store, hash-verified

560 * @return the operation status, RT_EOK on OK, -RT_ERROR on error
561 */
562rt_err_t rt_timer_start(rt_timer_t timer)
563{
564 rt_sched_lock_level_t slvl;
565 int is_thread_timer = 0;
566 struct rt_spinlock *spinlock;
567 rt_list_t *timer_list;
568 rt_base_t level;
569 rt_err_t err;
570
571 /* parameter check */
572 RT_ASSERT(timer != RT_NULL);
573 RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
574
575#ifdef RT_USING_TIMER_ALL_SOFT
576 timer_list = _soft_timer_list;
577 spinlock = &_stimer_lock;
578#else
579#ifdef RT_USING_TIMER_SOFT
580 if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
581 {
582 timer_list = _soft_timer_list;
583 spinlock = &_stimer_lock;
584 }
585 else
586#endif /* RT_USING_TIMER_SOFT */
587 {
588 timer_list = _timer_list;
589 spinlock = &_htimer_lock;
590 }
591#endif
592
593 if (timer->parent.flag & RT_TIMER_FLAG_THREAD_TIMER)
594 {
595 rt_thread_t thread;
596 is_thread_timer = 1;
597 rt_sched_lock(&slvl);
598
599 thread = rt_container_of(timer, struct rt_thread, thread_timer);
600 RT_ASSERT(rt_object_get_type(&thread->parent) == RT_Object_Class_Thread);
601 rt_sched_thread_timer_start(thread);
602 }
603
604 level = rt_spin_lock_irqsave(spinlock);
605
606 err = _timer_start(timer_list, timer);
607
608 rt_spin_unlock_irqrestore(spinlock, level);
609
610 if (is_thread_timer)
611 {
612 rt_sched_unlock(slvl);
613 }
614
615 return err;
616}
617RTM_EXPORT(rt_timer_start);
618
619/**

Callers 15

_rndis_set_responseFunction · 0.85
_do_send_recv_timeoutFunction · 0.85
sys_rt_timer_startFunction · 0.85
rt_can_openFunction · 0.85
rt_led_set_stateFunction · 0.85
sdhci_start_timerFunction · 0.85
netif_is_readyFunction · 0.85
netif_set_connectedFunction · 0.85
rt_lptimer_startFunction · 0.85

Calls 7

rt_object_get_typeFunction · 0.85
rt_sched_lockFunction · 0.70
rt_spin_lock_irqsaveFunction · 0.70
_timer_startFunction · 0.70
rt_sched_unlockFunction · 0.70