tests/driver_pulse_counter: test application for pulse counter driver
This commit is contained in:
parent
149914000f
commit
36666a75b0
7
tests/driver_pulse_counter/Makefile
Normal file
7
tests/driver_pulse_counter/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
BOARD_BLACKLIST := msb-430 msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1
|
||||
|
||||
USEMODULE += pulse_counter
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
12
tests/driver_pulse_counter/README.md
Normal file
12
tests/driver_pulse_counter/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# About
|
||||
This is a manual test application for the PULSE_COUNTER driver.
|
||||
|
||||
# Usage
|
||||
This test application will initialize the PULSE_COUNTER sensor with the configuration
|
||||
as specified in the default `pulse_counter_params.h` file.
|
||||
|
||||
If you want to use this test application with different parameters, you can
|
||||
simply override the default PULSE_COUNTER_PARAMS.
|
||||
|
||||
After initialization, the sensor reads the pulse counter values every second and
|
||||
prints them to STDOUT.
|
||||
52
tests/driver_pulse_counter/main.c
Normal file
52
tests/driver_pulse_counter/main.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2017 UC Berkeley
|
||||
*
|
||||
* 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 the PULSE_COUNTER driver
|
||||
*
|
||||
* @author Hyung-Sin Kim <hs.kim@cs.berkeley.edu>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "pulse_counter_params.h"
|
||||
|
||||
#define SLEEP US_PER_SEC
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pulse_counter_t dev;
|
||||
|
||||
printf("PULSE_COUNTER driver test application\n");
|
||||
|
||||
/* Initialization */
|
||||
if (pulse_counter_init(&dev, &pulse_counter_params[0])) {
|
||||
printf("[Failed]");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("[OK]\n");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/* Pulse counter reading */
|
||||
int16_t count = pulse_counter_read_with_reset(&dev);
|
||||
printf("pulse counter: %d\n", count);
|
||||
|
||||
xtimer_usleep(SLEEP);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user