Browse Source

tests/driver_lsm6dsl: add lsm6dsl driver test app

pr/rotary
Vincent Dupont 5 years ago
parent
commit
f5adafd813
  1. 6
      drivers/include/lsm6dsl.h
  2. 4
      drivers/lsm6dsl/include/lsm6dsl_internal.h
  3. 4
      drivers/lsm6dsl/include/lsm6dsl_params.h
  4. 2
      drivers/lsm6dsl/lsm6dsl.c
  5. 2
      drivers/lsm6dsl/lsm6dsl_saul.c
  6. 9
      tests/driver_lsm6dsl/Makefile
  7. 72
      tests/driver_lsm6dsl/main.c

6
drivers/include/lsm6dsl.h

@ -8,13 +8,13 @@
*/
/**
* @defgroup drivers_lsm6dsl LSM36DSL 3D accelerometer/gyroscope
* @defgroup drivers_lsm6dsl LSM6DSL 3D accelerometer/gyroscope
* @ingroup drivers_sensors
* @brief Device driver for the LSM36DSL 3D accelerometer/gyroscope
* @brief Device driver for the LSM6DSL 3D accelerometer/gyroscope
*
* @{
* @file
* @brief Device driver interface for the LSM36DSL 3D accelerometer/gyroscope.
* @brief Device driver interface for the LSM6DSL 3D accelerometer/gyroscope.
*
* @author Vincent Dupont <vincent@otakeys.com>
*/

4
drivers/lsm6dsl/include/lsm6dsl_internal.h

@ -8,11 +8,11 @@
*/
/**
* @addtogroup drivers_lsm6dsl
* @ingroup drivers_lsm6dsl
*
* @{
* @file
* @brief Internal configuration for LSM36DSL devices
* @brief Internal configuration for LSM6DSL devices
*
* @author Vincent Dupont <vincent@otakeys.com>
*/

4
drivers/lsm6dsl/include/lsm6dsl_params.h

@ -8,11 +8,11 @@
*/
/**
* @addtogroup drivers_lsm6dsl
* @ingroup drivers_lsm6dsl
*
* @{
* @file
* @brief Default configuration for LSM36DSL devices
* @brief Default configuration for LSM6DSL devices
*
* @author Vincent Dupont <vincent@otakeys.com>
*/

2
drivers/lsm6dsl/lsm6dsl.c

@ -9,7 +9,7 @@
/**
* @file
* @brief Device driver implementation for the LSM36DSL 3D accelerometer/gyroscope.
* @brief Device driver implementation for the LSM6DSL 3D accelerometer/gyroscope.
*
* @author Vincent Dupont <vincent@otakeys.com>
*/

2
drivers/lsm6dsl/lsm6dsl_saul.c

@ -9,7 +9,7 @@
/**
* @file
* @brief SAUL implementation for the LSM36DSL 3D accelerometer/gyroscope.
* @brief SAUL implementation for the LSM6DSL 3D accelerometer/gyroscope.
*
* @author Vincent Dupont <vincent@otakeys.com>
*/

9
tests/driver_lsm6dsl/Makefile

@ -0,0 +1,9 @@
APPLICATION = driver_lsm6dsl
include ../Makefile.tests_common
FEATURES_REQUIRED = periph_i2c
USEMODULE += lsm6dsl
USEMODULE += xtimer
include $(RIOTBASE)/Makefile.include

72
tests/driver_lsm6dsl/main.c

@ -0,0 +1,72 @@
/*
* Copyright (C) 2017 OTA keys S.A.
*
* 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.
*/
/**
* @file
* @brief Test application for the LSM6DSL accelerometer/gyroscope driver.
*
* @author Vincent Dupont <vincent@otakeys.com>
*
*/
#include <stdio.h>
#include "xtimer.h"
#include "lsm6dsl.h"
#include "lsm6dsl_params.h"
#define SLEEP (100 * 1000U)
int main(void)
{
lsm6dsl_t dev;
int16_t temp_value;
lsm6dsl_3d_data_t mag_value;
lsm6dsl_3d_data_t acc_value;
puts("LSM6DSL test application\n");
printf("Initializing LSM6DSL sensor at I2C_%i... ", lsm6dsl_params->i2c);
if (lsm6dsl_init(&dev, lsm6dsl_params) == 0) {
puts("[OK]\n");
}
else {
puts("[Failed]");
return 1;
}
while (1) {
if (lsm6dsl_read_acc(&dev, &acc_value) == 0) {
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");
}
if (lsm6dsl_read_gyro(&dev, &mag_value) == 0) {
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");
}
xtimer_usleep(SLEEP);
}
return 0;
}
Loading…
Cancel
Save