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"
|
|
|
|
|
2015-09-02 17:07:36 +02:00
|
|
|
#define NUMOF 1000
|
2015-08-14 16:04:53 +02:00
|
|
|
|
2015-09-02 17:07:36 +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;
|
|
|
|
|
2015-09-02 17:07:36 +02:00
|
|
|
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);
|
2015-09-05 16:21:46 +02:00
|
|
|
uint32_t diff = (xtimer_now()-before)-interval;
|
2015-08-14 16:04:53 +02:00
|
|
|
res[i] = diff;
|
|
|
|
interval -= 1;
|
|
|
|
}
|
|
|
|
|
2015-09-02 17:07:36 +02:00
|
|
|
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;
|
|
|
|
}
|