Lines Matching full:timer
43 * remaining time for a partially elapsed timer in ticks will be
52 static void duration_expire(struct k_timer *timer);
53 static void duration_stop(struct k_timer *timer);
55 /** TESTPOINT: init timer via K_TIMER_DEFINE */
113 static void duration_expire(struct k_timer *timer) in duration_expire() argument
120 TIMER_ASSERT(interval_check(interval, DURATION), timer); in duration_expire()
122 TIMER_ASSERT(interval_check(interval, PERIOD), timer); in duration_expire()
126 k_timer_stop(timer); in duration_expire()
130 static void duration_stop(struct k_timer *timer) in duration_stop() argument
135 static void period0_expire(struct k_timer *timer) in period0_expire() argument
140 static void status_expire(struct k_timer *timer) in status_expire() argument
142 /** TESTPOINT: status get upon timer expired */ in status_expire()
143 TIMER_ASSERT(k_timer_status_get(timer) == 1, timer); in status_expire()
144 /** TESTPOINT: remaining get upon timer expired */ in status_expire()
145 TIMER_ASSERT(k_timer_remaining_get(timer) >= PERIOD, timer); in status_expire()
148 k_timer_stop(timer); in status_expire()
157 static void status_stop(struct k_timer *timer) in status_stop() argument
159 /** TESTPOINT: remaining get upon timer stopped */ in status_stop()
160 TIMER_ASSERT(k_timer_remaining_get(timer) == 0, timer); in status_stop()
164 * @brief Tests for the Timer kernel object
165 * @defgroup kernel_timer_tests Timer
172 * @brief Test duration and period of Timer
174 * Validates initial duration and period of timer.
176 * It initializes the timer with k_timer_init(), then starts the timer
178 * Stops the timer using k_timer_stop() and checks for proper completion
189 /** TESTPOINT: init timer via k_timer_init */ in ZTEST_USER()
204 * @brief Test restart the timer
206 * @details Validates initial duration and period of timer. Start the timer with
207 * specific duration and period. Then starts the timer again, and check
208 * the status of timer.
223 /** TESTPOINT: restart the timer */ in ZTEST_USER()
226 /* Restart timer, timer's status is reset to zero */ in ZTEST_USER()
236 * @brief Test Timer with zero period value
238 * Validates initial timer duration, keeping timer period to zero.
239 * Basically, acting as one-shot timer.
240 * It initializes the timer with k_timer_init(), then starts the timer
242 * zero. Stops the timer using k_timer_stop() and checks for proper
262 /** TESTPOINT: ensure it is one-shot timer */ in ZTEST_USER()
273 * @brief Test Timer with K_FOREVER period value
275 * Validates initial timer duration, keeping timer period to K_FOREVER.
276 * Basically, acting as one-shot timer.
277 * It initializes the timer with k_timer_init(), then starts the timer
279 * zero. Stops the timer using k_timer_stop() and checks for proper
301 /** TESTPOINT: ensure it is one-shot timer */ in ZTEST_USER()
312 * @brief Test Timer without any timer expiry callback function
314 * Validates timer without any expiry_fn(set to NULL). expiry_fn() is a
315 * function that is invoked each time the timer expires.
317 * It initializes the timer with k_timer_init(), then starts the timer
318 * using k_timer_start(). Stops the timer using k_timer_stop() and
343 /* Wait for the next expiration of an OS timer tick, to synchronize
354 * @brief Test to check timer periodicity
356 * Timer test to check for the predictability with which the timer
359 * It initializes the timer with k_timer_init(), then starts the timer
360 * using k_timer_start() with specific period. It resets the timer’s
362 * between each timer expiry to check for the timer expiration period
363 * correctness. Finally, stops the timer using k_timer_stop().
386 * whatever duration that was set. Since timer is likely in ZTEST_USER()
389 * be fetched as soon as possible after timer firing. in ZTEST_USER()
402 /** TESTPOINT: check if timer fired within 1ms of the in ZTEST_USER()
424 * @brief Test Timer status and time remaining before next expiry
426 * Timer test to validate timer status and next trigger expiry time
428 * It initializes the timer with k_timer_init(), then starts the timer
429 * using k_timer_start() and checks for timer current status with
431 * k_timer_remaining_get(). Stops the timer using k_timer_stop().
442 /** TESTPOINT: status get upon timer starts */ in ZTEST_USER()
444 /** TESTPOINT: remaining get upon timer starts */ in ZTEST_USER()
453 * @brief Test Timer status randomly after certain duration
455 * Validate timer status function using k_timer_status_get().
457 * It initializes the timer with k_timer_init(), then starts the timer
459 * Checks for timer status randomly after certain duration.
460 * Stops the timer using k_timer_stop().
486 * @brief Test Timer thread synchronization
489 * the timer expires.
491 * It initializes the timer with k_timer_init(), then starts the timer
492 * using k_timer_start() and checks timer status with
494 * Stops the timer using k_timer_stop.
507 /** TESTPOINT: check timer not expire */ in ZTEST_USER()
512 /** TESTPOINT: check timer not expire */ in ZTEST_USER()
527 * @brief Test statically defined Timer init
529 * Validate statically defined timer init using K_TIMER_DEFINE
531 * It creates prototype of K_TIMER_DEFINE to statically define timer
532 * init and starts the timer with k_timer_start() with specific initial
533 * duration and period. Stops the timer using k_timer_stop() and checks
544 /** TESTPOINT: init timer via k_timer_init */ in ZTEST_USER()
556 /** TESTPOINT: init timer via k_timer_init */ in ZTEST_USER()
576 static void user_data_timer_handler(struct k_timer *timer);
592 static void user_data_timer_handler(struct k_timer *timer) in user_data_timer_handler() argument
594 int timer_num = timer == user_data_timer[0] ? 0 : in user_data_timer_handler()
595 timer == user_data_timer[1] ? 1 : in user_data_timer_handler()
596 timer == user_data_timer[2] ? 2 : in user_data_timer_handler()
597 timer == user_data_timer[3] ? 3 : in user_data_timer_handler()
598 timer == user_data_timer[4] ? 4 : -1; in user_data_timer_handler()
604 intptr_t data_retrieved = (intptr_t)k_timer_user_data_get(timer); in user_data_timer_handler()
610 * @brief Test user-specific data associated with timer
612 * Validate user-specific data associated with timer
614 * It creates prototype of K_TIMER_DEFINE and starts the timer using
617 * Stops the timer using k_timer_stop() and checks for correct data
618 * retrieval after timer completion.
668 * Starts a timer, busy-waits for half the DURATION, then checks the
669 * remaining time to expiration and stops the timer. The remaining time
721 * ticks, we're waiting in k_busy_wait(), not for a timer in ZTEST_USER()
727 * by the kernel timer and the one used for busy-waiting may be skewed. in ZTEST_USER()
834 static void timer_init(struct k_timer *timer, k_timer_expiry_t expiry_fn, in timer_init() argument
838 k_object_access_grant(timer, k_current_get()); in timer_init()
841 k_timer_init(timer, expiry_fn, stop_fn); in timer_init()