Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
menu "Packages"

rsource "arduino_adafruit_lsm9ds0/Kconfig"
rsource "arduino_adafruit_sensor/Kconfig"
rsource "arduino_sdi_12/Kconfig"
rsource "c25519/Kconfig"
rsource "cayenne-lpp/Kconfig"
Expand Down
33 changes: 33 additions & 0 deletions pkg/arduino_adafruit_lsm9ds0/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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_LSM9DS0
bool "Arduino Adafruit LSM9DS0 driver package"
depends on TEST_KCONFIG
select PACKAGE_ARDUINO_ADAFRUIT_SENSOR
help
Arduino driver package for the Adafruit Accelerometer + Gyro +
Magnetometer 9-DOF breakout module with the ST LSM9DS0 sensor

choice MODULE_ARDUINO_LSM9DS0
bool "Device Interface"
depends on PACKAGE_ARDUINO_ADAFRUIT_LSM9DS0
help
The driver supports LSM9DS0 connected either via SPI or
I2C bus.

config MODULE_ARDUINO_ADAFRUIT_LSM9DS0_I2C
bool "I2C"
depends on HAS_PERIPH_I2C
select MODULE_PERIPH_I2C

config MODULE_ARDUINO_ADAFRUIT_LSM9DS0_SPI
bool "SPI"
depends on HAS_PERIPH_SPI
select MODULE_PERIPH_SPI

endchoice
9 changes: 9 additions & 0 deletions pkg/arduino_adafruit_lsm9ds0/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PKG_NAME=arduino_adafruit_lsm9ds0
PKG_URL=https://github.com/adafruit/Adafruit_LSM9DS0_Library
PKG_VERSION=018133408e41a688c53a2cb4f3473457749ef15f
PKG_LICENSE=BSD

include $(RIOTBASE)/pkg/pkg.mk

all:
"$(MAKE)" -C $(PKG_SOURCE_DIR) -f $(RIOTBASE)/Makefile.base MODULE=$(PKG_NAME)
5 changes: 5 additions & 0 deletions pkg/arduino_adafruit_lsm9ds0/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# both interfaces are implemented by the driver
FEATURES_REQUIRED += periph_i2c
FEATURES_REQUIRED += periph_spi

USEPKG += arduino_adafruit_sensor
4 changes: 4 additions & 0 deletions pkg/arduino_adafruit_lsm9ds0/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PSEUDOMODULES += arduino_adafruit_lsm9ds0_i2c
PSEUDOMODULES += arduino_adafruit_lsm9ds0_spi

INCLUDES += -I$(PKGDIRBASE)/arduino_adafruit_lsm9ds0
7 changes: 7 additions & 0 deletions pkg/arduino_adafruit_lsm9ds0/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @defgroup pkg_arduino_lsm9ds0 Arduino driver package Adafruit LSM9DS0 breakout
* @ingroup pkg
* @brief Arduino driver package for the Adafruit Accelerometer + Gyro +
* Magnetometer 9-DOF breakout module with the ST LSM9DS0 sensor
* @see https://github.com/adafruit/Adafruit_LSM9DS0_Library
*/
11 changes: 11 additions & 0 deletions pkg/arduino_adafruit_sensor/Kconfig
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions pkg/arduino_adafruit_sensor/Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions pkg/arduino_adafruit_sensor/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FEATURES_REQUIRED += arduino
FEATURES_REQUIRED += cpp

USEMODULE += arduino
2 changes: 2 additions & 0 deletions pkg/arduino_adafruit_sensor/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CFLAGS += "-DARDUINO = 100"
INCLUDES += -I$(PKGDIRBASE)/arduino_adafruit_sensor
6 changes: 6 additions & 0 deletions pkg/arduino_adafruit_sensor/doc.txt
Original file line number Diff line number Diff line change
@@ -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
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 66fe43c08e09331b1810a37c7b0edbedc212f871 Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Sun, 2 Jan 2022 12:38:18 +0100
Subject: [PATCH 1/3] remove_include_Print_h

---
Adafruit_Sensor.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h
index 087eda5..77b70e1 100755
--- a/Adafruit_Sensor.h
+++ b/Adafruit_Sensor.h
@@ -24,7 +24,6 @@
#include <stdint.h>
#elif ARDUINO >= 100
#include "Arduino.h"
-#include "Print.h"
#else
#include "WProgram.h"
#endif
--
2.17.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 0bc3004057327195bff710cd85961f97dfe4a38f Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Sun, 2 Jan 2022 13:58:33 +0100
Subject: [PATCH 2/3] add_F_for_string_literals

---
Adafruit_Sensor.cpp | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Adafruit_Sensor.cpp b/Adafruit_Sensor.cpp
index 2a4513e..5b82a10 100644
--- a/Adafruit_Sensor.cpp
+++ b/Adafruit_Sensor.cpp
@@ -1,5 +1,7 @@
#include "Adafruit_Sensor.h"

+#define F(string_literal) (string_literal)
+
/**************************************************************************/
/*!
@brief Prints sensor information to serial console
--
2.17.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From a72b5fb7f3003ee738706f1949c365860e06e3f0 Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Sun, 2 Jan 2022 14:12:38 +0100
Subject: [PATCH 3/3] add_include_string_h

---
Adafruit_Sensor.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h
index 77b70e1..6844bca 100755
--- a/Adafruit_Sensor.h
+++ b/Adafruit_Sensor.h
@@ -28,6 +28,8 @@
#include "WProgram.h"
#endif

+#include <string.h>
+
/* Constants */
#define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */
#define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */
--
2.17.1

8 changes: 8 additions & 0 deletions tests/pkg_arduino_adafruit_lsm9ds0/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include ../Makefile.tests_common

DRIVER ?= arduino_adafruit_lsm9ds0_i2c

USEPKG += arduino_adafruit_lsm9ds0
USEMODULE += $(DRIVER)

include $(RIOTBASE)/Makefile.include
6 changes: 6 additions & 0 deletions tests/pkg_arduino_adafruit_lsm9ds0/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-nano \
arduino-uno \
nucleo-f031k6 \
#
3 changes: 3 additions & 0 deletions tests/pkg_arduino_adafruit_lsm9ds0/app.config.test
Original file line number Diff line number Diff line change
@@ -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_LSM9DS0=y
96 changes: 96 additions & 0 deletions tests/pkg_arduino_adafruit_lsm9ds0/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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 Test application for Arduino Adafruit LSM9DS0 driver
*
* @author Gunar Schorcht <gunar@schorcht.net>
* @}
*/

#include "arduino_board.h"

#include <SPI.h>
#include <Wire.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_LSM9DS0.h>

#define LSM9DS0_XM_CS 10 /* Accelerator/Magnetometer CS */
#define LSM9DS0_G_CS 9 /* Gyroscope CS */

int main(void)
{
/* sensor base ID = 1000 */
#if IS_USED(MODULE_ARDUINO_ADAFRUIT_LSM9DS0_SPI)
Adafruit_LSM9DS0 sensor(LSM9DS0_XM_CS, LSM9DS0_G_CS, 1000);
#else
Adafruit_LSM9DS0 sensor(1000);
#endif

Serial.print("Initialize LSM9DS0 ... ");

if(!sensor.begin()) {
Serial.print("not found");
return 1;
}
Serial.println("ok");

sensor.getAccel().printSensorDetails();
sensor.getMag().printSensorDetails();
sensor.getGyro().printSensorDetails();
sensor.getTemp().printSensorDetails();

sensor.setupAccel(sensor.LSM9DS0_ACCELRANGE_2G);
sensor.setupMag(sensor.LSM9DS0_MAGGAIN_2GAUSS);
sensor.setupGyro(sensor.LSM9DS0_GYROSCALE_245DPS);


while (1) {
sensors_event_t e_accel, e_mag, e_gyro, e_temp;

sensor.getEvent(&e_accel, &e_mag, &e_gyro, &e_temp);

Serial.print("Accel\tX: ");
Serial.print(e_accel.acceleration.x);
Serial.print(" \tY: ");
Serial.print(e_accel.acceleration.y);
Serial.print(" \tZ: ");
Serial.print(e_accel.acceleration.z);
Serial.println(" \tm/s^2");

Serial.print("Magn.\tX: ");
Serial.print(e_mag.magnetic.x);
Serial.print(" \tY: ");
Serial.print(e_mag.magnetic.y);
Serial.print(" \tZ: ");
Serial.print(e_mag.magnetic.z);
Serial.println(" \tuT");

Serial.print("Gyro\tX: ");
Serial.print(e_gyro.gyro.x);
Serial.print(" \tY: ");
Serial.print(e_gyro.gyro.y);
Serial.print(" \tZ: ");
Serial.print(e_gyro.gyro.z);
Serial.println(" \trad/s");

Serial.print("Temp: ");
Serial.print(e_temp.temperature);
Serial.println(" \t°C");

Serial.println("**********************\n");

delay(250);
}
return 0;
}
5 changes: 5 additions & 0 deletions tests/pkg_arduino_adafruit_sensor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include ../Makefile.tests_common

USEPKG += arduino_adafruit_sensor

include $(RIOTBASE)/Makefile.include
6 changes: 6 additions & 0 deletions tests/pkg_arduino_adafruit_sensor/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-uno \
arduino-nano \
nucleo-l011k4 \
#
3 changes: 3 additions & 0 deletions tests/pkg_arduino_adafruit_sensor/app.config.test
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions tests/pkg_arduino_adafruit_sensor/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2021 Gunar Schorcht <gunar@schorcht.net>
*
* 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 <gunar@schorcht.net>
*
* @}
*/

#include <string.h>

#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();
}
26 changes: 26 additions & 0 deletions tests/pkg_arduino_adafruit_sensor/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

# Copyright (C) 2021 Gunar Schorchtr <gunar@schorcht.net>
#
# 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))