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

Function rt_hwtimer_write

components/drivers/hwtimer/hwtimer.c:200–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200static rt_ssize_t rt_hwtimer_write(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size)
201{
202 rt_base_t level;
203 rt_uint32_t t;
204 rt_hwtimer_mode_t opm = HWTIMER_MODE_PERIOD;
205 rt_hwtimer_t *timer;
206
207 timer = (rt_hwtimer_t *)dev;
208 if ((timer->ops->start == RT_NULL) || (timer->ops->stop == RT_NULL))
209 return 0;
210
211 if (size != sizeof(rt_hwtimerval_t))
212 return 0;
213
214 timer->ops->stop(timer);
215
216 level = rt_hw_interrupt_disable();
217 timer->overflow = 0;
218 rt_hw_interrupt_enable(level);
219
220 t = timeout_calc(timer, (rt_hwtimerval_t*)buffer);
221 if ((timer->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT))
222 {
223 opm = HWTIMER_MODE_ONESHOT;
224 }
225
226 if (timer->ops->start(timer, t, opm) != RT_EOK)
227 size = 0;
228
229 return size;
230}
231
232static rt_err_t rt_hwtimer_control(struct rt_device *dev, int cmd, void *args)
233{

Callers

nothing calls this directly

Calls 4

timeout_calcFunction · 0.85
startMethod · 0.80
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected