tests/driver_lpsxx: use new unified driver
This commit is contained in:
parent
1f4dee90a1
commit
f3b7b6066a
@ -1,9 +0,0 @@
|
|||||||
# About
|
|
||||||
This is a manual test application for the LPS331AP pressure sensor driver.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
This test application will initialize the pressure sensor with the following parameters:
|
|
||||||
- Sampling Rate: 7Hz
|
|
||||||
|
|
||||||
After initialization, the sensor reads the pressure and temperature values every 250ms
|
|
||||||
and prints them to the STDOUT.
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 Freie Universität Berlin
|
|
||||||
*
|
|
||||||
* 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 LPS331AP pressure sensor
|
|
||||||
*
|
|
||||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
|
||||||
*
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "xtimer.h"
|
|
||||||
#include "lps331ap.h"
|
|
||||||
#include "lps331ap_params.h"
|
|
||||||
|
|
||||||
#define SLEEP (250 * 1000U)
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
lps331ap_t dev;
|
|
||||||
|
|
||||||
puts("LPS331AP pressure sensor test application\n");
|
|
||||||
puts("Initializing LPS331AP sensor");
|
|
||||||
if (lps331ap_init(&dev, &lps331ap_params[0]) == 0) {
|
|
||||||
puts("[OK]\n");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
puts("[Failed]");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
int pres = lps331ap_read_pres(&dev);
|
|
||||||
int temp = lps331ap_read_temp(&dev);
|
|
||||||
|
|
||||||
int pres_abs = pres / 1000;
|
|
||||||
pres -= pres_abs * 1000;
|
|
||||||
int temp_abs = temp / 1000;
|
|
||||||
temp -= temp_abs * 1000;
|
|
||||||
|
|
||||||
printf("Pressure value: %2i.%03i bar - Temperature: %2i.%03i °C\n",
|
|
||||||
pres_abs, pres, temp_abs, temp);
|
|
||||||
|
|
||||||
xtimer_usleep(SLEEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@ -1,6 +1,8 @@
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += lps331ap
|
DRIVER ?= lps331ap
|
||||||
|
|
||||||
|
USEMODULE += $(DRIVER)
|
||||||
USEMODULE += xtimer
|
USEMODULE += xtimer
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
19
tests/driver_lpsxxx/README.md
Normal file
19
tests/driver_lpsxxx/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# About
|
||||||
|
|
||||||
|
This is a manual test application for the LPSXXX family of pressure sensors
|
||||||
|
driver. This driver can be used with LPS331AP and LPS25HB.
|
||||||
|
|
||||||
|
Default driver is `lps331ap`. To use the LPS25HB driver, set the `DRIVER` when
|
||||||
|
building the application:
|
||||||
|
|
||||||
|
DRIVER=lps25hb make BOARD=<your board>
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
This test application will initialize the pressure sensor with the following
|
||||||
|
parameters:
|
||||||
|
|
||||||
|
- Sampling Rate: 7Hz
|
||||||
|
|
||||||
|
After initialization, the sensor reads the pressure and temperature values
|
||||||
|
every 250ms and prints them to the STDOUT.
|
||||||
58
tests/driver_lpsxxx/main.c
Normal file
58
tests/driver_lpsxxx/main.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Freie Universität Berlin
|
||||||
|
* 2018 Inria
|
||||||
|
*
|
||||||
|
* 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 LPS331AP/LPS25HB pressure sensor
|
||||||
|
*
|
||||||
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||||
|
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "xtimer.h"
|
||||||
|
#include "lpsxxx.h"
|
||||||
|
#include "lpsxxx_params.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
lpsxxx_t dev;
|
||||||
|
|
||||||
|
puts("Test application for %s pressure sensor\n\n", LPSXXX_SAUL_NAME);
|
||||||
|
printf("Initializing %s sensor\n", LPSXXX_SAUL_NAME);
|
||||||
|
if (lpsxxx_init(&dev, &lpsxxx_params[0]) != LPSXXX_OK) {
|
||||||
|
puts("Initialization failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t pres;
|
||||||
|
int16_t temp;
|
||||||
|
while (1) {
|
||||||
|
lpsxxx_enable(&dev);
|
||||||
|
xtimer_sleep(1); /* wait a bit for the measurements to complete */
|
||||||
|
|
||||||
|
lpsxxx_read_temp(&dev, &temp);
|
||||||
|
lpsxxx_read_pres(&dev, &pres);
|
||||||
|
lpsxxx_disable(&dev);
|
||||||
|
|
||||||
|
int temp_abs = temp / 100;
|
||||||
|
temp -= temp_abs * 100;
|
||||||
|
|
||||||
|
printf("Pressure value: %ihPa - Temperature: %2i.%02i°C\n",
|
||||||
|
pres, temp_abs, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user