1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/xtimer_usleep_until/main.c

52 lines
1.1 KiB
C
Raw Normal View History

2015-08-14 16:04:53 +02:00
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief timer test application
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include <stdio.h>
#include "xtimer.h"
#include "periph_conf.h"
#define NUMOF 1000
2015-08-14 16:04:53 +02:00
uint32_t res[NUMOF];
2015-08-14 16:04:53 +02:00
int main(void)
{
puts("xtimer_usleep_until test application.\n");
uint32_t interval = 1000;
for (int i = 0; i < NUMOF; i++) {
2015-08-14 16:04:53 +02:00
printf("Testing interval %u...\n", (unsigned)interval);
uint32_t last_wakeup = xtimer_now();
uint32_t before = last_wakeup;
xtimer_usleep_until(&last_wakeup, (unsigned)interval);
uint32_t diff = (xtimer_now()-before)-interval;
2015-08-14 16:04:53 +02:00
res[i] = diff;
interval -= 1;
}
for (int i = 0; i < NUMOF; i++) {
2015-08-14 16:04:53 +02:00
printf("%4d diff=%i\n", i, (int)res[i]);
}
printf("\nTest complete.\n");
return 0;
}