drivers, lsm6dsl: update test, and add README
This commit is contained in:
parent
6d25209967
commit
9a3c983d1c
10
tests/driver_lsm6dsl/README.md
Normal file
10
tests/driver_lsm6dsl/README.md
Normal file
@ -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.
|
||||||
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 OTA keys S.A.
|
* Copyright (C) 2017 OTA keys S.A.
|
||||||
|
* 2017 HAW Hamburg
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* 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
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
@ -7,11 +8,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @ingroup tests
|
||||||
|
* @{
|
||||||
|
*
|
||||||
* @file
|
* @file
|
||||||
* @brief Test application for the LSM6DSL accelerometer/gyroscope driver.
|
* @brief Test application for the LSM6DSL accelerometer/gyroscope driver.
|
||||||
*
|
*
|
||||||
* @author Vincent Dupont <vincent@otakeys.com>
|
* @author Vincent Dupont <vincent@otakeys.com>
|
||||||
|
* @author Sebastian Meiling <s@mlng.net>
|
||||||
*
|
*
|
||||||
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -20,7 +26,7 @@
|
|||||||
#include "lsm6dsl.h"
|
#include "lsm6dsl.h"
|
||||||
#include "lsm6dsl_params.h"
|
#include "lsm6dsl_params.h"
|
||||||
|
|
||||||
#define SLEEP (100 * 1000U)
|
#define SLEEP (500UL * US_PER_MS)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@ -29,42 +35,42 @@ int main(void)
|
|||||||
lsm6dsl_3d_data_t mag_value;
|
lsm6dsl_3d_data_t mag_value;
|
||||||
lsm6dsl_3d_data_t acc_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);
|
printf("Initializing LSM6DSL sensor at I2C_%i... ", lsm6dsl_params->i2c);
|
||||||
|
|
||||||
if (lsm6dsl_init(&dev, lsm6dsl_params) == 0) {
|
if (lsm6dsl_init(&dev, lsm6dsl_params) != LSM6DSL_OK) {
|
||||||
puts("[OK]\n");
|
puts("[ERROR]");
|
||||||
}
|
|
||||||
else {
|
|
||||||
puts("[Failed]");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
puts("[SUCCESS]\n");
|
||||||
|
|
||||||
while (1) {
|
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,
|
printf("Accelerometer x: %i y: %i z: %i\n", acc_value.x,
|
||||||
acc_value.y,
|
acc_value.y,
|
||||||
acc_value.z);
|
acc_value.z);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
puts("\nFailed reading accelerometer values\n");
|
puts("[ERROR] reading accelerometer!\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) {
|
if (lsm6dsl_read_gyro(&dev, &mag_value) == LSM6DSL_OK) {
|
||||||
printf("Gyroscope x: %i y: %i z: %i\n", mag_value.x,
|
printf("Gyroscope x: %i y: %i z: %i\n", mag_value.x,
|
||||||
mag_value.y,
|
mag_value.y,
|
||||||
mag_value.z);
|
mag_value.z);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
xtimer_usleep(SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user