From 2775c720185770a858173798f92469a66f2b22b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20H=C3=BC=C3=9Fler?= Date: Sun, 10 Oct 2021 17:33:28 +0200 Subject: [PATCH] tests/driver_vbat: add test for backup battery monitoring --- tests/periph_vbat/Makefile | 6 +++++ tests/periph_vbat/README.md | 5 ++++ tests/periph_vbat/app.config.test | 5 ++++ tests/periph_vbat/main.c | 42 +++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 tests/periph_vbat/Makefile create mode 100644 tests/periph_vbat/README.md create mode 100644 tests/periph_vbat/app.config.test create mode 100644 tests/periph_vbat/main.c diff --git a/tests/periph_vbat/Makefile b/tests/periph_vbat/Makefile new file mode 100644 index 0000000000..ba1d50c726 --- /dev/null +++ b/tests/periph_vbat/Makefile @@ -0,0 +1,6 @@ +include ../Makefile.tests_common + +FEATURES_REQUIRED += periph_vbat +USEMODULE += ztimer ztimer_msec + +include $(RIOTBASE)/Makefile.include diff --git a/tests/periph_vbat/README.md b/tests/periph_vbat/README.md new file mode 100644 index 0000000000..77299e3e49 --- /dev/null +++ b/tests/periph_vbat/README.md @@ -0,0 +1,5 @@ +Backup Battery Monitoring Application +===================================== + +This test regularly samples the backup battery voltage and prints the result +to the serial console. diff --git a/tests/periph_vbat/app.config.test b/tests/periph_vbat/app.config.test new file mode 100644 index 0000000000..53f7c7a820 --- /dev/null +++ b/tests/periph_vbat/app.config.test @@ -0,0 +1,5 @@ +# this file enables modules defined in Kconfig. Do not use this file for +# application configuration. This is only needed during migration. +CONFIG_MODULE_ZTIMER=y +CONFIG_MODULE_ZTIMER_MSEC=y +CONFIG_MODULE_PERIPH_VBAT=y diff --git a/tests/periph_vbat/main.c b/tests/periph_vbat/main.c new file mode 100644 index 0000000000..47d7988fea --- /dev/null +++ b/tests/periph_vbat/main.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief Test application for backup battery monitoring + * + * @author Fabian Hüßler + * + * @} + */ + +#include +#include + +#include "board.h" +#include "ztimer.h" +#include "periph/vbat.h" + +int main(void) +{ + puts("\nRIOT backup battery monitoring test\n"); + puts("This test will sample the backup battery once a second\n\n"); + + int32_t bat_mv; + while (1) { + if ((bat_mv = vbat_sample_mv()) < 0) { + return 1; + } + printf("VBAT: %"PRIi32"[mV]\n", bat_mv); + ztimer_sleep(ZTIMER_MSEC, 1000); + } + return 0; +}