tests/periph_rtt: Initialize timer target from current reading
This avoids false test failures when the RTT retains its old counter value across reboots/resets.
This commit is contained in:
parent
8841486f2e
commit
d3d3c1c036
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "periph_conf.h"
|
#include "periph_conf.h"
|
||||||
@ -51,9 +52,12 @@ int main(void)
|
|||||||
puts("Initializing the RTT driver");
|
puts("Initializing the RTT driver");
|
||||||
rtt_init();
|
rtt_init();
|
||||||
|
|
||||||
puts("Setting initial alarm");
|
uint32_t now = rtt_get_counter();
|
||||||
last = TICKS_TO_WAIT;
|
printf("RTT now: %" PRIu32 "\n", now);
|
||||||
rtt_set_alarm(TICKS_TO_WAIT, cb, 0);
|
|
||||||
|
last = (now + TICKS_TO_WAIT) & RTT_MAX_VALUE;
|
||||||
|
printf("Setting initial alarm to now + 10 s (%" PRIu32 ")\n", last);
|
||||||
|
rtt_set_alarm(last, cb, 0);
|
||||||
|
|
||||||
puts("Done setting up the RTT, wait for many Hellos");
|
puts("Done setting up the RTT, wait for many Hellos");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user