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
57
58
59
60
|
/*
* Copyright (C) 2016 Freie Universitรคt Berlin
*
* 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 the SAUL interface of devices by periodically reading from
* them
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
*/
#include <stdio.h>
#include "xtimer.h"
#include "phydat.h"
#include "saul_reg.h"
/**
* @brief Read th sensors every second
*/
#define INTERVAL (1LU * US_PER_SEC)
int main(void)
{
phydat_t res;
xtimer_ticks32_t last_wakeup = xtimer_now();
puts("SAUL test application");
while (1) {
saul_reg_t *dev = saul_reg;
if (dev == NULL) {
puts("No SAUL devices present");
return 1;
}
while (dev) {
int dim = saul_reg_read(dev, &res);
printf("\nDev: %s\tType: %s\n", dev->name,
saul_class_to_str(dev->driver->type));
phydat_dump(&res, dim);
dev = dev->next;
}
puts("\n##########################");
xtimer_periodic_wakeup(&last_wakeup, INTERVAL);
}
return 0;
}
|