a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* 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;
dev.i2c = ADXL345_PARAM_I2C;
dev.addr = ADXL345_PARAM_ADDR;
puts("ADXL345 test application");
printf("Initializing ADXL345 accelerometer at I2C_DEV(%i)... ",
dev.i2c);
if (adxl345_init(&dev, (adxl345_params_t*)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",
(int)data.x, (int)data.y, (int)data.z);
xtimer_usleep(SLEEP_DELAY);
}
return 0;
}
|