Lines Matching full:timer

39 	struct timer_obj *timer;  in zephyr_timer_wrapper()  local
41 timer = (struct timer_obj *)ztimer; in zephyr_timer_wrapper()
43 if (timer->reload == 0U) { in zephyr_timer_wrapper()
44 timer->status = NOT_ACTIVE; in zephyr_timer_wrapper()
45 LOG_DBG("timer %p not active", timer); in zephyr_timer_wrapper()
48 if (timer->evp.sigev_notify == SIGEV_NONE) { in zephyr_timer_wrapper()
53 if (timer->evp.sigev_notify_function == NULL) { in zephyr_timer_wrapper()
58 LOG_DBG("calling sigev_notify_function %p", timer->evp.sigev_notify_function); in zephyr_timer_wrapper()
59 (timer->evp.sigev_notify_function)(timer->evp.sigev_value); in zephyr_timer_wrapper()
65 struct timer_obj *timer = (struct timer_obj *)arg; in zephyr_thread_wrapper() local
70 if (timer->evp.sigev_notify_attributes == NULL) { in zephyr_thread_wrapper()
76 if (timer->reload == 0U) { in zephyr_thread_wrapper()
77 timer->status = NOT_ACTIVE; in zephyr_thread_wrapper()
78 LOG_DBG("timer %p not active", timer); in zephyr_thread_wrapper()
81 ret = k_sem_take(&timer->sem_cond, K_FOREVER); in zephyr_thread_wrapper()
84 if (timer->evp.sigev_notify_function == NULL) { in zephyr_thread_wrapper()
89 LOG_DBG("calling sigev_notify_function %p", timer->evp.sigev_notify_function); in zephyr_thread_wrapper()
90 (timer->evp.sigev_notify_function)(timer->evp.sigev_value); in zephyr_thread_wrapper()
98 struct timer_obj *timer; in zephyr_timer_interrupt() local
100 timer = (struct timer_obj *)ztimer; in zephyr_timer_interrupt()
101 k_sem_give(&timer->sem_cond); in zephyr_timer_interrupt()
105 * @brief Create a per-process timer.
116 struct timer_obj *timer; in timer_create() local
124 if (k_mem_slab_alloc(&posix_timer_slab, (void **)&timer, alloc_timeout) != 0) { in timer_create()
130 *timer = (struct timer_obj){0}; in timer_create()
131 timer->evp = *evp; in timer_create()
132 evp = &timer->evp; in timer_create()
136 k_timer_init(&timer->ztimer, NULL, NULL); in timer_create()
139 k_timer_init(&timer->ztimer, zephyr_timer_wrapper, NULL); in timer_create()
164 ret = k_sem_init(&timer->sem_cond, 0, 1); in timer_create()
172 ret = pthread_create(&timer->thread, evp->sigev_notify_attributes, in timer_create()
173 zephyr_thread_wrapper, timer); in timer_create()
181 k_timer_init(&timer->ztimer, zephyr_timer_interrupt, NULL); in timer_create()
189 *timerid = (timer_t)timer; in timer_create()
193 k_mem_slab_free(&posix_timer_slab, (void *)&timer); in timer_create()
200 * @brief Get amount of time left for expiration on a per-process timer.
206 struct timer_obj *timer = (struct timer_obj *)timerid; in timer_gettime() local
210 if (timer == NULL) { in timer_gettime()
215 if (timer->status == ACTIVE) { in timer_gettime()
216 remaining = k_timer_remaining_get(&timer->ztimer); in timer_gettime()
223 /* Timer is disarmed */ in timer_gettime()
229 its->it_interval = timer->interval; in timer_gettime()
234 * @brief Sets expiration time of per-process timer.
241 struct timer_obj *timer = (struct timer_obj *) timerid; in timer_settime() local
244 if (timer == NULL || in timer_settime()
258 /* Stop the timer if the value is 0 */ in timer_settime()
260 if (timer->status == ACTIVE) { in timer_settime()
261 k_timer_stop(&timer->ztimer); in timer_settime()
264 timer->status = NOT_ACTIVE; in timer_settime()
268 /* Calculate timer period */ in timer_settime()
269 timer->reload = _ts_to_ms(&value->it_interval); in timer_settime()
270 timer->interval.tv_sec = value->it_interval.tv_sec; in timer_settime()
271 timer->interval.tv_nsec = value->it_interval.tv_nsec; in timer_settime()
273 /* Calculate timer duration */ in timer_settime()
276 current = k_timer_remaining_get(&timer->ztimer); in timer_settime()
285 if (timer->status == ACTIVE) { in timer_settime()
286 k_timer_stop(&timer->ztimer); in timer_settime()
289 timer->status = ACTIVE; in timer_settime()
290 k_timer_start(&timer->ztimer, K_MSEC(duration), K_MSEC(timer->reload)); in timer_settime()
295 * @brief Returns the timer expiration overrun count.
301 struct timer_obj *timer = (struct timer_obj *) timerid; in timer_getoverrun() local
303 if (timer == NULL) { in timer_getoverrun()
308 int overruns = k_timer_status_get(&timer->ztimer) - 1; in timer_getoverrun()
318 * @brief Delete a per-process timer.
324 struct timer_obj *timer = (struct timer_obj *) timerid; in timer_delete() local
326 if (timer == NULL) { in timer_delete()
331 if (timer->status == ACTIVE) { in timer_delete()
332 timer->status = NOT_ACTIVE; in timer_delete()
333 k_timer_stop(&timer->ztimer); in timer_delete()
336 if (timer->evp.sigev_notify == SIGEV_THREAD) { in timer_delete()
337 (void)pthread_cancel(timer->thread); in timer_delete()
340 k_mem_slab_free(&posix_timer_slab, (void *)timer); in timer_delete()