Merge pull request #6387 from haukepetersen/add_example_saul
examples: added stand-alone SAUL example
This commit is contained in:
commit
9666f58e6c
@ -557,6 +557,8 @@ endif
|
|||||||
|
|
||||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||||
USEMODULE += saul
|
USEMODULE += saul
|
||||||
|
USEMODULE += saul_reg
|
||||||
|
USEMODULE += auto_init_saul
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter saul,$(USEMODULE)))
|
ifneq (,$(filter saul,$(USEMODULE)))
|
||||||
|
|||||||
@ -32,9 +32,7 @@ USEMODULE += shell
|
|||||||
USEMODULE += shell_commands
|
USEMODULE += shell_commands
|
||||||
USEMODULE += ps
|
USEMODULE += ps
|
||||||
# include and auto-initialize all available sensors
|
# include and auto-initialize all available sensors
|
||||||
USEMODULE += saul_reg
|
|
||||||
USEMODULE += saul_default
|
USEMODULE += saul_default
|
||||||
USEMODULE += auto_init_saul
|
|
||||||
|
|
||||||
BOARD_PROVIDES_NETIF := airfy-beacon cc2538dk fox iotlab-m3 iotlab-a8-m3 mulle \
|
BOARD_PROVIDES_NETIF := airfy-beacon cc2538dk fox iotlab-m3 iotlab-a8-m3 mulle \
|
||||||
microbit native nrf51dongle nrf52dk nrf6310 openmote-cc2538 pba-d-01-kw2x \
|
microbit native nrf51dongle nrf52dk nrf6310 openmote-cc2538 pba-d-01-kw2x \
|
||||||
|
|||||||
26
examples/saul/Makefile
Normal file
26
examples/saul/Makefile
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# name of your application
|
||||||
|
APPLICATION = default
|
||||||
|
|
||||||
|
# If no BOARD is found in the environment, use this default:
|
||||||
|
BOARD ?= native
|
||||||
|
|
||||||
|
# This has to be the absolute path to the RIOT base directory:
|
||||||
|
RIOTBASE ?= $(CURDIR)/../..
|
||||||
|
|
||||||
|
# we want to use SAUL:
|
||||||
|
USEMODULE += saul_default
|
||||||
|
# include the shell:
|
||||||
|
USEMODULE += shell
|
||||||
|
USEMODULE += shell_commands
|
||||||
|
# additional modules for debugging:
|
||||||
|
USEMODULE += ps
|
||||||
|
|
||||||
|
# Comment this out to disable code in RIOT that does safety checking
|
||||||
|
# which is not needed in a production environment but helps in the
|
||||||
|
# development process:
|
||||||
|
CFLAGS += -DDEVELHELP
|
||||||
|
|
||||||
|
# Change this to 0 show compiler invocation lines by default:
|
||||||
|
QUIET ?= 1
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.include
|
||||||
19
examples/saul/README.md
Normal file
19
examples/saul/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
examples/saul
|
||||||
|
================
|
||||||
|
This application demonstrates the usage of SAUL and the SAUL registry.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
Simply build and flash the application for your target board:
|
||||||
|
```
|
||||||
|
BOARD=YOUR_BOARD_NAME_HERE make flash term
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you should have access to the RIOT shell on your board. For interacting
|
||||||
|
with SAUL devices, use the `saul` shell command, e.g.:
|
||||||
|
```
|
||||||
|
saul <- this will list all available devices mapped into
|
||||||
|
the SAUL registry
|
||||||
|
saul read 0 <- read values from device #0
|
||||||
|
saul write 1 0 <- write a `0` to SAUL device #1
|
||||||
|
```
|
||||||
34
examples/saul/main.c
Normal file
34
examples/saul/main.c
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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 examples
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Example for demonstrating SAUL and the SAUL registry
|
||||||
|
*
|
||||||
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "shell.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
puts("Welcome to RIOT!\n");
|
||||||
|
puts("Type `help` for help, type `saul` to see all SAUL devices\n");
|
||||||
|
|
||||||
|
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||||
|
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -2,9 +2,7 @@ APPLICATION = saul
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
# include and auto-initialize all available sensors
|
# include and auto-initialize all available sensors
|
||||||
USEMODULE += saul_reg
|
|
||||||
USEMODULE += saul_default
|
USEMODULE += saul_default
|
||||||
USEMODULE += auto_init_saul
|
|
||||||
|
|
||||||
USEMODULE += xtimer
|
USEMODULE += xtimer
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user