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:
parent
fa52f1e986
commit
2775c72018
6
tests/periph_vbat/Makefile
Normal file
6
tests/periph_vbat/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
FEATURES_REQUIRED += periph_vbat
|
||||
USEMODULE += ztimer ztimer_msec
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
5
tests/periph_vbat/README.md
Normal file
5
tests/periph_vbat/README.md
Normal 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.
|
||||
5
tests/periph_vbat/app.config.test
Normal file
5
tests/periph_vbat/app.config.test
Normal 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
42
tests/periph_vbat/main.c
Normal 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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user