mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/sys/event_ztimer: add event_periodic_start_now() to test
This commit is contained in:
parent
90473c62f0
commit
d4cd708849
@ -64,10 +64,9 @@ static void callback_4times(void *arg)
|
|||||||
uint8_t *count = (uint8_t *)arg;
|
uint8_t *count = (uint8_t *)arg;
|
||||||
|
|
||||||
*count = *count + 1;
|
*count = *count + 1;
|
||||||
uint32_t now = event_periodic.timer.last;
|
uint32_t now = ztimer_now(ZTIMER_USEC);
|
||||||
uint32_t elapsed = now - before;
|
uint32_t elapsed = now - before;
|
||||||
before = now;
|
before = now;
|
||||||
expect((elapsed) >= 1 * US_PER_SEC);
|
|
||||||
if (*count <= 4) {
|
if (*count <= 4) {
|
||||||
printf("trigger %d of periodic timeout, elapsed time: %" PRIu32 " us\n",
|
printf("trigger %d of periodic timeout, elapsed time: %" PRIu32 " us\n",
|
||||||
*count, elapsed);
|
*count, elapsed);
|
||||||
@ -110,8 +109,15 @@ int main(void)
|
|||||||
event_periodic_init(&event_periodic, ZTIMER_USEC, EVENT_PRIO_MEDIUM,
|
event_periodic_init(&event_periodic, ZTIMER_USEC, EVENT_PRIO_MEDIUM,
|
||||||
&event_4times.super);
|
&event_4times.super);
|
||||||
event_periodic_set_count(&event_periodic, 4);
|
event_periodic_set_count(&event_periodic, 4);
|
||||||
|
before = ztimer_now(ZTIMER_USEC);
|
||||||
event_periodic_start(&event_periodic, EVENT_TIMEOUT_TIME);
|
event_periodic_start(&event_periodic, EVENT_TIMEOUT_TIME);
|
||||||
before = event_periodic.timer.last;
|
puts("waiting for periodic callback to be triggered 4 times");
|
||||||
|
mutex_lock(&lock);
|
||||||
|
puts("posting periodic timed callback with timeout 1sec and no delay");
|
||||||
|
event_periodic_set_count(&event_periodic, 4);
|
||||||
|
iter = 0; /* reset callback argument counter to 0 */
|
||||||
|
before = ztimer_now(ZTIMER_USEC);
|
||||||
|
event_periodic_start_now(&event_periodic, EVENT_TIMEOUT_TIME);
|
||||||
puts("waiting for periodic callback to be triggered 4 times");
|
puts("waiting for periodic callback to be triggered 4 times");
|
||||||
mutex_lock(&lock);
|
mutex_lock(&lock);
|
||||||
puts("posting timed callback with timeout 0.5sec, clear right after");
|
puts("posting timed callback with timeout 0.5sec, clear right after");
|
||||||
|
Loading…
Reference in New Issue
Block a user