diff --git a/tests/driver_lps331ap/README.md b/tests/driver_lps331ap/README.md deleted file mode 100644 index 96daac3736..0000000000 --- a/tests/driver_lps331ap/README.md +++ /dev/null @@ -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. diff --git a/tests/driver_lps331ap/main.c b/tests/driver_lps331ap/main.c deleted file mode 100644 index 746aea02c9..0000000000 --- a/tests/driver_lps331ap/main.c +++ /dev/null @@ -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 - * - * @} - */ - -#include - -#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; -} diff --git a/tests/driver_lps331ap/Makefile b/tests/driver_lpsxxx/Makefile similarity index 68% rename from tests/driver_lps331ap/Makefile rename to tests/driver_lpsxxx/Makefile index 3099ea5cd4..9664dc9003 100644 --- a/tests/driver_lps331ap/Makefile +++ b/tests/driver_lpsxxx/Makefile @@ -1,6 +1,8 @@ include ../Makefile.tests_common -USEMODULE += lps331ap +DRIVER ?= lps331ap + +USEMODULE += $(DRIVER) USEMODULE += xtimer include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_lpsxxx/README.md b/tests/driver_lpsxxx/README.md new file mode 100644 index 0000000000..b1339aa26a --- /dev/null +++ b/tests/driver_lpsxxx/README.md @@ -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= + +# 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. diff --git a/tests/driver_lpsxxx/main.c b/tests/driver_lpsxxx/main.c new file mode 100644 index 0000000000..c54c625b15 --- /dev/null +++ b/tests/driver_lpsxxx/main.c @@ -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 + * @author Alexandre Abadie + * + * @} + */ + +#include + +#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; +}