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

Function rt_cputimer_start

components/drivers/cputime/cputimer.c:126–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126rt_err_t rt_cputimer_start(rt_cputimer_t timer)
127{
128 rt_list_t *timer_list;
129 rt_base_t level;
130
131 /* parameter check */
132 RT_ASSERT(timer != RT_NULL);
133 RT_ASSERT(clock_cpu_issettimeout() != RT_FALSE);
134
135 /* stop timer firstly */
136 level = rt_hw_interrupt_disable();
137 /* remove timer from list */
138
139 rt_list_remove(&timer->row);
140 /* change status of timer */
141 timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
142
143 timer_list = &_cputimer_list;
144
145 for (; timer_list != _cputimer_list.prev;
146 timer_list = timer_list->next)
147 {
148 struct rt_cputimer *t;
149 rt_list_t *p = timer_list->next;
150
151 t = rt_list_entry(p, struct rt_cputimer, row);
152
153 if ((t->timeout_tick - timer->timeout_tick) == 0)
154 {
155 continue;
156 }
157 else if ((t->timeout_tick - timer->timeout_tick) < 0x7fffffffffffffff)
158 {
159 break;
160 }
161 }
162
163 rt_list_insert_after(timer_list, &(timer->row));
164
165 timer->parent.flag |= RT_TIMER_FLAG_ACTIVATED;
166
167 _set_next_timeout();
168 /* enable interrupt */
169 rt_hw_interrupt_enable(level);
170
171 return RT_EOK;
172}
173
174rt_err_t rt_cputimer_stop(rt_cputimer_t timer)
175{

Callers 1

rt_cputime_sleepFunction · 0.85

Calls 6

clock_cpu_issettimeoutFunction · 0.85
rt_list_removeFunction · 0.85
rt_list_insert_afterFunction · 0.85
_set_next_timeoutFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected