1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 01:23:49 +01:00

tests/driver_vbat: add test for backup battery monitoring

This commit is contained in:
Fabian Hüßler 2021-10-10 17:33:28 +02:00
parent fa52f1e986
commit 2775c72018
4 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,6 @@
include ../Makefile.tests_common
FEATURES_REQUIRED += periph_vbat
USEMODULE += ztimer ztimer_msec
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,5 @@
Backup Battery Monitoring Application
=====================================
This test regularly samples the backup battery voltage and prints the result
to the serial console.

View File

@ -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

42
tests/periph_vbat/main.c Normal file
View File

@ -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 <fabian.huessler@ovgu.de>
*
* @}
*/
#include <stdio.h>
#include <inttypes.h>
#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;
}