diff --git a/tests/driver_bmx055/Makefile b/tests/driver_bmx055/Makefile new file mode 100644 index 0000000000..9c9293fbfd --- /dev/null +++ b/tests/driver_bmx055/Makefile @@ -0,0 +1,10 @@ +include ../Makefile.tests_common + +# include and auto-initialize all available sensors +USEMODULE += saul_default +# include driver for bmx055 sensor +USEMODULE += bmx055 +# include xtimer for polling +USEMODULE += xtimer + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_bmx055/README.md b/tests/driver_bmx055/README.md new file mode 100644 index 0000000000..3fcf081b5c --- /dev/null +++ b/tests/driver_bmx055/README.md @@ -0,0 +1,14 @@ +# About +This is a test application that is polling all three SAUL devices +(Magnetometer, Accelerometer, Gyroscope) of the Bosch BMX055 +9-Axis Sensor. +This test is a copy of the standard saul test. Since it utilizes all +capabilities of the driver it is a sufficient test of the sensor. + +# Usage +The application will initialize the modules with default parameters and read +out accel, gyro and compass values each second +default parameters are: +- Magnetometer Sampling Rate: 10 Hz +- Accelerometer Range: 2G +- Gyroscope Scale: 2000 DPS diff --git a/tests/driver_bmx055/main.c b/tests/driver_bmx055/main.c new file mode 100644 index 0000000000..2eaf2153f1 --- /dev/null +++ b/tests/driver_bmx055/main.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2017 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 Bosch BMX055 9-axis Sensor driver + * + * @author Hauke Petersen + * @author Semjon Kerner + */ + +#include + +#include "xtimer.h" +#include "phydat.h" +#include "saul_reg.h" + +/** + * @brief Read the sensors every second + */ +#define INTERVAL (1LU * US_PER_SEC) + +int main(void) +{ + phydat_t res; + xtimer_ticks32_t last_wakeup = xtimer_now(); + + puts("Test application for bmx055 module"); + + while (1) { + saul_reg_t *dev = saul_reg; + + if (dev == NULL) { + puts("No SAUL devices present"); + return 1; + } + + while (dev) { + int dim = saul_reg_read(dev, &res); + printf("\nDev: %s\tType: %s\n", dev->name, + saul_class_to_str(dev->driver->type)); + phydat_dump(&res, dim); + dev = dev->next; + } + puts("\n##########################"); + + xtimer_periodic_wakeup(&last_wakeup, INTERVAL); + } + + return 0; +}