mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/periph: add test-application for peripheral freqm
This commit is contained in:
parent
afcd4801bd
commit
4a9ae47499
7
tests/periph/freqm/Makefile
Normal file
7
tests/periph/freqm/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
BOARD ?= same54-xpro
|
||||||
|
|
||||||
|
include ../Makefile.periph_common
|
||||||
|
|
||||||
|
USEMODULE += periph_freqm
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.include
|
14
tests/periph/freqm/README.md
Normal file
14
tests/periph/freqm/README.md
Normal file
@ -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: <INSERT VERSION HERE>)
|
||||||
|
FREQM peripheral driver test
|
||||||
|
Measured clock frequency: <MEASURED CLOCK FREQUENCY> Hz
|
||||||
|
Test run finished.
|
52
tests/periph/freqm/main.c
Normal file
52
tests/periph/freqm/main.c
Normal file
@ -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 <urs.gompper@ml-pa.com>
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user