Browse Source

examples: added stand-alone SAUL example

pr/spi.typo
Hauke Petersen 6 years ago
parent
commit
b5e147c56f
  1. 26
      examples/saul/Makefile
  2. 19
      examples/saul/README.md
  3. 34
      examples/saul/main.c

26
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

19
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
```

34
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 <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;
}
Loading…
Cancel
Save