1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/adxl345: add functionnal test

Signed-off-by: dylad <dylan.laduranty@mesotic.com>
This commit is contained in:
dylad 2017-03-20 22:52:58 +01:00
parent 2f801bbce9
commit 0d279ea699
3 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,7 @@
APPLICATION = driver_adxl345
include ../Makefile.tests_common
USEMODULE += xtimer
USEMODULE += adxl345
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,16 @@
# About
This is a test application for the ADXL345 accelerometer.
# Datasheet
http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf
# Usage
This test application will initialize the ADXL345 sensor with the following parameters:
- I2C device address set to 0x53
- full scale parameter set to +/-16 g
- 200 Hz output data-rate
See RIOT/drivers/adxl345_params.h for the default configuration.
After initialization, the sensor reads the x-, y-, z-axis values every 100ms
and prints them to STDOUT.

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2017 Mesotic SAS
*
* 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 ADXL345 test application
*
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
*
* @}
*/
#include <stdio.h>
#include "adxl345.h"
#include "adxl345_params.h"
#include "xtimer.h"
#define SLEEP_DELAY 100 * 1000U
int main(void)
{
adxl345_t dev;
adxl345_data_t data;
puts("ADXL345 test application");
printf("Initializing ADXL345 accelerometer at I2C_DEV(%i)... ",
adxl345_params->i2c);
if (adxl345_init(&dev, adxl345_params) == ADXL345_OK) {
puts("[OK]\n");
}
else {
puts("[Failed]");
return -1;
}
while(1) {
adxl345_read(&dev, &data);
printf("Acceleration [in mg]: X axis:%d Y axis:%d Z axis:%d\n",
data.x, data.y, data.z);
xtimer_usleep(SLEEP_DELAY);
}
return 0;
}