From 4a9ae47499857ebe0adcc1649f361ec91b973462 Mon Sep 17 00:00:00 2001 From: Urs Gompper Date: Wed, 25 Oct 2023 16:53:17 +0200 Subject: [PATCH] tests/periph: add test-application for peripheral freqm --- tests/periph/freqm/Makefile | 7 +++++ tests/periph/freqm/README.md | 14 ++++++++++ tests/periph/freqm/main.c | 52 ++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/periph/freqm/Makefile create mode 100644 tests/periph/freqm/README.md create mode 100644 tests/periph/freqm/main.c diff --git a/tests/periph/freqm/Makefile b/tests/periph/freqm/Makefile new file mode 100644 index 0000000000..fe22b6f7ec --- /dev/null +++ b/tests/periph/freqm/Makefile @@ -0,0 +1,7 @@ +BOARD ?= same54-xpro + +include ../Makefile.periph_common + +USEMODULE += periph_freqm + +include $(RIOTBASE)/Makefile.include diff --git a/tests/periph/freqm/README.md b/tests/periph/freqm/README.md new file mode 100644 index 0000000000..ac40fd85ef --- /dev/null +++ b/tests/periph/freqm/README.md @@ -0,0 +1,14 @@ +Peripheral FREQM Test Application +===================================== + +This application tests the frequency meter (FREQM) functionality. This is done +by measuring the frequency of a clock, connected to a GPIO, with an internal +clock as reference. + +Expected Output on Success +-------------------------- + + main(): This is RIOT! (Version: ) + FREQM peripheral driver test + Measured clock frequency: Hz + Test run finished. diff --git a/tests/periph/freqm/main.c b/tests/periph/freqm/main.c new file mode 100644 index 0000000000..432957c971 --- /dev/null +++ b/tests/periph/freqm/main.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 ML!PA Consulting GmbH + * + * 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. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief Application to test functionality of the frequency meter + * peripheral + * + * @author Urs Gompper + * @} + */ + +#include +#include +#include +#include +#include + +#include "periph/freqm.h" + +int main(void) +{ + puts("FREQM peripheral driver test"); + + /* Initialize frequency meter peripheral */ + freqm_init(0); + + uint32_t period_us = UINT32_MAX; + uint32_t freq_hz = 0; + + /* Measure in blocking mode */ + if (!freqm_frequency_get(0, &freq_hz, period_us)) { + printf("Measured Clock Frequency: %ld Hz\n", freq_hz); + } + else { + puts("Overflow occurred to the FREQM value counter!"); + return EXIT_FAILURE; + } + + puts("Test run finished."); + + /* main thread exits */ + return 0; +}