forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
61 lines (49 loc) · 1.2 KB
/
main.c
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
57
58
59
60
61
/*
* Copyright (C) 2015 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
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test application for the LIS3MDL 3-axis magnetometer
*
* @author René Herthel <rene-herthel@outlook.de>
*
* @}
*/
#include <stdio.h>
#include "xtimer.h"
#include "lis3mdl.h"
#include "lis3mdl_params.h"
#define SLEEP (800 * 800U)
int main(void)
{
lis3mdl_t dev;
puts("LIS3MDL test application");
puts("Initializing LIS3MDL sensor");
if (lis3mdl_init(&dev, &lis3mdl_params[0]) == 0) {
puts("[ OK ]\n");
}
else {
puts("[ FAIL ]\n");
return 1;
}
while(1) {
lis3mdl_3d_data_t mag_value;
lis3mdl_read_mag(&dev, &mag_value);
printf("Magnetometer [G]:\tX: %2d\tY: %2d\tZ: %2d\n",
mag_value.x_axis,
mag_value.y_axis,
mag_value.z_axis);
int16_t temp_value;
lis3mdl_read_temp(&dev, &temp_value);
printf("Temperature:\t\t%i°C\n", temp_value);
xtimer_usleep(SLEEP);
}
return 0;
}