Merge pull request #12180 from gschorcht/sys/arduino/lib
sys/arduino: Using Arduino libraries
This commit is contained in:
commit
c7cd3d869e
11
pkg/talking_leds/Makefile
Normal file
11
pkg/talking_leds/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
PKG_NAME=talking_leds
|
||||
PKG_URL=https://github.com/fabriziop/TalkingLED
|
||||
PKG_VERSION=8ae4f2d0b736aa338f24e097dbaf876fbb385dbd
|
||||
PKG_LICENSE=MIT
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all:
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/src -f $(CURDIR)/Makefile.talking_leds
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
1
pkg/talking_leds/Makefile.dep
Normal file
1
pkg/talking_leds/Makefile.dep
Normal file
@ -0,0 +1 @@
|
||||
USEMODULE += arduino
|
||||
3
pkg/talking_leds/Makefile.include
Normal file
3
pkg/talking_leds/Makefile.include
Normal file
@ -0,0 +1,3 @@
|
||||
INCLUDES += -I$(PKGDIRBASE)/talking_leds/src
|
||||
|
||||
CXXEXFLAGS += -std=c++11
|
||||
3
pkg/talking_leds/Makefile.talking_leds
Normal file
3
pkg/talking_leds/Makefile.talking_leds
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = talking_leds
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
6
pkg/talking_leds/doc.txt
Normal file
6
pkg/talking_leds/doc.txt
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @defgroup pkg_talking_leds Talking LEDs - Arduino library for demonstration
|
||||
* @ingroup pkg
|
||||
* @brief Demonstrates the usage of Arduino libraries as packages
|
||||
* @see https://github.com/fabriziop/TalkingLED
|
||||
*/
|
||||
@ -1,15 +1,18 @@
|
||||
# Add Arduino sketches to the application as a module
|
||||
|
||||
SKETCHES = $(wildcard $(APPDIR)/*.sketch)
|
||||
|
||||
ifneq (,$(SKETCHES))
|
||||
# Define application sketches module, it will be generated into $(BINDIR)
|
||||
SKETCH_MODULE ?= arduino_sketches
|
||||
SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE)
|
||||
SKETCHES = $(wildcard $(APPDIR)/*.sketch)
|
||||
include $(RIOTBASE)/sys/arduino/sketches.inc.mk
|
||||
|
||||
# Depends on module
|
||||
USEMODULE += $(SKETCH_MODULE)
|
||||
DIRS += $(SKETCH_MODULE_DIR)
|
||||
BUILDDEPS += $(SKETCH_GENERATED_FILES)
|
||||
endif
|
||||
|
||||
# include the Arduino headers
|
||||
INCLUDES += -I$(RIOTBASE)/sys/arduino/include
|
||||
|
||||
@ -22,12 +22,23 @@
|
||||
#define ARDUINO_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
#include "periph/gpio.h"
|
||||
#include "arduino_board.h"
|
||||
}
|
||||
|
||||
#include "serialport.hpp"
|
||||
|
||||
/**
|
||||
* @brief Arduino boolean data type definion
|
||||
*/
|
||||
typedef bool boolean;
|
||||
|
||||
/**
|
||||
* @brief Arduino byte data type definion
|
||||
*/
|
||||
typedef uint8_t byte;
|
||||
|
||||
/**
|
||||
* @brief Possible pin configurations
|
||||
*/
|
||||
|
||||
5
tests/sys_arduino_lib/Makefile
Normal file
5
tests/sys_arduino_lib/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEPKG += talking_leds
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
7
tests/sys_arduino_lib/Makefile.ci
Normal file
7
tests/sys_arduino_lib/Makefile.ci
Normal file
@ -0,0 +1,7 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
nucleo-f031k6 \
|
||||
#
|
||||
46
tests/sys_arduino_lib/main.cpp
Normal file
46
tests/sys_arduino_lib/main.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Gunar Schorcht
|
||||
*
|
||||
* 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 Demonstrates the use of an Arduino library imported as package
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "arduino_board.h"
|
||||
#include "TalkingLED.h"
|
||||
|
||||
#ifndef ARDUINO_LED
|
||||
#define ARDUINO_LED (13) /* Arduino Uno LED pin */
|
||||
#endif
|
||||
|
||||
TalkingLED tled;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
tled.begin(ARDUINO_LED);
|
||||
|
||||
while (1) {
|
||||
/* message 2: short short */
|
||||
tled.message(2);
|
||||
tled.waitEnd();
|
||||
/* message 8: long long */
|
||||
tled.message(8);
|
||||
tled.waitEnd();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user