Lines Matching full:timer

14 static void zephyr_timer_wrapper(struct k_timer *timer);
26 static void zephyr_timer_wrapper(struct k_timer *timer) in zephyr_timer_wrapper() argument
30 cm_timer = CONTAINER_OF(timer, struct cv2_timer, z_timer); in zephyr_timer_wrapper()
35 * @brief Create a Timer
40 struct cv2_timer *timer; in osTimerNew() local
54 if (k_mem_slab_alloc(&cv2_timer_slab, (void **)&timer, K_MSEC(100)) == 0) { in osTimerNew()
55 (void)memset(timer, 0, sizeof(struct cv2_timer)); in osTimerNew()
60 timer->callback_function = func; in osTimerNew()
61 timer->arg = argument; in osTimerNew()
62 timer->type = type; in osTimerNew()
63 timer->status = NOT_ACTIVE; in osTimerNew()
65 k_timer_init(&timer->z_timer, zephyr_timer_wrapper, NULL); in osTimerNew()
68 strncpy(timer->name, init_timer_attrs.name, in osTimerNew()
69 sizeof(timer->name) - 1); in osTimerNew()
71 strncpy(timer->name, attr->name, sizeof(timer->name) - 1); in osTimerNew()
74 return (osTimerId_t)timer; in osTimerNew()
78 * @brief Start or restart a Timer
82 struct cv2_timer *timer = (struct cv2_timer *)timer_id; in osTimerStart() local
84 if (timer == NULL) { in osTimerStart()
92 if (timer->type == osTimerOnce) { in osTimerStart()
93 k_timer_start(&timer->z_timer, K_TICKS(ticks), K_NO_WAIT); in osTimerStart()
94 } else if (timer->type == osTimerPeriodic) { in osTimerStart()
95 k_timer_start(&timer->z_timer, in osTimerStart()
99 timer->status = ACTIVE; in osTimerStart()
104 * @brief Stop the Timer
108 struct cv2_timer *timer = (struct cv2_timer *)timer_id; in osTimerStop() local
110 if (timer == NULL) { in osTimerStop()
118 if (timer->status == NOT_ACTIVE) { in osTimerStop()
122 k_timer_stop(&timer->z_timer); in osTimerStop()
123 timer->status = NOT_ACTIVE; in osTimerStop()
128 * @brief Delete the timer that was created by osTimerCreate
132 struct cv2_timer *timer = (struct cv2_timer *) timer_id; in osTimerDelete() local
134 if (timer == NULL) { in osTimerDelete()
142 if (timer->status == ACTIVE) { in osTimerDelete()
143 k_timer_stop(&timer->z_timer); in osTimerDelete()
144 timer->status = NOT_ACTIVE; in osTimerDelete()
147 k_mem_slab_free(&cv2_timer_slab, (void *)timer); in osTimerDelete()
152 * @brief Get name of a timer.
156 struct cv2_timer *timer = (struct cv2_timer *)timer_id; in osTimerGetName() local
158 if (k_is_in_isr() || (timer == NULL)) { in osTimerGetName()
162 return timer->name; in osTimerGetName()
166 * @brief Check if a timer is running.
170 struct cv2_timer *timer = (struct cv2_timer *)timer_id; in osTimerIsRunning() local
172 if (k_is_in_isr() || (timer == NULL)) { in osTimerIsRunning()
176 return !(!(k_timer_remaining_get(&timer->z_timer))); in osTimerIsRunning()