diff --git a/pkg/arduino_api/Kconfig b/pkg/arduino_api/Kconfig new file mode 100644 index 0000000000..ca6b4cd312 --- /dev/null +++ b/pkg/arduino_api/Kconfig @@ -0,0 +1,4 @@ +config PACKAGE_ARDUINO_API + bool "Arduino API package" + depends on TEST_KCONFIG + depends on MODULE_ARDUINO diff --git a/pkg/arduino_api/Makefile b/pkg/arduino_api/Makefile new file mode 100644 index 0000000000..6aef8114a0 --- /dev/null +++ b/pkg/arduino_api/Makefile @@ -0,0 +1,11 @@ +PKG_NAME=arduino_api +PKG_URL=https://github.com/arduino/ArduinoCore-API +PKG_VERSION=e03b65374c614130aa1b11597e07b3b5089a726d +PKG_LICENSE=LGPL-2.1 + +GITAMFLAGS = --3way + +include $(RIOTBASE)/pkg/pkg.mk + +all: + $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/api -f $(RIOTBASE)/Makefile.base MODULE=$(PKG_NAME) diff --git a/pkg/arduino_api/Makefile.dep b/pkg/arduino_api/Makefile.dep new file mode 100644 index 0000000000..60bad41674 --- /dev/null +++ b/pkg/arduino_api/Makefile.dep @@ -0,0 +1 @@ +USEMODULE += arduino diff --git a/pkg/arduino_api/Makefile.include b/pkg/arduino_api/Makefile.include new file mode 100644 index 0000000000..d8d5bd0cbe --- /dev/null +++ b/pkg/arduino_api/Makefile.include @@ -0,0 +1,3 @@ +INCLUDES += -I$(PKGDIRBASE)/arduino_api/api + +CXXEXFLAGS += -std=c++11 diff --git a/pkg/arduino_api/doc.txt b/pkg/arduino_api/doc.txt new file mode 100644 index 0000000000..67238b2100 --- /dev/null +++ b/pkg/arduino_api/doc.txt @@ -0,0 +1,6 @@ +/** + * @defgroup pkg_arduino_api Hardware independent layer of the Arduino cores + * @ingroup pkg + * @brief Hardware independent layer of the Arduino cores + * @see https://github.com/arduino/ArduinoCore-API + */ diff --git a/pkg/arduino_api/patches/0001-Chages-for-RIOT-integration.patch b/pkg/arduino_api/patches/0001-Chages-for-RIOT-integration.patch new file mode 100644 index 0000000000..9760cc7c80 --- /dev/null +++ b/pkg/arduino_api/patches/0001-Chages-for-RIOT-integration.patch @@ -0,0 +1,95 @@ +From 450ac61995792240213e2d05ab83039e4ef07df0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= +Date: Wed, 13 Oct 2021 09:25:24 +0200 +Subject: [PATCH 1/1] Chages for RIOT integration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- Fix "has not been declared" errors +- Remove attach/detach interrupt funcions + +Signed-off-by: J. David Ibáñez +--- + api/Common.h | 3 --- + api/Interrupts.h | 44 -------------------------------------------- + api/Stream.h | 2 +- + 3 files changed, 1 insertion(+), 48 deletions(-) + +diff --git api/Common.h api/Common.h +index c40a35a..c2d9de4 100644 +--- api/Common.h ++++ api/Common.h +@@ -109,9 +109,6 @@ unsigned long pulseInLong(pin_size_t pin, uint8_t state, unsigned long timeout); + void shiftOut(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder, uint8_t val); + uint8_t shiftIn(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder); + +-void attachInterrupt(pin_size_t interruptNumber, voidFuncPtr callback, PinStatus mode); +-void attachInterruptParam(pin_size_t interruptNumber, voidFuncPtrParam callback, PinStatus mode, void* param); +-void detachInterrupt(pin_size_t interruptNumber); + + void setup(void); + void loop(void); +diff --git api/Interrupts.h api/Interrupts.h +index e306fc7..e69de29 100644 +--- api/Interrupts.h ++++ api/Interrupts.h +@@ -1,44 +0,0 @@ +-#ifndef W_INTERRUPTS_CPP +-#define W_INTERRUPTS_CPP +-#ifdef __cplusplus +- +-#include +-#include +-#include +-#include "Common.h" +- +-namespace arduino { +- +-template +-using voidTemplateFuncPtrParam = void (*)(T param); +- +-template struct __container__ { +- void* param; +- voidTemplateFuncPtrParam function; +-}; +- +-// C++ only overloaded version of attachInterrupt function +-template void attachInterrupt(pin_size_t interruptNum, voidTemplateFuncPtrParam userFunc, PinStatus mode, T& param) { +- +- struct __container__ *cont = new __container__(); +- cont->param = ¶m; +- cont->function = userFunc; +- +- // TODO: check lambda scope +- // TODO: add structure to delete(__container__) when detachInterrupt() is called +- auto f = [](void* a) -> void +- { +- T param = *(T*)((struct __container__*)a)->param; +- (((struct __container__*)a)->function)(param); +- }; +- +- attachInterruptParam(interruptNum, f, mode, cont); +-} +- +-template void attachInterrupt(pin_size_t interruptNum, voidTemplateFuncPtrParam userFunc, PinStatus mode, T* param) { +- attachInterruptParam(interruptNum, (voidFuncPtrParam)userFunc, mode, (void*)param); +-} +- +-} +-#endif +-#endif +diff --git api/Stream.h api/Stream.h +index e81c71b..b22d0b2 100644 +--- api/Stream.h ++++ api/Stream.h +@@ -130,4 +130,4 @@ class Stream : public Print + + } + +-using arduino::Stream; +\ No newline at end of file ++using namespace arduino; +-- +2.32.0 +