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

Merge pull request #16258 from maribu/cpu/sam3/periph_rtt

cpu/sam3/periph_rtt: fix rtt_get_alarm()
This commit is contained in:
Marian Buschsieweke 2021-03-30 17:47:30 +02:00 committed by GitHub
commit ca8641c213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -75,7 +75,8 @@ void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
uint32_t rtt_get_alarm(void)
{
if (RTT->RTT_MR & RTT_MR_ALMIEN) {
return RTT->RTT_AR;
/* the alarm value is RTT_AR + 1, see rtt_set_alarm() */
return RTT->RTT_AR + 1;
}
return 0;
}

View File

@ -93,8 +93,10 @@ int main(void)
printf("Setting initial alarm to now + 5 s (%" PRIu32 ")\n", last);
rtt_set_alarm(last, cb, 0);
if (rtt_get_alarm() != last) {
puts("Error: rtt_get_alarm() not working");
uint32_t tmp = rtt_get_alarm();
if (tmp != last) {
printf("Error: rtt_get_alarm() not working (expected %" PRIu32 " but got %" PRIu32 ")\n",
last, tmp);
return 1;
}
else {