2015-09-18 23:00:31 +02:00
|
|
|
/**
|
|
|
|
* @defgroup sys_arduino Arduino
|
|
|
|
* @ingroup sys
|
|
|
|
* @brief Arduino in RIOT
|
|
|
|
*
|
|
|
|
* @section sec_about About
|
|
|
|
*
|
|
|
|
* This module enables users to run unmodified Arduino sketches in RIOT. For
|
|
|
|
* this we aim at supporting the full Arduino API.
|
|
|
|
*
|
|
|
|
* The support of the Arduino API in RIOT is useful for multiple reasons:
|
|
|
|
* - starting point for beginners
|
|
|
|
* - run your existing sketches on any non-Arduino hardware supported by RIOT
|
|
|
|
* - makes it easy to move from Arduino to RIOT
|
2016-06-12 10:45:25 +02:00
|
|
|
* - use Arduino device drivers in RIOT
|
2015-09-18 23:00:31 +02:00
|
|
|
* - is fun to implement :-)
|
|
|
|
*
|
|
|
|
* Refer to @ref sys_arduino_api for the actual API documentation
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @section sec_usage General usage
|
|
|
|
*
|
2015-12-04 17:25:36 +01:00
|
|
|
* To run your Arduino sketch in RIOT, just follow these steps:
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
|
|
|
* -# create an empty application
|
|
|
|
* -# add the `arduino` module to your application, your `Makefile` should now
|
|
|
|
* look something like this:
|
|
|
|
* @code
|
|
|
|
* APPLICATION = YOUR_APP_NAME
|
|
|
|
* BOARD ?= YOUR_TARGET_PLATFORM
|
|
|
|
* RIOTBASE ?= PATH_TO_RIOT_ROOT
|
|
|
|
*
|
|
|
|
* USEMODULE += arduino
|
|
|
|
*
|
|
|
|
* include $(RIOTBASE)/Makefile.include
|
|
|
|
* @endcode
|
|
|
|
*
|
2015-12-04 17:25:36 +01:00
|
|
|
* -# copy your Arduino sktech(es) into your application folder. Currently they
|
2015-09-18 23:00:31 +02:00
|
|
|
* must have the file ending `*.sketch` to be processed.
|
|
|
|
* -# build, flash, and run your application the usual RIOT-way: simply call
|
|
|
|
* `make all`, `make flash`, `make term`, etc.
|
|
|
|
*
|
2019-10-23 21:16:21 +02:00
|
|
|
* That's all. As bonus you can of course use any existing RIOT code inside your
|
2015-09-18 23:00:31 +02:00
|
|
|
* Arduino sketches - you simply have to add the includes to your sketch and
|
|
|
|
* the corresponding modules to your `Makefile`.
|
|
|
|
*
|
|
|
|
* @note So far, all Arduino sketches MUST have the file ending `*.sketch` to
|
|
|
|
* be recognized by RIOT's build system
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @section sec_concept Concept
|
|
|
|
*
|
|
|
|
* For enabling RIOT to run Arduino sketches, we extended the build system to
|
|
|
|
* handle `*.sketch` files and we implemented the Arduino API using RIOT's
|
|
|
|
* native functions.
|
|
|
|
*
|
|
|
|
* @subsection sec_concept_build Extension of the build system
|
|
|
|
*
|
2017-09-28 12:14:10 +02:00
|
|
|
* Building Arduino sketches in RIOT is done in a three step process.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
2017-09-28 12:14:10 +02:00
|
|
|
* First, the make system defines a generated `arduino_sketches` module placed
|
|
|
|
* into `$(BINDIR)`
|
|
|
|
* [Arduino sketches makefile](https://github.com/RIOT-OS/RIOT/tree/master/sys/arduino/sketches.inc.mk),
|
|
|
|
* which is included from the
|
2015-09-18 23:00:31 +02:00
|
|
|
* [Makefile.include](https://github.com/RIOT-OS/RIOT/tree/master/sys/arduino/Makefile.include)
|
|
|
|
* of the RIOT Arduino module.
|
2017-09-28 12:14:10 +02:00
|
|
|
* The generated module is added to used modules and build directories.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
2017-09-28 12:14:10 +02:00
|
|
|
* Second, as prerequisites for the `link` target, the make system will create
|
|
|
|
* the module into `$(BINDIR)/arduino_sketches` with an `arduino_sketches.cpp`
|
|
|
|
* source file.
|
|
|
|
* Into this file, it copies some Arduino glue code (
|
2015-09-18 23:00:31 +02:00
|
|
|
* [pre.snip](https://github.com/RIOT-OS/RIOT/blob/master/sys/arduino/pre.snip)
|
|
|
|
* and
|
|
|
|
* [post.snip](https://github.com/RIOT-OS/RIOT/blob/master/sys/arduino/post.snip))
|
|
|
|
* together with the contents of all `*.sketch` files contained in the
|
|
|
|
* application folder.
|
|
|
|
*
|
2017-09-28 12:14:10 +02:00
|
|
|
* Third, the RIOT make system is called as usual, building the generated
|
|
|
|
* library with the Arduino code and including it in the final firmware.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
|
|
|
* @subsection sec_conecpt_api Implementation of the Arduino API
|
|
|
|
*
|
|
|
|
* For supporting the Arduino API, we have created our own function and class
|
|
|
|
* definitions, using the exact same signatures as in the original Arduino
|
|
|
|
* header files. These headers are then implemented using standard RIOT APIs,
|
|
|
|
* e.g. the peripheral drivers, `xtimer`, etc.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @section sec_boardsupport Add Arduino support to a board
|
|
|
|
*
|
2023-06-23 15:42:08 +02:00
|
|
|
* @note As prerequisite, the board must have support for C++. Support for
|
|
|
|
* the standard C++ lib (feature `libstdcpp`) is not required.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
2023-06-23 15:42:08 +02:00
|
|
|
* As a minimum requirement, the features `arduino_pins` is a hard dependency.
|
|
|
|
* See @ref iomaps-mapping-gpio what a board needs to provide this.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
2023-06-23 15:42:08 +02:00
|
|
|
* Additional mappings for analog pins (see @ref iomaps-mapping-adc) and PWM
|
|
|
|
* pins (see @ref iomaps-mapping-pwm) is required to be able to use
|
|
|
|
* `analogRead()` and `analogWrite()`.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
2023-06-23 15:42:08 +02:00
|
|
|
* See also @ref iomaps on how a board can provide more I/O mappings and even
|
|
|
|
* declare electrical and mechanical compatibility with common Arduino form
|
|
|
|
* factors.
|
2015-09-18 23:00:31 +02:00
|
|
|
*
|
|
|
|
* @section sec_todo Open issues
|
|
|
|
*
|
|
|
|
* @todo Make it possible to bootstrap Arduino code manually from any RIOT
|
|
|
|
* application. Include a pseudomule as e.g. arduino_base, which does not
|
|
|
|
* implement a main function calling `setup()` and `loop()`, so these
|
|
|
|
* functions have to be called manually from a RIOT application.
|
|
|
|
* @todo Implement analog outputs (PWM mapping)
|
|
|
|
* @todo Implement analog inputs (ADC mapping)
|
|
|
|
* @todo Add means to include various Arduino Libraries (maybe as pkg?)
|
|
|
|
* @todo Implement anything else that is missing...
|
|
|
|
* @todo Adapt Arduino build script, so sketches do not have to have the file
|
|
|
|
* ending `*.sketch` anymore
|
|
|
|
*/
|