diff --git a/tests/driver_mma8652/Makefile b/tests/driver_mma8652/Makefile deleted file mode 100644 index c689e89ba5..0000000000 --- a/tests/driver_mma8652/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -APPLICATION = driver_mma8652 -include ../Makefile.tests_common - -FEATURES_REQUIRED = periph_i2c - -USEMODULE += mma8652 -USEMODULE += xtimer - -# set default device parameters in case they are undefined -TEST_MMA8652_I2C ?= I2C_DEV\(0\) -TEST_MMA8652_ADDR ?= 0x1D -TEST_MMA8652_USER_OFFSET_X ?= 0 -TEST_MMA8652_USER_OFFSET_Y ?= 0 -TEST_MMA8652_USER_OFFSET_Z ?= 0 -TEST_MMA8x5x_TYPE ?= MMA8x5x_TYPE_MMA8652 - -# export parameters -CFLAGS += -DTEST_MMA8652_I2C=$(TEST_MMA8652_I2C) -CFLAGS += -DTEST_MMA8652_ADDR=$(TEST_MMA8652_ADDR) -CFLAGS += -DTEST_MMA8652_USER_OFFSET_X=$(TEST_MMA8652_USER_OFFSET_X) -CFLAGS += -DTEST_MMA8652_USER_OFFSET_Y=$(TEST_MMA8652_USER_OFFSET_Y) -CFLAGS += -DTEST_MMA8652_USER_OFFSET_Z=$(TEST_MMA8652_USER_OFFSET_Z) -CFLAGS += -DTEST_MMA8x5x_TYPE=$(TEST_MMA8x5x_TYPE) - -include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_mma8652/README.md b/tests/driver_mma8652/README.md deleted file mode 100644 index 12be603b02..0000000000 --- a/tests/driver_mma8652/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# About -This is a manual test application for the MMA8652 accelerometer driver. - -# Usage -This test application will initialize the MMA8652 sensor with the following parameters: - - full scale parameter set to +/-2 g - - 6.25 Hz output data-rate - -After initialization, the sensor reads the x-, y-, z-axis values every 1 s -and prints them to STDOUT. diff --git a/tests/driver_mma8652/main.c b/tests/driver_mma8652/main.c deleted file mode 100644 index eb6965124e..0000000000 --- a/tests/driver_mma8652/main.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin - * Copyright (C) 2014 PHYTEC Messtechnik GmbH - * - * 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 MMA8652 accelerometer driver. - * - * @author Hauke Petersen - * @author Johann Fischer - * - * @} - */ - -#ifndef TEST_MMA8652_I2C -#error "TEST_MMA8652_I2C not defined" -#endif -#ifndef TEST_MMA8652_ADDR -#error "TEST_MMA8652_ADDR not defined" -#endif -#ifndef TEST_MMA8x5x_TYPE -#error "TEST_MMA8x5x_TYPE not defined" -#endif - -#include - -#include "xtimer.h" -#include "mma8652.h" - -#define SLEEP (1000 * 1000U) - -int main(void) -{ - mma8652_t dev; - int16_t x, y, z; - uint8_t status; - - puts("MMA8652 accelerometer driver test application\n"); - printf("Initializing MMA8652 accelerometer at I2C_%i... ", TEST_MMA8652_I2C); - - if (mma8652_init(&dev, TEST_MMA8652_I2C, TEST_MMA8652_ADDR, - MMA8652_DATARATE_DEFAULT, - MMA8652_FS_RANGE_DEFAULT, - TEST_MMA8x5x_TYPE) == 0) { - puts("[OK]\n"); - } - else { - puts("[Failed]"); - return -1; - } - - if (mma8652_set_user_offset(&dev, TEST_MMA8652_USER_OFFSET_X, - TEST_MMA8652_USER_OFFSET_Y, - TEST_MMA8652_USER_OFFSET_Z)) { - puts("Set user offset correction failed."); - return -1; - } - - if (mma8652_set_active(&dev)) { - puts("Measurement start failed."); - return -1; - } - - while (1) { - mma8652_read(&dev, &x, &y, &z, &status); - printf("Acceleration, in mg: X: %d Y: %d Z: %d S: %2x\n", x, y, z, status); - xtimer_usleep(SLEEP); - } - - return 0; -} diff --git a/tests/driver_mma8x5x/Makefile b/tests/driver_mma8x5x/Makefile new file mode 100644 index 0000000000..048384e2ee --- /dev/null +++ b/tests/driver_mma8x5x/Makefile @@ -0,0 +1,9 @@ +APPLICATION = driver_mma8x5x +include ../Makefile.tests_common + +FEATURES_REQUIRED = periph_i2c + +USEMODULE += mma8x5x +USEMODULE += xtimer + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_mma8x5x/README.md b/tests/driver_mma8x5x/README.md new file mode 100644 index 0000000000..e94a61c2f0 --- /dev/null +++ b/tests/driver_mma8x5x/README.md @@ -0,0 +1,18 @@ +# About +This is a manual test application for the MMA8x5x accelerometer driver. + +# Usage +This test application will initialize the MMA8x5x sensor with the following parameters: + - default device type: MMA8652 + - full scale parameter set to +/-2 g + - 200 Hz output data-rate + +To change these parameters, you can override them by setting their corresponding +defines in your build environment, e.g. +```bash +CFLAGS=-DMMA8X5X_PARAM_TYPE=MMA8X5X_TYPE_MMA8451 make ... +``` +See RIOT/drivers/mma8x5x_params.h for the default configuration. + +After initialization, the sensor reads the x-, y-, z-axis values every 100ms +and prints them to STDOUT. diff --git a/tests/driver_mma8x5x/main.c b/tests/driver_mma8x5x/main.c new file mode 100644 index 0000000000..b5ca1e94d3 --- /dev/null +++ b/tests/driver_mma8x5x/main.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 Freie Universität Berlin + * Copyright (C) 2014 PHYTEC Messtechnik GmbH + * + * 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 MMA8652 accelerometer driver. + * + * @author Hauke Petersen + * @author Johann Fischer + * + * @} + */ + +#include + +#include "xtimer.h" +#include "mma8x5x.h" +#include "mma8x5x_params.h" + +#define SLEEP (100 * 1000U) + +static mma8x5x_t dev; + +int main(void) +{ + mma8x5x_data_t data; + + puts("MMA8652 accelerometer driver test application\n"); + printf("Initializing MMA8652 accelerometer at I2C_DEV(%i)... ", + mma8x5x_params->i2c); + + if (mma8x5x_init(&dev, mma8x5x_params) == MMA8X5X_OK) { + puts("[OK]\n"); + } + else { + puts("[Failed]"); + return -1; + } + + while (1) { + mma8x5x_read(&dev, &data); + printf("Acceleration [in mg]: X: %d Y: %d Z: %d\n", + data.x, data.y, data.z); + xtimer_usleep(SLEEP); + } + + return 0; +}