From 739cb85830b3d30185220fd96ac2a6d37ee45280 Mon Sep 17 00:00:00 2001 From: Sebastian Meiling Date: Thu, 29 Nov 2018 16:22:50 +0100 Subject: [PATCH 1/2] tests: add README.md for periph_timer Moving test description from code to a separate README.md file to reduce binary size to make the test fit on an arduino-uno. --- tests/periph_timer/README.md | 17 +++++++++++++++++ tests/periph_timer/main.c | 10 ---------- 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 tests/periph_timer/README.md diff --git a/tests/periph_timer/README.md b/tests/periph_timer/README.md new file mode 100644 index 0000000000..72e6434297 --- /dev/null +++ b/tests/periph_timer/README.md @@ -0,0 +1,17 @@ +# Periph Timer Test + +## About + +This application will test all configured peripheral timers of the target +platform. For each timer, it will set each channel with an incrementing +timeout: CH0 is set to 5ms, CH1 to 10ms, CH2 to 15ms and so on. + +## Expected Result + +The output should show that every channel fired after an evenly distributed +amount of time, i.e. the diff values should be equal (with some jitter...). + +## Note + +This test does however **NOT** show whether the timeouts and diffs were correct +in relation to the expected real-time; use e.g. tests/xtimer_msg for this. diff --git a/tests/periph_timer/main.c b/tests/periph_timer/main.c index ad75ea662a..fe93a8ac6b 100644 --- a/tests/periph_timer/main.c +++ b/tests/periph_timer/main.c @@ -115,16 +115,6 @@ int main(void) int res = 0; puts("\nTest for peripheral TIMERs\n"); - puts("This test will test all configured peripheral timers of the\n" - "targeted platform. For each timer, it will set each channel with\n" - "an incrementing timeout. CH0 set to 5ms, CH1 to 10ms, CH2 to 15ms\n" - "and so on.\n" - "In the output you should see that every channel fired, after an\n" - "evenly distributed amount of time -> the shown diff values should\n" - "be pretty much equal (to some jitter...)\n" - "This test does however NOT show, if the timeouts were correct in\n" - "relation to the expected real-time ~ use e.g. tests/xtimer_msg for\n" - "this.\n\n"); printf("Available timers: %i\n", TIMER_NUMOF); From 7913811a0f5d2e6e12699aa3ae3d9e1477b4f9ea Mon Sep 17 00:00:00 2001 From: Sebastian Meiling Date: Thu, 29 Nov 2018 16:25:06 +0100 Subject: [PATCH 2/2] tests: board specific TIMER_SPEED in periph_timer By default the periph_timer tests wants to init all timers with 1MHz, which is not suitable for all timers, e.g. the atmega timers cannot run at that speed to make the test work they need to be set to 250kHz. --- tests/periph_timer/Makefile | 7 +++++++ tests/periph_timer/main.c | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/periph_timer/Makefile b/tests/periph_timer/Makefile index 1debd39325..07e78eaaca 100644 --- a/tests/periph_timer/Makefile +++ b/tests/periph_timer/Makefile @@ -6,4 +6,11 @@ FEATURES_REQUIRED = periph_timer TEST_ON_CI_WHITELIST += all +ifneq (,$(filter arduino-duemilanove arduino-mega2560 arduino-uno waspmote-pro,$(BOARD))) + TIMER_SPEED ?= 250000 +endif + +TIMER_SPEED ?= 1000000 + +CFLAGS += -DTIMER_SPEED=$(TIMER_SPEED) include $(RIOTBASE)/Makefile.include diff --git a/tests/periph_timer/main.c b/tests/periph_timer/main.c index fe93a8ac6b..1cd0a9e39b 100644 --- a/tests/periph_timer/main.c +++ b/tests/periph_timer/main.c @@ -32,7 +32,6 @@ #endif #define MAX_CHANNELS (10U) -#define TIM_SPEED (1000000ul) /* try to run with 1MHz */ #define CHAN_OFFSET (5000U) /* fire every 5ms */ #define COOKIE (100U) /* for checking if arg is passed */ @@ -61,7 +60,7 @@ static int test_timer(unsigned num) } /* initialize and halt timer */ - if (timer_init(TIMER_DEV(num), TIM_SPEED, cb, (void *)(COOKIE * num)) < 0) { + if (timer_init(TIMER_DEV(num), TIMER_SPEED, cb, (void *)(COOKIE * num)) < 0) { printf("TIMER_%u: ERROR on initialization - skipping\n\n", num); return 0; }