diff --git a/tests/periph_rtt/Kconfig b/tests/periph_rtt/Kconfig new file mode 100644 index 0000000000..a2d35dbf35 --- /dev/null +++ b/tests/periph_rtt/Kconfig @@ -0,0 +1,12 @@ +# Copyright (C) 2021 Otto-von-Guericke-Universität Magdeburg +# +# 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. +# + +config APPLICATION + bool + default y + imply MODULE_PERIPH_RTT_SET_COUNTER + depends on TEST_KCONFIG diff --git a/tests/periph_rtt/Makefile b/tests/periph_rtt/Makefile index 08887559e5..72bb287f2b 100644 --- a/tests/periph_rtt/Makefile +++ b/tests/periph_rtt/Makefile @@ -2,6 +2,7 @@ BOARD ?= samr21-xpro include ../Makefile.tests_common FEATURES_REQUIRED = periph_rtt +FEATURES_OPTIONAL += periph_rtt_set_counter DISABLE_MODULE += periph_init_rtt diff --git a/tests/periph_rtt/main.c b/tests/periph_rtt/main.c index 96e10a5e65..8e9ac8de0f 100644 --- a/tests/periph_rtt/main.c +++ b/tests/periph_rtt/main.c @@ -75,10 +75,32 @@ int main(void) uint32_t now = rtt_get_counter(); printf("RTT now: %" PRIu32 "\n", now); + if (IS_USED(MODULE_PERIPH_RTT_SET_COUNTER)) { + puts("Setting RTT timer to 1337"); + rtt_set_counter(1337); + now = rtt_get_counter(); + printf("RTT now: %" PRIu32 "\n", now); + if ((now < 1337) || (now > 1337 + (1 * RTT_FREQUENCY + 999) / 1000)) { + puts("ERROR: rtt_set_counter() failed (off by more than 1 ms)"); + return 1; + } + else { + puts("rtt_set_counter() PASSED"); + } + } + last = (now + TICKS_TO_WAIT) & RTT_MAX_VALUE; 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"); + return 1; + } + else { + puts("rtt_get_alarm() PASSED"); + } + puts("Done setting up the RTT, wait for many Hellos"); return 0; } diff --git a/tests/periph_rtt/tests/01-run.py b/tests/periph_rtt/tests/01-run.py index 494ecec330..2990071a1b 100755 --- a/tests/periph_rtt/tests/01-run.py +++ b/tests/periph_rtt/tests/01-run.py @@ -25,8 +25,8 @@ def testfunc(child): child.expect(r'RTT now: \d+') child.expect(r'Setting initial alarm to now \+ {} s \(\d+\)' .format(period)) - child.expect_exact('Done setting up the RTT, wait for many Hellos') start = time.time() + child.expect_exact('Done setting up the RTT, wait for many Hellos') for _ in range(MAX_HELLOS): child.expect_exact('Hello\r\n', timeout=period + 1)