diff --git a/examples/timer_periodic_wakeup/main.c b/examples/timer_periodic_wakeup/main.c index ce080f4e98..b2925f3309 100644 --- a/examples/timer_periodic_wakeup/main.c +++ b/examples/timer_periodic_wakeup/main.c @@ -20,17 +20,18 @@ #include #include "xtimer.h" +#include "timex.h" /* set interval to 1 second */ -#define INTERVAL (1000000U) +#define INTERVAL (1U * SEC_IN_USEC) int main(void) { uint32_t last_wakeup = xtimer_now(); while(1) { - xtimer_usleep_until(&last_wakeup, INTERVAL); - printf("slept until %"PRIu32"\n", xtimer_now()); + xtimer_periodic_wakeup(&last_wakeup, INTERVAL); + printf("slept until %" PRIu32 "\n", xtimer_now()); } return 0; diff --git a/tests/driver_bh1750/main.c b/tests/driver_bh1750/main.c index 4380a5f667..0c276aa6bc 100644 --- a/tests/driver_bh1750/main.c +++ b/tests/driver_bh1750/main.c @@ -40,7 +40,7 @@ int main(void) while(1) { uint16_t val = bh1750fvi_sample(&dev); printf("value: %5i lux\n", (int)val); - xtimer_usleep_until(&last, RATE); + xtimer_periodic_wakeup(&last, RATE); } return 0; diff --git a/tests/driver_srf02/main.c b/tests/driver_srf02/main.c index 1e6df623f9..317f5a3950 100644 --- a/tests/driver_srf02/main.c +++ b/tests/driver_srf02/main.c @@ -27,6 +27,7 @@ #include "shell.h" #include "xtimer.h" +#include "timex.h" #include "srf02.h" #ifndef TEST_SRF02_I2C @@ -36,7 +37,7 @@ #error "TEST_MODE not defined" #endif -#define SAMPLE_PERIOD (100LU * 1000U) +#define SAMPLE_PERIOD (100LU * MS_IN_USEC) /* 100 ms */ static srf02_t dev; @@ -78,7 +79,7 @@ static int cmd_sample(int argc, char **argv) while(1) { sample(); - xtimer_usleep_until(&wakeup, SAMPLE_PERIOD); + xtimer_periodic_wakeup(&wakeup, SAMPLE_PERIOD); } return 0; diff --git a/tests/periph_adc/main.c b/tests/periph_adc/main.c index b63d33bcaa..79146a04f0 100644 --- a/tests/periph_adc/main.c +++ b/tests/periph_adc/main.c @@ -21,11 +21,12 @@ #include #include "xtimer.h" +#include "timex.h" #include "periph/adc.h" #define RES ADC_RES_10BIT -#define DELAY (100LU * 1000U) +#define DELAY (100LU * MS_IN_USEC) /* 100 ms */ int main(void) @@ -56,7 +57,7 @@ int main(void) printf("ADC_LINE(%i): %i\n", i, sample); } } - xtimer_usleep_until(&last, DELAY); + xtimer_periodic_wakeup(&last, DELAY); } return 0; diff --git a/tests/periph_dac/main.c b/tests/periph_dac/main.c index a827eede30..59897a7a5f 100644 --- a/tests/periph_dac/main.c +++ b/tests/periph_dac/main.c @@ -56,7 +56,7 @@ int main(void) dac_set(DAC_LINE(i), val); } val += step; - xtimer_usleep_until(&last, DELAY); + xtimer_periodic_wakeup(&last, DELAY); } return 0; diff --git a/tests/periph_pwm/main.c b/tests/periph_pwm/main.c index b20d253615..aee1a385c7 100644 --- a/tests/periph_pwm/main.c +++ b/tests/periph_pwm/main.c @@ -27,9 +27,10 @@ #include #include "xtimer.h" +#include "timex.h" #include "periph/pwm.h" -#define INTERVAL (10000U) +#define INTERVAL (10LU * MS_IN_USEC) /* 10 ms */ #define STEP (10) #define MODE PWM_LEFT @@ -71,7 +72,7 @@ int main(void) step = -step; } - xtimer_usleep_until(&last_wakeup, INTERVAL); + xtimer_periodic_wakeup(&last_wakeup, INTERVAL); } return 0; diff --git a/tests/saul/main.c b/tests/saul/main.c index 7e228ea466..ff6d694c9d 100644 --- a/tests/saul/main.c +++ b/tests/saul/main.c @@ -26,7 +26,7 @@ /** * @brief Read th sensors every second */ -#define INTERVAL (1000000LU) +#define INTERVAL (1LU * SEC_IN_USEC) int main(void) @@ -50,7 +50,7 @@ int main(void) dev = dev->next; } - xtimer_usleep_until(&last, INTERVAL); + xtimer_periodic_wakeup(&last, INTERVAL); } return 0; diff --git a/tests/xtimer_drift/main.c b/tests/xtimer_drift/main.c index 4af305c9f8..7bb5828d9c 100644 --- a/tests/xtimer_drift/main.c +++ b/tests/xtimer_drift/main.c @@ -192,7 +192,7 @@ int main(void) uint32_t last_wakeup = xtimer_now(); while (1) { - xtimer_usleep_until(&last_wakeup, TEST_INTERVAL); + xtimer_periodic_wakeup(&last_wakeup, TEST_INTERVAL); msg_try_send(&m, pid3); } } diff --git a/tests/xtimer_longterm/README.md b/tests/xtimer_longterm/README.md index 6ad57d601a..d0ba6f47b7 100644 --- a/tests/xtimer_longterm/README.md +++ b/tests/xtimer_longterm/README.md @@ -19,7 +19,7 @@ we consider this long-term...). The mid-term timers are set to 3 and 5 minutes. Both kind of timers have one that is using `xtimer_usleep` and one that is using `xtimer_set_msg`. -The short-term timer is triggered every 50ms and is using `xtimer_sleep_until`. +The short-term timer is triggered every 50ms and is using `xtimer_periodic_wakeup`. Each time this timer triggers, it increments a software counter, which triggers then a message every minute. A 50ms interval should be small enough, to trigger also for 16-bit wide timers at least once in every timer period. @@ -28,4 +28,4 @@ On each mid- and long-term timer event, the output shows also the number of fast timer (1min timer) ticks, that have been triggered since a timer was triggered last. This number should be equal to the timers interval. -For reasonable results, you should run this test at least for some ours... +For reasonable results, you should run this test at least for some hours... diff --git a/tests/xtimer_longterm/main.c b/tests/xtimer_longterm/main.c index 4fe44c49ca..e59fdd216f 100644 --- a/tests/xtimer_longterm/main.c +++ b/tests/xtimer_longterm/main.c @@ -113,7 +113,7 @@ void *ticker(void *arg) msg_send(&msg, print_pid); } - xtimer_usleep_until(&base, INT_SHORT); + xtimer_periodic_wakeup(&base, INT_SHORT); } return NULL; diff --git a/tests/xtimer_reset/main.c b/tests/xtimer_reset/main.c index 329e670a53..e591b646d6 100644 --- a/tests/xtimer_reset/main.c +++ b/tests/xtimer_reset/main.c @@ -18,6 +18,8 @@ * @} */ +#include +#include #include #include "thread.h" @@ -46,11 +48,11 @@ int main(void) xtimer_set_wakeup(&xtimer, 200000, me); xtimer_set_wakeup(&xtimer2, 100000, me); - printf("now=%u\n", (unsigned)xtimer_now()); + printf("now=%" PRIu32 "\n", xtimer_now()); thread_sleep(); - printf("now=%u\n", (unsigned)xtimer_now()); + printf("now=%" PRIu32 "\n", xtimer_now()); thread_sleep(); - printf("now=%u\n", (unsigned)xtimer_now()); + printf("now=%" PRIu32 "\n", xtimer_now()); printf("Test completed!\n");