MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ktime_hrtimer_settimeout

Function rt_ktime_hrtimer_settimeout

components/drivers/ktime/src/hrtimer.c:46–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46rt_weak rt_err_t rt_ktime_hrtimer_settimeout(unsigned long cnt)
47{
48 static rt_timer_t timer = RT_NULL;
49 static struct rt_timer _sh_rtimer;
50
51 RT_ASSERT(cnt > 0);
52
53 if (timer == RT_NULL)
54 {
55 timer = &_sh_rtimer;
56 rt_timer_init(timer, "shrtimer", (void (*)(void *))rt_ktime_hrtimer_process, RT_NULL, cnt, RT_TIMER_FLAG_ONE_SHOT);
57 }
58 else
59 {
60 rt_tick_t tick = cnt;
61 rt_timer_control(timer, RT_TIMER_CTRL_SET_TIME, &tick);
62 rt_timer_control(timer, RT_TIMER_CTRL_SET_PARM, RT_NULL);
63 }
64
65 if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
66 {
67 rt_timer_stop(timer);
68 }
69
70 rt_timer_start(timer);
71 return RT_EOK;
72}
73
74/**
75 * @brief convert cnt from cputimer cnt to hrtimer cnt

Callers 1

_set_next_timeout_lockedFunction · 0.70

Calls 4

rt_timer_initFunction · 0.85
rt_timer_controlFunction · 0.85
rt_timer_stopFunction · 0.85
rt_timer_startFunction · 0.85

Tested by

no test coverage detected