
3 changed files with 79 additions and 0 deletions
@ -0,0 +1,11 @@
|
||||
APPLICATION = saul
|
||||
include ../Makefile.tests_common |
||||
|
||||
# include and auto-initialize all available sensors
|
||||
USEMODULE += saul_reg
|
||||
USEMODULE += saul_default
|
||||
USEMODULE += auto_init_saul
|
||||
|
||||
USEMODULE += xtimer
|
||||
|
||||
include $(RIOTBASE)/Makefile.include |
@ -0,0 +1,11 @@
|
||||
Expected result |
||||
=============== |
||||
This test application is polling all available SAUL devices periodically for |
||||
their data. This data is then printed to STDIO. |
||||
|
||||
Background |
||||
========== |
||||
The actual devices that are actually polled depend on the devices that are |
||||
configured for a particular platform. If you want to test the SAUL interface |
||||
to a particular device, you should just connect it to your BOARD and include |
||||
the corresponding device driver using the `USEMODULE` environment variable. |
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 (1000000U) |
||||
|
||||
|
||||
int main(void) |
||||
{ |
||||
phydat_t res; |
||||
uint32_t last = 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); |
||||
phydat_dump(&res, dim); |
||||
dev = dev->next; |
||||
} |
||||
|
||||
xtimer_usleep_until(&last, INTERVAL); |
||||
} |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in new issue