diff --git a/pkg/Kconfig b/pkg/Kconfig index 4f0269d1a5..4269e9f8f6 100644 --- a/pkg/Kconfig +++ b/pkg/Kconfig @@ -6,6 +6,7 @@ # menu "Packages" +rsource "arduino_adafruit_sensor/Kconfig" rsource "arduino_sdi_12/Kconfig" rsource "c25519/Kconfig" rsource "cayenne-lpp/Kconfig" diff --git a/pkg/arduino_adafruit_sensor/Kconfig b/pkg/arduino_adafruit_sensor/Kconfig new file mode 100644 index 0000000000..ac5dc7d5bc --- /dev/null +++ b/pkg/arduino_adafruit_sensor/Kconfig @@ -0,0 +1,11 @@ +# Copyright (c) 2021 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. +# + +config PACKAGE_ARDUINO_ADAFRUIT_SENSOR + bool "Arduino Adafruit Unified Sensor Driver package" + depends on TEST_KCONFIG + select MODULE_ARDUINO diff --git a/pkg/arduino_adafruit_sensor/Makefile b/pkg/arduino_adafruit_sensor/Makefile new file mode 100644 index 0000000000..b7e2976d94 --- /dev/null +++ b/pkg/arduino_adafruit_sensor/Makefile @@ -0,0 +1,9 @@ +PKG_NAME=arduino_adafruit_sensor +PKG_URL=https://github.com/adafruit/Adafruit_Sensor +PKG_VERSION=334044cc0bd087ff93629cef9ae8efc14e88ec73 +PKG_LICENSE=Apache-2.0 + +include $(RIOTBASE)/pkg/pkg.mk + +all: + $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR) -f $(RIOTBASE)/Makefile.base diff --git a/pkg/arduino_adafruit_sensor/Makefile.dep b/pkg/arduino_adafruit_sensor/Makefile.dep new file mode 100644 index 0000000000..6b53d608fd --- /dev/null +++ b/pkg/arduino_adafruit_sensor/Makefile.dep @@ -0,0 +1,4 @@ +FEATURES_REQUIRED += arduino +FEATURES_REQUIRED += cpp + +USEMODULE += arduino diff --git a/pkg/arduino_adafruit_sensor/Makefile.include b/pkg/arduino_adafruit_sensor/Makefile.include new file mode 100644 index 0000000000..bcd54c5878 --- /dev/null +++ b/pkg/arduino_adafruit_sensor/Makefile.include @@ -0,0 +1,2 @@ +CFLAGS += "-DARDUINO = 100" +INCLUDES += -I$(PKGDIRBASE)/arduino_adafruit_sensor diff --git a/pkg/arduino_adafruit_sensor/doc.txt b/pkg/arduino_adafruit_sensor/doc.txt new file mode 100644 index 0000000000..e24e00c226 --- /dev/null +++ b/pkg/arduino_adafruit_sensor/doc.txt @@ -0,0 +1,6 @@ +/** + * @defgroup pkg_adafruit_sensor Adafruit Unified Sensor Driver + * @ingroup pkg + * @brief Adafruit Unified Sensor Driver + * @see https://github.com/adafruit/Adafruit_Sensor + */ diff --git a/pkg/arduino_adafruit_sensor/patches/0001-remove_include_Print_h.patch b/pkg/arduino_adafruit_sensor/patches/0001-remove_include_Print_h.patch new file mode 100644 index 0000000000..3a22fcb3a4 Binary files /dev/null and b/pkg/arduino_adafruit_sensor/patches/0001-remove_include_Print_h.patch differ diff --git a/pkg/arduino_adafruit_sensor/patches/0002-add_F_for_string_literals.patch b/pkg/arduino_adafruit_sensor/patches/0002-add_F_for_string_literals.patch new file mode 100644 index 0000000000..360f9eb1e7 Binary files /dev/null and b/pkg/arduino_adafruit_sensor/patches/0002-add_F_for_string_literals.patch differ diff --git a/pkg/arduino_adafruit_sensor/patches/0003-add_include_string_h.patch b/pkg/arduino_adafruit_sensor/patches/0003-add_include_string_h.patch new file mode 100644 index 0000000000..87a673c9c4 Binary files /dev/null and b/pkg/arduino_adafruit_sensor/patches/0003-add_include_string_h.patch differ diff --git a/tests/pkg_arduino_adafruit_sensor/Makefile b/tests/pkg_arduino_adafruit_sensor/Makefile new file mode 100644 index 0000000000..45ca1e8ed0 --- /dev/null +++ b/tests/pkg_arduino_adafruit_sensor/Makefile @@ -0,0 +1,5 @@ +include ../Makefile.tests_common + +USEPKG += arduino_adafruit_sensor + +include $(RIOTBASE)/Makefile.include diff --git a/tests/pkg_arduino_adafruit_sensor/Makefile.ci b/tests/pkg_arduino_adafruit_sensor/Makefile.ci new file mode 100644 index 0000000000..13ab4aacc2 --- /dev/null +++ b/tests/pkg_arduino_adafruit_sensor/Makefile.ci @@ -0,0 +1,6 @@ +BOARD_INSUFFICIENT_MEMORY := \ + arduino-duemilanove \ + arduino-uno \ + arduino-nano \ + nucleo-l011k4 \ + # diff --git a/tests/pkg_arduino_adafruit_sensor/app.config.test b/tests/pkg_arduino_adafruit_sensor/app.config.test new file mode 100644 index 0000000000..8789d8831d --- /dev/null +++ b/tests/pkg_arduino_adafruit_sensor/app.config.test @@ -0,0 +1,3 @@ +# this file enables modules defined in Kconfig. Do not use this file for +# application configuration. This is only needed during migration. +CONFIG_PACKAGE_ARDUINO_ADAFRUIT_SENSOR=y diff --git a/tests/pkg_arduino_adafruit_sensor/main.cpp b/tests/pkg_arduino_adafruit_sensor/main.cpp new file mode 100644 index 0000000000..8227bcca84 --- /dev/null +++ b/tests/pkg_arduino_adafruit_sensor/main.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2021 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 Tests the Adafruit Unified Sensor Drive + * + * @author Gunar Schorcht + * + * @} + */ + +#include + +#include "Adafruit_Sensor.h" + +class ADXL345 : public Adafruit_Sensor +{ + public: + bool getEvent(sensors_event_t *) { return false; }; + void getSensor(sensor_t *sensor); +}; + +void ADXL345::getSensor(sensor_t *s) +{ + memset(s, 0, sizeof(sensor_t)); + strncpy(s->name, "ADXL345", ARRAY_SIZE(s->name) - 1); + s->version = 1; + s->sensor_id = 12345; + s->type = SENSOR_TYPE_ACCELEROMETER; + s->min_delay = 0; + s->min_value = -156.9064F; /* -16g = 156.9064 m/s^2 */ + s->max_value = 156.9064F; /* 16g = 156.9064 m/s^2 */ + s->resolution = 0.03923F; /* 4mg = 0.0392266 m/s^2 */ +} + +int main(void) +{ + ADXL345 adxl345; + adxl345.printSensorDetails(); +} diff --git a/tests/pkg_arduino_adafruit_sensor/tests/01-run.py b/tests/pkg_arduino_adafruit_sensor/tests/01-run.py new file mode 100755 index 0000000000..df0092a0bf --- /dev/null +++ b/tests/pkg_arduino_adafruit_sensor/tests/01-run.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2021 Gunar Schorchtr +# +# 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. + +import sys +from testrunner import run + + +def testfunc(child): + child.expect_exact('------------------------------------') + child.expect_exact('Sensor: ADXL345') + child.expect_exact('Type: Acceleration (m/s2)') + child.expect_exact('Driver Ver: 1') + child.expect_exact('Unique ID: 12345') + child.expect_exact('Min Value: -156.90') + child.expect_exact('Max Value: 156.90') + child.expect_exact('Resolution: 0.03') + child.expect_exact('------------------------------------') + + +if __name__ == "__main__": + sys.exit(run(testfunc))