diff --git a/tests/driver_lsm6dsl/README.md b/tests/driver_lsm6dsl/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3d01dfa10013bad4a3bd28d7d37fe6495d531f3b --- /dev/null +++ b/tests/driver_lsm6dsl/README.md @@ -0,0 +1,10 @@ +# About +This is a manual test application for the ST LSM6DSL sensor driver. + +# Usage + +After successful initialization, the sensor reads the accelerometer, gyroscope, +and temperature values every 500ms and prints them to the STDOUT. If device +initialization fails the tests exits with 1, otherwise it runs forever. + +Note: reading sensor values may fail even on successful initialization. diff --git a/tests/driver_lsm6dsl/main.c b/tests/driver_lsm6dsl/main.c index f37a0fe480b066af651fb3628ce0e1e89d28d3f3..7ea329f1780d649ae059befd7f65cb315d39c082 100644 --- a/tests/driver_lsm6dsl/main.c +++ b/tests/driver_lsm6dsl/main.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2017 OTA keys S.A. + * 2017 HAW Hamburg * * 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 @@ -7,11 +8,16 @@ */ /** + * @ingroup tests + * @{ + * * @file * @brief Test application for the LSM6DSL accelerometer/gyroscope driver. * * @author Vincent Dupont <vincent@otakeys.com> + * @author Sebastian Meiling <s@mlng.net> * + * @} */ #include <stdio.h> @@ -20,7 +26,7 @@ #include "lsm6dsl.h" #include "lsm6dsl_params.h" -#define SLEEP (100 * 1000U) +#define SLEEP (500UL * US_PER_MS) int main(void) { @@ -29,42 +35,42 @@ int main(void) lsm6dsl_3d_data_t mag_value; lsm6dsl_3d_data_t acc_value; - puts("LSM6DSL test application\n"); + puts("LSM6DSL test application"); printf("Initializing LSM6DSL sensor at I2C_%i... ", lsm6dsl_params->i2c); - if (lsm6dsl_init(&dev, lsm6dsl_params) == 0) { - puts("[OK]\n"); - } - else { - puts("[Failed]"); + if (lsm6dsl_init(&dev, lsm6dsl_params) != LSM6DSL_OK) { + puts("[ERROR]"); return 1; } + puts("[SUCCESS]\n"); while (1) { - if (lsm6dsl_read_acc(&dev, &acc_value) == 0) { + if (lsm6dsl_read_acc(&dev, &acc_value) == LSM6DSL_OK) { printf("Accelerometer x: %i y: %i z: %i\n", acc_value.x, acc_value.y, acc_value.z); } else { - puts("\nFailed reading accelerometer values\n"); - } - if (lsm6dsl_read_temp(&dev, &temp_value) == 0) { - printf("Temperature value: %i degrees\n", temp_value); - } - else { - puts("\nFailed reading value\n"); + puts("[ERROR] reading accelerometer!\n"); } - if (lsm6dsl_read_gyro(&dev, &mag_value) == 0) { + if (lsm6dsl_read_gyro(&dev, &mag_value) == LSM6DSL_OK) { printf("Gyroscope x: %i y: %i z: %i\n", mag_value.x, mag_value.y, mag_value.z); } else { - puts("\nFailed reading Gyroscope values\n"); + puts("[ERROR] reading gyroscope!\n"); + } + + if (lsm6dsl_read_temp(&dev, &temp_value) == LSM6DSL_OK) { + printf("Temperature [in °C x 100]: %i \n", temp_value); + } + else { + puts("[ERROR] reading temperature!\n"); } + puts(""); xtimer_usleep(SLEEP); }