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

Function rt_timer_stop

src/timer.c:626–653  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

624 * @return the operation status, RT_EOK on OK, -RT_ERROR on error
625 */
626rt_err_t rt_timer_stop(rt_timer_t timer)
627{
628 rt_base_t level;
629 struct rt_spinlock *spinlock;
630
631 /* timer check */
632 RT_ASSERT(timer != RT_NULL);
633 RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
634
635 spinlock = _timerlock_idx(timer);
636
637 level = rt_spin_lock_irqsave(spinlock);
638
639 if (!(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED))
640 {
641 rt_spin_unlock_irqrestore(spinlock, level);
642 return -RT_ERROR;
643 }
644 RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(timer->parent)));
645
646 _timer_remove(timer);
647 /* change status */
648 timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
649
650 rt_spin_unlock_irqrestore(spinlock, level);
651
652 return RT_EOK;
653}
654RTM_EXPORT(rt_timer_stop);
655
656/**

Callers 15

_function_enableFunction · 0.85
_function_disableFunction · 0.85
sys_rt_timer_stopFunction · 0.85
rt_can_closeFunction · 0.85
rt_led_set_stateFunction · 0.85
sdhci_del_timerFunction · 0.85
sdhci_start_timerFunction · 0.85
netif_is_readyFunction · 0.85
netif_set_connectedFunction · 0.85
rt_lptimer_stopFunction · 0.85
soft_rtc_alarm_updateFunction · 0.85

Calls 5

rt_object_get_typeFunction · 0.85
_timerlock_idxFunction · 0.85
_timer_removeFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.70

Tested by 1

test_timer_stressFunction · 0.68