From 1469d46501ac4dd5e7eb82120cf2bcfb1abc0793 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Tue, 17 Jan 2017 12:20:50 +0100 Subject: [PATCH 1/2] test/examples/make: inc all of SAUL on saul_default - make saul_default dependent on saul_reg and auto_init_saul - adapt default example and the saul test application --- Makefile.dep | 2 ++ examples/default/Makefile | 2 -- tests/saul/Makefile | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.dep b/Makefile.dep index 0b4d6df2bd..8a443ac4a8 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -548,6 +548,8 @@ endif ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul + USEMODULE += saul_reg + USEMODULE += auto_init_saul endif ifneq (,$(filter saul,$(USEMODULE))) diff --git a/examples/default/Makefile b/examples/default/Makefile index 85e6687ed2..8b61c27c6c 100644 --- a/examples/default/Makefile +++ b/examples/default/Makefile @@ -32,9 +32,7 @@ USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps # include and auto-initialize all available sensors -USEMODULE += saul_reg USEMODULE += saul_default -USEMODULE += auto_init_saul BOARD_PROVIDES_NETIF := airfy-beacon cc2538dk fox iotlab-m3 iotlab-a8-m3 mulle \ microbit native nrf51dongle nrf52dk nrf6310 openmote-cc2538 pba-d-01-kw2x \ diff --git a/tests/saul/Makefile b/tests/saul/Makefile index d0c4790b5f..6a7e8d4b6a 100644 --- a/tests/saul/Makefile +++ b/tests/saul/Makefile @@ -2,9 +2,7 @@ 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 From b5e147c56f656a5da15008324514b2a46295d0ab Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Tue, 17 Jan 2017 11:52:02 +0100 Subject: [PATCH 2/2] examples: added stand-alone SAUL example --- examples/saul/Makefile | 26 ++++++++++++++++++++++++++ examples/saul/README.md | 19 +++++++++++++++++++ examples/saul/main.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 examples/saul/Makefile create mode 100644 examples/saul/README.md create mode 100644 examples/saul/main.c diff --git a/examples/saul/Makefile b/examples/saul/Makefile new file mode 100644 index 0000000000..1110a944d6 --- /dev/null +++ b/examples/saul/Makefile @@ -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 diff --git a/examples/saul/README.md b/examples/saul/README.md new file mode 100644 index 0000000000..ad3c652f4b --- /dev/null +++ b/examples/saul/README.md @@ -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 +``` diff --git a/examples/saul/main.c b/examples/saul/main.c new file mode 100644 index 0000000000..34e4f6b087 --- /dev/null +++ b/examples/saul/main.c @@ -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 + * + * @} + */ + +#include + +#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; +}