summaryrefslogtreecommitdiff
path: root/recipes-devtools
diff options
context:
space:
mode:
authorStefan Müller-Klieser <S.Mueller-Klieser@phytec.de>2017-03-20 16:46:41 +0100
committerStefan Müller-Klieser <s.mueller-klieser@phytec.de>2017-03-28 15:24:58 +0200
commit7cfac0c14610f91027f4da199c0a161c4ac13e42 (patch)
treece2895e14c987d29e066cfa98c94895afb688b91 /recipes-devtools
parent4833ba5800a88616421da2c0c0d2b041ba9aab4d (diff)
downloadmeta-yogurt-7cfac0c14610f91027f4da199c0a161c4ac13e42.tar.bz2
meta-yogurt-7cfac0c14610f91027f4da199c0a161c4ac13e42.zip
upm: add recipe
Libupm provides user space convenience drivers for sensors used by many maker projects, like groves and shields for Arduino and friends. Patches add support for recent sensors used on the phyNODE. Patches are submitted upstream, status unclear. Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
Diffstat (limited to 'recipes-devtools')
-rw-r--r--recipes-devtools/upm/upm/0001-FindNodejs.cmake-parse-V8_MAJOR_VERSION-from-nodejs-.patch52
-rw-r--r--recipes-devtools/upm/upm/0001-tcs37727-Added-upm-support-for-color-sensor-TCS37727.patch840
-rw-r--r--recipes-devtools/upm/upm/0002-hdc1000-Added-upm-support-for-sensor-HDC1000.patch407
-rw-r--r--recipes-devtools/upm/upm/0003-mag3110-Added-upm-support-for-sensor-MAG3110.patch676
-rw-r--r--recipes-devtools/upm/upm/0004-tmp006-Added-upm-support-for-sensor-TMP006.patch561
-rw-r--r--recipes-devtools/upm/upm/0005-mma8x5x-Added-upm-support-for-some-MMA8X5X-sensors.patch933
-rw-r--r--recipes-devtools/upm/upm/0006-examples-Added-some-examples-for-added-sensors.patch815
-rw-r--r--recipes-devtools/upm/upm_1.1.0.bb100
8 files changed, 4384 insertions, 0 deletions
diff --git a/recipes-devtools/upm/upm/0001-FindNodejs.cmake-parse-V8_MAJOR_VERSION-from-nodejs-.patch b/recipes-devtools/upm/upm/0001-FindNodejs.cmake-parse-V8_MAJOR_VERSION-from-nodejs-.patch
new file mode 100644
index 0000000..d4d99f7
--- /dev/null
+++ b/recipes-devtools/upm/upm/0001-FindNodejs.cmake-parse-V8_MAJOR_VERSION-from-nodejs-.patch
@@ -0,0 +1,52 @@
+From 7acc97b2d9f366513e2a95a86a889df426f7e689 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20M=C3=BCller-Klieser?= <s.mueller-klieser@phytec.de>
+Date: Mon, 13 Feb 2017 16:05:53 +0100
+Subject: [PATCH] FindNodejs.cmake: parse V8_MAJOR_VERSION from nodejs header
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Current version fails to build with a cross compile toolchain. We can
+use the headers from nodejs to parse the version numbers instead of
+executing node, which will not work in a cross setup. As no other
+version gets used in the current src tree, only convert V8 major for a
+start.
+
+Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
+---
+ cmake/modules/FindNode.cmake | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/cmake/modules/FindNode.cmake b/cmake/modules/FindNode.cmake
+index c28484e..1c4e29e 100644
+--- a/cmake/modules/FindNode.cmake
++++ b/cmake/modules/FindNode.cmake
+@@ -40,6 +40,10 @@ find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
+ if (NOT V8_ROOT_DIR)
+ unset(NODEJS_INCLUDE_DIRS)
+ message(ERROR " - v8.h not found")
++else()
++ message(STATUS "Parsing v8 version from header...")
++ file(STRINGS "${V8_ROOT_DIR}/v8-version.h" V8HEADER)
++ STRING(REGEX REPLACE ".*V8_MAJOR_VERSION ([0-9]+).*" "\\1" V8_VERSION_MAJOR "${V8HEADER}")
+ endif()
+
+ # Check that uv.h is in NODEJS_INCLUDE_DIRS
+@@ -81,10 +85,12 @@ if (NODEJS_EXECUTABLE)
+ set (NODE_VERSION_MAJOR "0")
+ set (NODE_VERSION_MINOR "10")
+ set (NODE_VERSION_PATCH "30")
+- set (V8_VERSION_MAJOR "3")
++ if ("${V8_VERSION_MAJOR}" STREQUAL "")
++ set (V8_VERSION_MAJOR "3")
++ endif()
+ set (V8_VERSION_MINOR "28")
+ set (V8_VERSION_PATCH "72")
+- set (V8_VERSION_STRING "3.28.72")
++ set (V8_VERSION_STRING "${V8_VERSION_MAJOR}.28.72")
+ message ("defaulted to node 0.10.30")
+ endif ()
+ string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm/0001-tcs37727-Added-upm-support-for-color-sensor-TCS37727.patch b/recipes-devtools/upm/upm/0001-tcs37727-Added-upm-support-for-color-sensor-TCS37727.patch
new file mode 100644
index 0000000..8dddd7d
--- /dev/null
+++ b/recipes-devtools/upm/upm/0001-tcs37727-Added-upm-support-for-color-sensor-TCS37727.patch
@@ -0,0 +1,840 @@
+From e86df782c29332d7194b19ac49ec1f7a30ca8185 Mon Sep 17 00:00:00 2001
+From: Norbert Wesp <nwesp@phytec.de>
+Date: Fri, 10 Feb 2017 14:36:34 +0100
+Subject: [PATCH 1/6] tcs37727: Added upm support for color sensor TCS37727
+
+TCS37727 is a Color Light-To-Digital Converter. I also added
+the manufacturer 'ams' of TCS37727. Examples will be added
+at a later commit.
+
+Signed-off-by: Norbert Wesp <nwesp@phytec.de>
+---
+ src/groups.md | 57 ++-----
+ src/tcs37727/CMakeLists.txt | 5 +
+ src/tcs37727/javaupm_tcs37727.i | 19 +++
+ src/tcs37727/jsupm_tcs37727.i | 8 +
+ src/tcs37727/pyupm_tcs37727.i | 15 ++
+ src/tcs37727/tcs37727.cpp | 349 ++++++++++++++++++++++++++++++++++++++++
+ src/tcs37727/tcs37727.hpp | 289 +++++++++++++++++++++++++++++++++
+ 7 files changed, 696 insertions(+), 46 deletions(-)
+ create mode 100644 src/tcs37727/CMakeLists.txt
+ create mode 100644 src/tcs37727/javaupm_tcs37727.i
+ create mode 100644 src/tcs37727/jsupm_tcs37727.i
+ create mode 100644 src/tcs37727/pyupm_tcs37727.i
+ create mode 100644 src/tcs37727/tcs37727.cpp
+ create mode 100644 src/tcs37727/tcs37727.hpp
+
+diff --git a/src/groups.md b/src/groups.md
+index e907141..d56759c 100644
+--- a/src/groups.md
++++ b/src/groups.md
+@@ -81,7 +81,7 @@ and is not meant to be installed anywhere.
+ @brief Light sensors with special function: Color recognition
+
+
+-@defgroup compass Compass/Gyro/Magnetometers
++@defgroup compass Compass/Gyro/Magnometers
+ @ingroup bycat
+ @brief Measure magnetic field to give rotation or heading
+
+@@ -275,6 +275,11 @@ and is not meant to be installed anywhere.
+ @brief Amphenol
+
+
++@defgroup ams ams AG
++@ingroup byman
++@brief ams AG
++
++
+ @defgroup bosch Bosch
+ @ingroup byman
+ @brief Bosch
+@@ -360,6 +365,11 @@ and is not meant to be installed anywhere.
+ @brief Silicon Labs
+
+
++@defgroup sparkfun Sparkfun
++@ingroup byman
++@brief Sparkfun
++
++
+ @defgroup stmicro STMicroelectronics
+ @ingroup byman
+ @brief STMicroelectronics
+@@ -375,51 +385,6 @@ and is not meant to be installed anywhere.
+ @brief Veris Industries
+
+
+-@defgroup aeon Aeon Labs
+-@ingroup byman
+-@brief Aeon Labs
+-
+-
+-@defgroup trane Trane
+-@ingroup byman
+-@brief Trane Incorporated
+-
+-
+-@defgroup avago Avago Technologies
+-@ingroup byman
+-@brief Avago Technologies
+-
+-
+-@defgroup catnip Catnip Electronics
+-@ingroup byman
+-@brief Catnip Electronics
+-
+-
+-@defgroup kionix Kionix Incorporated
+-@ingroup byman
+-@brief Kionix Incorporated
+-
+-
+-@defgroup maxbotix Maxbotix
+-@ingroup byman
+-@brief Maxbotix
+-
+-
+-@defgroup maxim Maxim Integrated
+-@ingroup byman
+-@brief Maxim Integrated
+-
+-
+-@defgroup sainsmart sainSMART
+-@ingroup byman
+-@brief sainSMART
+-
+-
+-@defgroup semtech Semtech Corporation
+-@ingroup byman
+-@brief Semtech Corporation
+-
+-
+ ### Groups for the various Starter Kits ###
+
+
+diff --git a/src/tcs37727/CMakeLists.txt b/src/tcs37727/CMakeLists.txt
+new file mode 100644
+index 0000000..7046b95
+--- /dev/null
++++ b/src/tcs37727/CMakeLists.txt
+@@ -0,0 +1,5 @@
++set (libname "tcs37727")
++set (libdescription "Color Sensor")
++set (module_src ${libname}.cpp)
++set (module_hpp ${libname}.hpp)
++upm_module_init()
+diff --git a/src/tcs37727/javaupm_tcs37727.i b/src/tcs37727/javaupm_tcs37727.i
+new file mode 100644
+index 0000000..ac6c4bc
+--- /dev/null
++++ b/src/tcs37727/javaupm_tcs37727.i
+@@ -0,0 +1,19 @@
++%module javaupm_tcs37727
++%include "../upm.i"
++
++%{
++ #include "tcs37727.hpp"
++%}
++
++%include "tcs37727.hpp"
++
++%pragma(java) jniclasscode=%{
++ static {
++ try {
++ System.loadLibrary("javaupm_tcs37727");
++ } catch (UnsatisfiedLinkError e) {
++ System.err.println("Native code library failed to load. \n" + e);
++ System.exit(1);
++ }
++ }
++%}
+\ No newline at end of file
+diff --git a/src/tcs37727/jsupm_tcs37727.i b/src/tcs37727/jsupm_tcs37727.i
+new file mode 100644
+index 0000000..823d6a3
+--- /dev/null
++++ b/src/tcs37727/jsupm_tcs37727.i
+@@ -0,0 +1,8 @@
++%module jsupm_tcs37727
++%include "../upm.i"
++
++%{
++ #include "tcs37727.hpp"
++%}
++
++%include "tcs37727.hpp"
+diff --git a/src/tcs37727/pyupm_tcs37727.i b/src/tcs37727/pyupm_tcs37727.i
+new file mode 100644
+index 0000000..a9a48c2
+--- /dev/null
++++ b/src/tcs37727/pyupm_tcs37727.i
+@@ -0,0 +1,15 @@
++// Include doxygen-generated documentation
++%include "pyupm_doxy2swig.i"
++%module pyupm_tcs37727
++%include "../upm.i"
++
++%feature("autodoc", "3");
++
++#ifdef DOXYGEN
++%include "tcs37727_doc.i"
++#endif
++
++%include "tcs37727.hpp"
++%{
++ #include "tcs37727.hpp"
++%}
+diff --git a/src/tcs37727/tcs37727.cpp b/src/tcs37727/tcs37727.cpp
+new file mode 100644
+index 0000000..aa0add0
+--- /dev/null
++++ b/src/tcs37727/tcs37727.cpp
+@@ -0,0 +1,349 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver tcs37727 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <iostream>
++#include <string>
++#include <stdexcept>
++
++#include <unistd.h>
++#include <stdlib.h>
++#include <endian.h>
++
++#include "tcs37727.hpp"
++
++using namespace upm;
++
++TCS37727::TCS37727(int bus, int atime_us, int devAddr) : m_i2ControlCtx(bus) {
++ s_data->red = 0;
++ s_data->green = 0;
++ s_data->blue = 0;
++ s_data->clear = 0;
++ s_data->lux = 0;
++ s_data->ct = 0;
++ s_again = 4;
++
++ m_name = TCS37727_NAME;
++
++ m_controlAddr = devAddr;
++ m_bus = bus;
++
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ if (checkID() != 0) {
++ /* sensor_id does not match! maybe wrong sensor chosen? */
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": checkID() failed");
++ }
++
++ ret = m_i2ControlCtx.writeReg(TCS37727_CONTROL, TCS37727_CONTROL_AGAIN_4);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++
++ ret = m_i2ControlCtx.writeReg(TCS37727_ATIME,
++ TCS37727_ATIME_TO_REG(atime_us));
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++
++ s_atime_us = atime_us;
++}
++
++int
++TCS37727::checkID(void)
++{
++ uint8_t id;
++
++ id = m_i2ControlCtx.readReg(TCS37727_DEVICE_ID_REG);
++
++ if (id != TCS37727_DEVICE_ID) {
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++TCS37727::setActive(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(TCS37727_ENABLE);
++
++ reg |= (TCS37727_ENABLE_AEN | TCS37727_ENABLE_PON);
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(TCS37727_ENABLE, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++ return 0;
++}
++
++int
++TCS37727::setStandby(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(TCS37727_ENABLE);
++
++ reg &= ~TCS37727_ENABLE_AEN;
++ if (!(reg & TCS37727_ENABLE_PEN)) {
++ reg &= ~TCS37727_ENABLE_PON;
++ }
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(TCS37727_ENABLE, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++ return 0;
++}
++
++uint8_t
++TCS37727::trimGain(int rawc)
++{
++ uint8_t reg_again = 0;
++ int val_again = s_again;
++ uint8_t reg;
++
++ if (rawc < TCS37727_AG_THRESHOLD_LOW) {
++ switch (val_again) {
++ case 1:
++ reg_again = TCS37727_CONTROL_AGAIN_4;
++ val_again = 4;
++ break;
++
++ case 4:
++ reg_again = TCS37727_CONTROL_AGAIN_16;
++ val_again = 16;
++ break;
++
++ case 16:
++ reg_again = TCS37727_CONTROL_AGAIN_60;
++ val_again = 60;
++ break;
++
++ case 60:
++ default:
++ return -1;
++ }
++ }
++ else if (rawc > TCS37727_AG_THRESHOLD_HIGH) {
++ switch (val_again) {
++ case 60:
++ reg_again = TCS37727_CONTROL_AGAIN_16;
++ val_again = 16;
++ break;
++
++ case 16:
++ reg_again = TCS37727_CONTROL_AGAIN_4;
++ val_again = 4;
++ break;
++
++ case 4:
++ reg_again = TCS37727_CONTROL_AGAIN_1;
++ val_again = 1;
++ break;
++
++ case 1:
++ default:
++ return -1;
++ }
++ }
++ else {
++ return 0;
++ }
++
++ reg = m_i2ControlCtx.readReg(TCS37727_CONTROL);
++
++ reg &= ~TCS37727_CONTROL_AGAIN_MASK;
++ reg |= reg_again;
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(TCS37727_CONTROL, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++
++ s_again = val_again;
++
++ return 0;
++
++}
++
++int
++TCS37727::sampleData(void)
++{
++ uint8_t buf[8];
++ int num = 0;
++
++ num = m_i2ControlCtx.readBytesReg((TCS37727_INC_TRANS | TCS37727_CDATA),
++ buf, 8);
++ if (num != 8) {
++ /* not enough values were read */
++ return -1;
++ }
++
++ int32_t tmpc = ((uint16_t)buf[1] << 8) | buf[0];
++ int32_t tmpr = ((uint16_t)buf[3] << 8) | buf[2];
++ int32_t tmpg = ((uint16_t)buf[5] << 8) | buf[4];
++ int32_t tmpb = ((uint16_t)buf[7] << 8) | buf[6];
++
++ /* Remove IR component as described in the DN40. */
++ int32_t ir = (tmpr + tmpg + tmpb - tmpc) >> 1;
++ tmpr -= ir;
++ tmpg -= ir;
++ tmpb -= ir;
++
++ /* Color temperature calculation as described in the DN40. */
++ int32_t ct = (CT_COEF_IF * tmpb) / tmpr + CT_OFFSET_IF;
++
++ /* Lux calculation as described in the DN40. */
++ int32_t gi = R_COEF_IF * tmpr + G_COEF_IF * tmpg + B_COEF_IF * tmpb;
++ /* TODO: add Glass Attenuation Factor GA compensation */
++ int32_t cpl = (s_atime_us * s_again) / DGF_IF;
++ int32_t lux = gi / cpl;
++
++ /* Autogain */
++ trimGain(tmpc);
++
++ s_data->red = (tmpr < 0) ? 0 : (tmpr * 1000) / cpl;
++ s_data->green = (tmpg < 0) ? 0 : (tmpg * 1000) / cpl;
++ s_data->blue = (tmpb < 0) ? 0 : (tmpb * 1000) / cpl;
++ s_data->clear = (tmpb < 0) ? 0 : (tmpc * 1000) / cpl;
++ s_data->lux = (lux < 0) ? 0 : lux;
++ s_data->ct = (ct < 0) ? 0 : ct;
++
++ return 0;
++}
++
++uint32_t
++TCS37727::getChannelRed(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return 999;
++ }
++ }
++
++ return s_data->red;
++}
++
++uint32_t
++TCS37727::getChannelGreen(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return 999;
++ }
++ }
++
++ return s_data->green;
++}
++
++uint32_t
++TCS37727::getChannelBlue(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return 999;
++ }
++ }
++
++ return s_data->blue;
++}
++
++uint32_t
++TCS37727::getChannelClear(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return 999;
++ }
++ }
++
++ return s_data->clear;
++}
++
++uint32_t
++TCS37727::getLux(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return 999;
++ }
++ }
++
++ return s_data->lux;
++}
++
++uint32_t
++TCS37727::getColorTemperature(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return 999;
++ }
++ }
++
++ return s_data->ct;
++}
++
++int
++TCS37727::getData(tcs37727_data_t* data, int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -1;
++ }
++ }
++
++ data->red = s_data->red;
++ data->green = s_data->green;
++ data->blue = s_data->blue;
++ data->clear = s_data->clear;
++ data->lux = s_data->lux;
++ data->ct = s_data->ct;
++
++ return 0;
++}
+diff --git a/src/tcs37727/tcs37727.hpp b/src/tcs37727/tcs37727.hpp
+new file mode 100644
+index 0000000..bde823c
+--- /dev/null
++++ b/src/tcs37727/tcs37727.hpp
+@@ -0,0 +1,289 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver tcs37727 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#pragma once
++
++#include <string>
++#include <mraa/i2c.hpp>
++#include <stdint.h>
++#include <stdbool.h>
++
++#define TCS37727_NAME "TCS37727"
++#define TCS37727_I2C_ADDRESS 0x29
++#define TCS37727_DEVICE_ID 0x49
++#define TCS37727_DEVICE_ID_REG 0x92
++
++#define TCS37727_ATIME_DEFAULT 200000 /* Default RGBC integration time */
++#define TCS37727_AG_THRESHOLD_LOW 200
++#define TCS37727_AG_THRESHOLD_HIGH (65535 - TCS37727_AG_THRESHOLD_LOW)
++
++
++/* TCS37727 Register Map */
++#define TCS37727_ENABLE 0x80 /* Enables states and interrupts */
++#define TCS37727_ATIME 0x81 /* RGBC time */
++#define TCS37727_PTIME 0x82 /* Proximity time */
++#define TCS37727_WTIME 0x83 /* Wait time */
++#define TCS37727_AILTL 0x04 /* Clear interrupt low threshold low byte */
++#define TCS37727_AILTH 0x05 /* Clear interrupt low threshold high byte */
++#define TCS37727_AIHTL 0x06 /* Clear interrupt high threshold low byte */
++#define TCS37727_AIHTH 0x07 /* Clear interrupt high threshold high byte */
++#define TCS37727_PILTL 0x08 /* Proximity inter. low threshold low byte */
++#define TCS37727_PILTH 0x09 /* Proximity inter. low threshold high byte */
++#define TCS37727_PIHTL 0x0A /* Proximity inter. high threshold low byte */
++#define TCS37727_PIHTH 0x0B /* Proximity inter. high threshold high byte */
++#define TCS37727_PERS 0x8C /* Interrupt persistence filters */
++#define TCS37727_CONFIG 0x8D /* Configuration */
++#define TCS37727_PPULSE 0x8E /* Proximity pulse count */
++#define TCS37727_CONTROL 0x8F /* Gain control register */
++#define TCS37727_STATUS 0x93 /* Device status */
++#define TCS37727_CDATA 0x14 /* Clear ADC data low byte */
++#define TCS37727_CDATAH 0x15 /* Clear ADC data high byte */
++#define TCS37727_RDATA 0x16 /* Red ADC data low byte */
++#define TCS37727_RDATAH 0x17 /* Red ADC data high byte */
++#define TCS37727_GDATA 0x18 /* Green ADC data low byte */
++#define TCS37727_GDATAH 0x19 /* Green ADC data high byte */
++#define TCS37727_BDATA 0x1A /* Blue ADC data low byte */
++#define TCS37727_BDATAH 0x1B /* Blue ADC data high byte */
++#define TCS37727_PDATA 0x1C /* Proximity ADC data low byte */
++#define TCS37727_PDATAH 0x1D /* Proximity ADC data high byte */
++
++/* TCS37727 Command Register */
++#define TCS37727_BYTE_TRANS 0x80 /* Repeated byte protocol transaction */
++#define TCS37727_INC_TRANS 0xA0 /* Auto-increment protocol transaction */
++#define TCS37727_SF_PICLR 0xE5 /* Proximity interrupt clear */
++#define TCS37727_SF_CICLR 0xE6 /* Clear channel interrupt clear */
++#define TCS37727_SF_PCICLR 0xE7 /* Proximity & Clear channel inter. clear */
++
++/* TCS37727 Enable Register */
++#define TCS37727_ENABLE_PIEN (1 << 5) /* Proximity interrupt enable */
++#define TCS37727_ENABLE_AIEN (1 << 4) /* Clear channel interrupt enable */
++#define TCS37727_ENABLE_WEN (1 << 3) /* Wait enable */
++#define TCS37727_ENABLE_PEN (1 << 2) /* Proximity enable */
++#define TCS37727_ENABLE_AEN (1 << 1) /* RGBC enable, actives 2-channel ADC */
++#define TCS37727_ENABLE_PON (1 << 0) /* Power ON */
++
++/* TCS37727 Control Register */
++#define TCS37727_CONTROL_PDRIVE_100 0x00 /* 100 mA LED Drive Strength */
++#define TCS37727_CONTROL_PDRIVE_50 0x04 /* 50 mA LED Drive Strength */
++#define TCS37727_CONTROL_PDRIVE_25 0x08 /* 25 mA LED Drive Strength */
++#define TCS37727_CONTROL_PDRIVE_12 0x0C /* 12.5 mA LED Drive Strength */
++#define TCS37727_CONTROL_PDRIVE_MASK 0x0C /* PDRIVE Mask */
++#define TCS37727_CONTROL_AGAIN_1 0x00 /* 1 × gain RGBC Gain Value */
++#define TCS37727_CONTROL_AGAIN_4 0x01 /* 4 × gain RGBC Gain Value */
++#define TCS37727_CONTROL_AGAIN_16 0x02 /* 16 × gain RGBC Gain Value */
++#define TCS37727_CONTROL_AGAIN_60 0x03 /* 60 × gain RGBC Gain Value */
++#define TCS37727_CONTROL_AGAIN_MASK 0x03 /* AGAIN Mask */
++
++/* TCS37727 ATIME register values */
++#define TCS37727_ATIME_MIN 2400 /* 2.4ms integr. time, max count 1024 */
++#define TCS37727_ATIME_MAX 614000 /* 614ms integr. time, max count 0xffff */
++
++#define TCS37727_ATIME_TO_REG(val) (256 - (uint8_t)((val) / 2400))
++#define TCS37727_ATIME_TO_US(reg) ((256 - (uint8_t)(reg)) * 2400)
++
++/* Coefficients for Lux and CT Equations (DN40) */
++/* Coefficients in integer format, multiplied by 1000 */
++#define DGF_IF 310
++#define R_COEF_IF 136
++#define G_COEF_IF 1000
++#define B_COEF_IF -444
++#define CT_COEF_IF 3810
++#define CT_OFFSET_IF 1391
++
++namespace upm {
++
++typedef struct {
++ uint32_t red; /**< IR compensated channels red */
++ uint32_t green; /**< IR compensated channels green */
++ uint32_t blue; /**< IR compensated channels blue */
++ uint32_t clear; /**< channels clear */
++ uint32_t lux; /**< Lux */
++ uint32_t ct; /**< Color temperature */
++} tcs37727_data_t;
++
++/**
++ * @brief TCS37727 Color Light-To-Digital Converter
++ * @defgroup tcs37727 libupm-tcs37727
++ * @ingroup ams i2c color
++ */
++
++/**
++ * @library tcs37727
++ * @sensor tcs37727
++ * @comname TCS37727 Color Light-To-Digital Converter
++ * @type color
++ * @man ams
++ * @web http://ams.com/eng/Products/Light-Sensors
++ * @con i2c
++ *
++ * @brief API for the TCS37727 Color Light-To-Digital Converter
++ *
++ * Description in web-link above:
++ * The TCS3772 device family provides red, green, blue, and clear (RGBC) light
++ * sensing and, when coupled with an external IR LED, proximity detection.
++ * These devices detect light intensity under a variety of lighting conditions
++ * and through a variety of attenuation materials, including dark glass. The
++ * proximity detection feature allows a large dynamic range of operation for
++ * accurate short distance detection, such as in a cell phone, for detecting
++ * when the user positions the phone close to their ear. An internal state
++ * machine provides the ability to put the device into a low power state in
++ * between proximity and RGBC measurements providing very low average power
++ * consumption.
++ *
++ * @snippet tcs37727.cxx Interesting
++ */
++class TCS37727 {
++ public:
++ /**
++ *
++ * Instantiates an TCS37727 object
++ * Settings: Gain 4x, Proximity Detection off
++ *
++ * @param bus Number of the used bus
++ * @param atime_us RGBC integration time
++ * @param devAddr Address of the used I2C device
++ */
++ TCS37727 (int bus, int atime_us=TCS37727_ATIME_DEFAULT,
++ int devAddr=TCS37727_I2C_ADDRESS);
++
++ /**
++ * Check device_id of sensor
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int checkID(void);
++
++ /**
++ * Set active mode, this enables periodic RGBC measurements
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setActive(void);
++
++ /**
++ * Set standby mode, this disables periodic RGBC measurements
++ * Also turns off the sensor when proximity measurement is disabled
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setStandby(void);
++
++ /**
++ *
++ */
++ uint8_t trimGain(int rawc);
++
++ /**
++ * Read out data of regs and call further function
++ * Also saves converted values to variables
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int sampleData(void);
++
++ /**
++ * Get the calculated channel red color
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The channel red color on success
++ * 999 on error
++ */
++ uint32_t getChannelRed(int bSampleData = 0);
++
++ /**
++ * Get the calculated channel green color
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The channel green color on success
++ * 999 on error
++ */
++ uint32_t getChannelGreen(int bSampleData = 0);
++
++ /**
++ * Get the calculated channel blue color
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The channel blue color on success
++ * 999 on error
++ */
++ uint32_t getChannelBlue(int bSampleData = 0);
++
++ /**
++ * Get the calculated channel clear color
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The channel clear color on success
++ * 999 on error
++ */
++ uint32_t getChannelClear(int bSampleData = 0);
++
++ /**
++ * Get the calculated lux value
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The lux value on success
++ * 999 on error
++ */
++ uint32_t getLux(int bSampleData = 0);
++
++ /**
++ * Get the calculated color temperature
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The color temperature on success
++ * 999 on error
++ */
++ uint32_t getColorTemperature(int bSampleData = 0);
++
++ /**
++ * Get calculated sensor values
++ *
++ * @param data Calculated sensor values
++ * @param bSampleData Flag to read sensor
++ * @return 0 on success
++ * -1 on error
++ */
++ int getData(tcs37727_data_t* data, int bSampleData = 0);
++
++ private:
++
++ std::string m_name;
++
++ int m_controlAddr;
++ int m_bus;
++ mraa::I2c m_i2ControlCtx;
++
++ int s_atime_us; /* atime value conveted to microseconds */
++ int s_again; /* amount of gain */
++
++ tcs37727_data_t s_data[1];
++ };
++
++}
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm/0002-hdc1000-Added-upm-support-for-sensor-HDC1000.patch b/recipes-devtools/upm/upm/0002-hdc1000-Added-upm-support-for-sensor-HDC1000.patch
new file mode 100644
index 0000000..5bdc25d
--- /dev/null
+++ b/recipes-devtools/upm/upm/0002-hdc1000-Added-upm-support-for-sensor-HDC1000.patch
@@ -0,0 +1,407 @@
+From 34f0733a93b6c7705f081f9fbc782772ccf361b3 Mon Sep 17 00:00:00 2001
+From: Norbert Wesp <nwesp@phytec.de>
+Date: Fri, 10 Feb 2017 14:43:18 +0100
+Subject: [PATCH 2/6] hdc1000: Added upm support for sensor HDC1000
+
+The HDC1000 is a digital humidity sensor with integrated
+temperature sensor.
+Examples will be added at a later commit.
+
+Signed-off-by: Norbert Wesp <nwesp@phytec.de>
+---
+ src/hdc1000/CMakeLists.txt | 5 ++
+ src/hdc1000/hdc1000.cpp | 147 +++++++++++++++++++++++++++++++++++++++++
+ src/hdc1000/hdc1000.hpp | 148 ++++++++++++++++++++++++++++++++++++++++++
+ src/hdc1000/javaupm_hdc1000.i | 19 ++++++
+ src/hdc1000/jsupm_hdc1000.i | 8 +++
+ src/hdc1000/pyupm_hdc1000.i | 15 +++++
+ 6 files changed, 342 insertions(+)
+ create mode 100644 src/hdc1000/CMakeLists.txt
+ create mode 100644 src/hdc1000/hdc1000.cpp
+ create mode 100644 src/hdc1000/hdc1000.hpp
+ create mode 100644 src/hdc1000/javaupm_hdc1000.i
+ create mode 100644 src/hdc1000/jsupm_hdc1000.i
+ create mode 100644 src/hdc1000/pyupm_hdc1000.i
+
+diff --git a/src/hdc1000/CMakeLists.txt b/src/hdc1000/CMakeLists.txt
+new file mode 100644
+index 0000000..a06ed52
+--- /dev/null
++++ b/src/hdc1000/CMakeLists.txt
+@@ -0,0 +1,5 @@
++set (libname "hdc1000")
++set (libdescription "Humidity/Temperature Sensor")
++set (module_src ${libname}.cpp)
++set (module_hpp ${libname}.hpp)
++upm_module_init()
+diff --git a/src/hdc1000/hdc1000.cpp b/src/hdc1000/hdc1000.cpp
+new file mode 100644
+index 0000000..8c1c630
+--- /dev/null
++++ b/src/hdc1000/hdc1000.cpp
+@@ -0,0 +1,147 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver hdc1000 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <iostream>
++#include <string>
++#include <stdexcept>
++
++#include <unistd.h>
++#include <stdlib.h>
++#include <endian.h>
++
++#include "hdc1000.hpp"
++
++using namespace upm;
++
++HDC1000::HDC1000(int bus, int devAddr) : m_i2ControlCtx(bus) {
++ m_temperature = 0;
++ m_humidity = 0;
++
++ m_name = HDC1000_NAME;
++
++ m_controlAddr = devAddr;
++ m_bus = bus;
++
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ if (checkID() != 0) {
++ /* sensor_id does not match! maybe wrong sensor chosen? */
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": checkID() failed");
++ }
++
++ sampleData();
++}
++
++int
++HDC1000::checkID(void)
++{
++ uint8_t tmp[2];
++ uint16_t id;
++ int re = 0;
++
++ re = m_i2ControlCtx.readBytesReg(HDC1000_DEVICE_ID_REG, tmp, 2);
++ if (re != 2) {
++ /* not enough bytes were read! */
++ return -1;
++ }
++
++ id = ((uint16_t)tmp[0] << 8) | tmp[1];
++
++ if (id != HDC1000_DEVICE_ID) {
++ return -1;
++ }
++
++ return 0;
++}
++
++void
++HDC1000::resetSensor(void)
++{
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ ret = m_i2ControlCtx.writeByte(0);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte() failed");
++ }
++ usleep(SLEEP_SEC);
++}
++
++void
++HDC1000::sampleData(void)
++{
++ uint8_t itemp[4];
++ uint16_t traw, hraw;
++ int re = 0;
++
++ resetSensor();
++
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ re = m_i2ControlCtx.read(itemp, 4);
++ if (re != 4) {
++ /* not enough bytes were read! */
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_read(4) failed");
++ }
++
++ traw = ((uint16_t)itemp[0] << 8) | itemp[1];
++ m_temperature = ((((int32_t)traw * 16500) >> 16) -4000);
++
++ hraw = ((uint16_t)itemp[2] << 8) | itemp[3];
++ m_humidity = (((int32_t)hraw * 10000) >> 16);
++}
++
++float
++HDC1000::getTemperature(int bSampleData)
++{
++ if (bSampleData) {
++ sampleData();
++ }
++ return (float)(m_temperature * 0.01);
++}
++
++float
++HDC1000::getHumidity(int bSampleData)
++{
++ if (bSampleData) {
++ sampleData();
++ }
++ return (float)(m_humidity * 0.01);
++}
+diff --git a/src/hdc1000/hdc1000.hpp b/src/hdc1000/hdc1000.hpp
+new file mode 100644
+index 0000000..cf3e56e
+--- /dev/null
++++ b/src/hdc1000/hdc1000.hpp
+@@ -0,0 +1,148 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver hdc1000 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#pragma once
++
++#include <string>
++#include <mraa/i2c.hpp>
++#include <math.h>
++
++#define HDC1000_NAME "hdc1000"
++#define HDC1000_i2C_ADDRESS 0x43
++#define HDC1000_MANUFACTURER_ID 0x5449 /* ID of Texas Instruments */
++#define HDC1000_DEVICE_ID 0x1000 /* ID of HDC1000 device */
++
++/* HDC1000 Register Map */
++#define HDC1000_TEMPERATURE 0x00
++#define HDC1000_HUMIDITY 0x01
++#define HDC1000_CONFIGURATION 0x02
++#define HDC1000_MANUFACTURER_ID_REG 0xFE
++#define HDC1000_DEVICE_ID_REG 0xFF
++
++/* HDC1000 configuration register bitmap */
++#define HDC1000_RST_SOFT 0x8000
++#define HDC1000_HEAT (1 << 13)
++#define HDC1000_SEQ_MODE (1 << 12)
++#define HDC1000_BTST_LOW (1 << 11)
++#define HDC1000_TRES_14 (0)
++#define HDC1000_TRES_11 (1 << 10)
++#define HDC1000_HRES_14 (0)
++#define HDC1000_HRES_11 (1 << 8)
++#define HDC1000_HRES_8 (1 << 9)
++
++#define SLEEP_SEC (1000*1000)
++
++namespace upm {
++
++/**
++ * @brief HDC1000 Temperature and Humidity Sensor
++ * @defgroup hdc1000 libupm-hdc1000
++ * @ingroup ti i2c temp
++ */
++
++/**
++ * @library hdc1000
++ * @sensor hdc1000
++ * @comname HDC1000 Temperature & Humidity Sensor
++ * @type temp
++ * @man ti
++ * @web http://www.ti.com/lit/ds/symlink/hdc1000.pdf
++ * @con i2c
++ *
++ * @brief API for the HDC1000 Temperature & Humidity Sensor
++ *
++ * Description in web-link above:
++ * The HDC1000 is a digital humidity sensor with integrated temperature sensor
++ * that provides excellent measurement accuracy at very low power. The device
++ * measures humidity based on a novel capacitive sensor. The humidity and
++ * temperature sensors are factory calibrated. The innovative
++ * WLCSP (Wafer Level Chip Scale Package) simplifies board design with the use
++ * of an ultra-compact package. The sensing element of the HDC1000 is placed on
++ * the bottom part of the device, which makes the HDC1000 more robust against
++ * dirt, dust, and other environmental contaminants. The HDC1000 is functional
++ * within the full -40°C to +125 °C temperature range.
++ *
++ * @snippet hdc1000.cxx Interesting
++ */
++class HDC1000 {
++ public:
++ /**
++ * Instantiates an HDC1000 object
++ *
++ * @param bus Number of the used bus
++ * @param devAddr Address of the used I2C device
++ */
++ HDC1000 (int bus, int devAddr=HDC1000_i2C_ADDRESS);
++
++ /**
++ * Check device_id of sensor
++ *
++ * @return 0 on succes
++ * -1 on error
++ */
++ int checkID(void);
++
++ /**
++ * Performs a soft reset of the HDC1000 device to ensure
++ * it is in a known state.
++ */
++ void resetSensor(void);
++
++ /**
++ * Initiates a temperature/pressure mesasurement and waits
++ * to complete.
++ */
++ void sampleData(void);
++
++ /**
++ * Get the current measured humidity [RH]
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The humidity sensor temp in degC
++ */
++ float getHumidity(int bSampleData = false);
++
++ /**
++ * Get the humidity cell temperature [degC]
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The humidity sensor temp in degC
++ */
++ float getTemperature(int bSampleData = false);
++
++ private:
++
++ std::string m_name;
++
++ int m_controlAddr;
++ int m_bus;
++ mraa::I2c m_i2ControlCtx;
++
++ int32_t m_temperature;
++ int32_t m_humidity;
++};
++
++}
+diff --git a/src/hdc1000/javaupm_hdc1000.i b/src/hdc1000/javaupm_hdc1000.i
+new file mode 100644
+index 0000000..c6ec019
+--- /dev/null
++++ b/src/hdc1000/javaupm_hdc1000.i
+@@ -0,0 +1,19 @@
++%module javaupm_hdc1000
++%include "../upm.i"
++
++%{
++ #include "hdc1000.hpp"
++%}
++
++%include "hdc1000.hpp"
++
++%pragma(java) jniclasscode=%{
++ static {
++ try {
++ System.loadLibrary("javaupm_hdc1000");
++ } catch (UnsatisfiedLinkError e) {
++ System.err.println("Native code library failed to load. \n" + e);
++ System.exit(1);
++ }
++ }
++%}
+\ No newline at end of file
+diff --git a/src/hdc1000/jsupm_hdc1000.i b/src/hdc1000/jsupm_hdc1000.i
+new file mode 100644
+index 0000000..b9ed9f3
+--- /dev/null
++++ b/src/hdc1000/jsupm_hdc1000.i
+@@ -0,0 +1,8 @@
++%module jsupm_hdc1000
++%include "../upm.i"
++
++%{
++ #include "hdc1000.hpp"
++%}
++
++%include "hdc1000.hpp"
+diff --git a/src/hdc1000/pyupm_hdc1000.i b/src/hdc1000/pyupm_hdc1000.i
+new file mode 100644
+index 0000000..58fe7a3
+--- /dev/null
++++ b/src/hdc1000/pyupm_hdc1000.i
+@@ -0,0 +1,15 @@
++// Include doxygen-generated documentation
++%include "pyupm_doxy2swig.i"
++%module pyupm_hdc1000
++%include "../upm.i"
++
++%feature("autodoc", "3");
++
++#ifdef DOXYGEN
++%include "hdc1000_doc.i"
++#endif
++
++%include "hdc1000.hpp"
++%{
++ #include "hdc1000.hpp"
++%}
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm/0003-mag3110-Added-upm-support-for-sensor-MAG3110.patch b/recipes-devtools/upm/upm/0003-mag3110-Added-upm-support-for-sensor-MAG3110.patch
new file mode 100644
index 0000000..48fadbb
--- /dev/null
+++ b/recipes-devtools/upm/upm/0003-mag3110-Added-upm-support-for-sensor-MAG3110.patch
@@ -0,0 +1,676 @@
+From 73fdea2d6282bab54594afe1b8d13541abc28c9a Mon Sep 17 00:00:00 2001
+From: Norbert Wesp <nwesp@phytec.de>
+Date: Fri, 10 Feb 2017 14:45:05 +0100
+Subject: [PATCH 3/6] mag3110: Added upm support for sensor MAG3110
+
+MAG3110 is a three-axis digital magnetometer.
+Examples will be added at a later commit.
+
+Signed-off-by: Norbert Wesp <nwesp@phytec.de>
+---
+ src/mag3110/CMakeLists.txt | 5 +
+ src/mag3110/javaupm_mag3110.i | 19 +++
+ src/mag3110/jsupm_mag3110.i | 8 ++
+ src/mag3110/mag3110.cpp | 269 ++++++++++++++++++++++++++++++++++++++
+ src/mag3110/mag3110.hpp | 296 ++++++++++++++++++++++++++++++++++++++++++
+ src/mag3110/pyupm_mag3110.i | 15 +++
+ 6 files changed, 612 insertions(+)
+ create mode 100644 src/mag3110/CMakeLists.txt
+ create mode 100644 src/mag3110/javaupm_mag3110.i
+ create mode 100644 src/mag3110/jsupm_mag3110.i
+ create mode 100644 src/mag3110/mag3110.cpp
+ create mode 100644 src/mag3110/mag3110.hpp
+ create mode 100644 src/mag3110/pyupm_mag3110.i
+
+diff --git a/src/mag3110/CMakeLists.txt b/src/mag3110/CMakeLists.txt
+new file mode 100644
+index 0000000..a9f27b4
+--- /dev/null
++++ b/src/mag3110/CMakeLists.txt
+@@ -0,0 +1,5 @@
++set (libname "mag3110")
++set (libdescription "Three-Axis Digital Magnetometer")
++set (module_src ${libname}.cpp)
++set (module_hpp ${libname}.hpp)
++upm_module_init()
+diff --git a/src/mag3110/javaupm_mag3110.i b/src/mag3110/javaupm_mag3110.i
+new file mode 100644
+index 0000000..109de91
+--- /dev/null
++++ b/src/mag3110/javaupm_mag3110.i
+@@ -0,0 +1,19 @@
++%module javaupm_mag3110
++%include "../upm.i"
++
++%{
++ #include "mag3110.hpp"
++%}
++
++%include "mag3110.hpp"
++
++%pragma(java) jniclasscode=%{
++ static {
++ try {
++ System.loadLibrary("javaupm_mag3110");
++ } catch (UnsatisfiedLinkError e) {
++ System.err.println("Native code library failed to load. \n" + e);
++ System.exit(1);
++ }
++ }
++%}
+\ No newline at end of file
+diff --git a/src/mag3110/jsupm_mag3110.i b/src/mag3110/jsupm_mag3110.i
+new file mode 100644
+index 0000000..2f74981
+--- /dev/null
++++ b/src/mag3110/jsupm_mag3110.i
+@@ -0,0 +1,8 @@
++%module jsupm_mag3110
++%include "../upm.i"
++
++%{
++ #include "mag3110.hpp"
++%}
++
++%include "mag3110.hpp"
+diff --git a/src/mag3110/mag3110.cpp b/src/mag3110/mag3110.cpp
+new file mode 100644
+index 0000000..3bac833
+--- /dev/null
++++ b/src/mag3110/mag3110.cpp
+@@ -0,0 +1,269 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver mag3110 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <iostream>
++#include <string>
++#include <stdexcept>
++
++#include <unistd.h>
++#include <stdlib.h>
++#include <endian.h>
++
++#include "mag3110.hpp"
++
++using namespace upm;
++
++MAG3110::MAG3110 (int bus, uint8_t dros, int devAddr) : m_i2ControlCtx(bus) {
++ s_data->x = 0;
++ s_data->y = 0;
++ s_data->z = 0;
++ s_data->status = 0;
++ s_data->dtemp = 0;
++
++ uint8_t reg;
++
++ m_name = MAG3110_NAME;
++
++ m_controlAddr = devAddr;
++ m_bus = bus;
++
++ if (dros > MAG3110_DROS_0008_128) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": given DR-OS invalid");
++ }
++
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ if (checkID() != 0) {
++ /* sensor_id does not match! maybe wrong sensor chosen? */
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": checkID() failed");
++ }
++
++ /* enable automatic magnetic sensor reset */
++ reg = MAG3110_CTRL_REG2_AUTO_MRST_EN;
++ ret = m_i2ControlCtx.writeReg(MAG3110_CTRL_REG2, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++
++ reg = MAG3110_CTRL_REG1_DROS(dros);
++ ret = m_i2ControlCtx.writeReg(MAG3110_CTRL_REG1, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++}
++
++int
++MAG3110::checkID(void)
++{
++ uint8_t id;
++
++ id = m_i2ControlCtx.readReg(MAG3110_DEVICE_ID_REG);
++
++ if (id != MAG3110_DEVICE_ID) {
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++MAG3110::setUserOffset(int16_t x, int16_t y, int16_t z)
++{
++ mraa::Result ret;
++ ret = m_i2ControlCtx.writeWordReg(MAG3110_OFF_X_MSB, (uint16_t)x);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ return -1;
++ }
++
++ ret = m_i2ControlCtx.writeWordReg(MAG3110_OFF_Y_MSB, (uint16_t)y);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ return -1;
++ }
++
++ ret = m_i2ControlCtx.writeWordReg(MAG3110_OFF_Z_MSB, (uint16_t)z);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++MAG3110::setActive(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(MAG3110_CTRL_REG1);
++
++ reg |= MAG3110_CTRL_REG1_AC;
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(MAG3110_CTRL_REG1, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++MAG3110::setStandby(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(MAG3110_CTRL_REG1);
++
++ reg &= ~MAG3110_CTRL_REG1_AC;
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(MAG3110_CTRL_REG1, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++MAG3110::isReady(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(MAG3110_DR_STATUS);
++
++ return (int)(reg & MAG3110_DR_STATUS_ZYXDR);
++}
++
++int
++MAG3110::sampleData(void)
++{
++ uint8_t buf[7];
++ uint8_t dtemp;
++ int re = 0;
++
++ re = m_i2ControlCtx.readBytesReg(MAG3110_DR_STATUS, buf, 7);
++ if (re != 7) {
++ /* did not read enough bytes */
++ return -1;
++ }
++
++ s_data->status = buf[0];
++ s_data->x = ((int16_t)buf[1] << 8) | buf[2];
++ s_data->y = ((int16_t)buf[3] << 8) | buf[4];
++ s_data->z = ((int16_t)buf[5] << 8) | buf[6];
++
++ dtemp = m_i2ControlCtx.readReg(MAG3110_DIE_TEMP);
++
++ s_data->dtemp = dtemp;
++
++ return 0;
++}
++
++int16_t
++MAG3110::getX(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -999;
++ }
++ }
++
++ return s_data->x;
++}
++
++int16_t
++MAG3110::getY(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -999;
++ }
++ }
++
++ return s_data->y;
++}
++
++int16_t
++MAG3110::getZ(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -999;
++ }
++ }
++
++ return s_data->z;
++}
++
++uint8_t
++MAG3110::getStatus(void)
++{
++ return s_data->status;
++}
++
++int8_t
++MAG3110::getDieTemperature(void)
++{
++ return s_data->dtemp;
++}
++
++int
++MAG3110::getData(mag3110_data_t* data, int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -1;
++ }
++ }
++
++ data->x = s_data->x;
++ data->y = s_data->y;
++ data->z = s_data->z;
++ data->status = s_data->status;
++ data->dtemp = s_data->dtemp;
++
++ return 0;
++}
+diff --git a/src/mag3110/mag3110.hpp b/src/mag3110/mag3110.hpp
+new file mode 100644
+index 0000000..0d693c0
+--- /dev/null
++++ b/src/mag3110/mag3110.hpp
+@@ -0,0 +1,296 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver mag3110 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#pragma once
++
++#include <string>
++#include <mraa/i2c.hpp>
++#include <stdint.h>
++#include <stdbool.h>
++
++#define MAG3110_NAME "MAG3110"
++#define MAG3110_I2C_ADDRESS 0x0E
++#define MAG3110_DEVICE_ID 0xC4
++#define MAG3110_DEVICE_ID_REG 0x07
++
++/* MAG3110 Register Map */
++#define MAG3110_DR_STATUS 0x00 /**< Data ready status per axis */
++#define MAG3110_OUT_X_MSB 0x01 /**< Bits [15:8] of X measurement */
++#define MAG3110_OUT_X_LSB 0x02 /**< Bits [7:0] of X measurement */
++#define MAG3110_OUT_Y_MSB 0x03 /**< Bits [15:8] of Y measurement */
++#define MAG3110_OUT_Y_LSB 0x04 /**< Bits [7:0] of Y measurement */
++#define MAG3110_OUT_Z_MSB 0x05 /**< Bits [15:8] of Z measurement */
++#define MAG3110_OUT_Z_LSB 0x06 /**< Bits [7:0] of Z measurement */
++#define MAG3110_SYSMOD 0x08 /**< FIFO Status Register */
++#define MAG3110_OFF_X_MSB 0x09 /**< Bits [15:8] of user X offset */
++#define MAG3110_OFF_X_LSB 0x0A /**< Bits [7:0] of user X offset */
++#define MAG3110_OFF_Y_MSB 0x0B /**< Bits [15:8] of user Y offset */
++#define MAG3110_OFF_Y_LSB 0x0C /**< Bits [7:0] of user Y offset */
++#define MAG3110_OFF_Z_MSB 0x0D /**< Bits [15:8] of user Z offset */
++#define MAG3110_OFF_Z_LSB 0x0E /**< Bits [7:0] of user Z offset */
++#define MAG3110_DIE_TEMP 0x0F /**< Temperature, signed 8 bits */
++#define MAG3110_CTRL_REG1 0x10 /**< Operation modes */
++#define MAG3110_CTRL_REG2 0x11 /**< Operation modes */
++
++/* MAG3110 DR-STATUS Register */
++#define MAG3110_DR_STATUS_ZYXOW (1 << 7)
++#define MAG3110_DR_STATUS_ZOW (1 << 6)
++#define MAG3110_DR_STATUS_YOW (1 << 5)
++#define MAG3110_DR_STATUS_XOW (1 << 4)
++#define MAG3110_DR_STATUS_ZYXDR (1 << 3)
++#define MAG3110_DR_STATUS_ZDR (1 << 2)
++#define MAG3110_DR_STATUS_YDR (1 << 1)
++#define MAG3110_DR_STATUS_XDR (1 << 0)
++
++/* MAG3110 SYSMOD Register */
++#define MAG3110_SYSMOD_STANDBY 0
++#define MAG3110_SYSMOD_ACTIVE_RAW 1
++#define MAG3110_SYSMOD_ACTIVE 2
++
++/* MAG3110 Control Register 1 */
++#define MAG3110_CTRL_REG1_DROS_SHIFT 3
++#define MAG3110_CTRL_REG1_DROS_MASK 0xF8
++#define MAG3110_CTRL_REG1_DROS(x) (((uint8_t)(((uint8_t)(x))<<\
++ MAG3110_CTRL_REG1_DROS_SHIFT))\
++ &MAG3110_CTRL_REG1_DROS_MASK)
++#define MAG3110_CTRL_REG1_FR (1 << 2)
++#define MAG3110_CTRL_REG1_TM (1 << 1)
++#define MAG3110_CTRL_REG1_AC (1 << 0)
++
++/* MAG3110 Control Register 2 */
++#define MAG3110_CTRL_REG2_AUTO_MRST_EN (1 << 7)
++#define MAG3110_CTRL_REG2_RAW (1 << 5)
++#define MAG3110_CTRL_REG2_MAG_RST (1 << 4)
++
++/* MAG3110 Output Rate (DR) and Over Sample (OS) Ratio for CTRL_REG1 */
++#define MAG3110_DROS_8000_16 0 /* DR 80 Hz, OS Ratio 16 */
++#define MAG3110_DROS_4000_32 1 /* DR 40 Hz, OS Ratio 32 */
++#define MAG3110_DROS_2000_64 2 /* DR 20 Hz, OS Ratio 64 */
++#define MAG3110_DROS_1000_128 3 /* DR 10 Hz, OS Ratio 128 */
++#define MAG3110_DROS_4000_16 4 /* DR 40 Hz, OS Ratio 16 */
++#define MAG3110_DROS_2000_32 5 /* DR 20 Hz, OS Ratio 32 */
++#define MAG3110_DROS_1000_64 6 /* DR 10 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0500_128 7 /* DR 5 Hz, OS Ratio 128 */
++#define MAG3110_DROS_2000_16 8 /* DR 20 Hz, OS Ratio 16 */
++#define MAG3110_DROS_1000_32 9 /* DR 10 Hz, OS Ratio 32 */
++#define MAG3110_DROS_0500_64 10 /* DR 5 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0250_128 11 /* DR 2.5 Hz, OS Ratio 128 */
++#define MAG3110_DROS_1000_16 12 /* DR 10 Hz, OS Ratio 16 */
++#define MAG3110_DROS_0500_32 13 /* DR 5 Hz, OS Ratio 32 */
++#define MAG3110_DROS_0250_64 14 /* DR 2.5 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0125_128 15 /* DR 1.25 Hz, OS Ratio 128 */
++#define MAG3110_DROS_0500_16 16 /* DR 5 Hz, OS Ratio 16 */
++#define MAG3110_DROS_0250_32 17 /* DR 2.5 Hz, OS Ratio 32 */
++#define MAG3110_DROS_0125_64 18 /* DR 1.25 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0063_128 19 /* DR 0.63 Hz, OS Ratio 128 */
++#define MAG3110_DROS_0250_16 20 /* DR 2.5 Hz, OS Ratio 16 */
++#define MAG3110_DROS_0125_32 21 /* DR 1.25 Hz, OS Ratio 32 */
++#define MAG3110_DROS_0063_64 22 /* DR 0.63 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0031_128 23 /* DR 0.31 Hz, OS Ratio 128 */
++#define MAG3110_DROS_0125_16 24 /* DR 1.25 Hz, OS Ratio 16 */
++#define MAG3110_DROS_0063_32 25 /* DR 0.63 Hz, OS Ratio 32 */
++#define MAG3110_DROS_0031_64 26 /* DR 0.31 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0016_128 27 /* DR 0.16 Hz, OS Ratio 128 */
++#define MAG3110_DROS_0063_16 28 /* DR 0.63 Hz, OS Ratio 16 */
++#define MAG3110_DROS_0031_32 29 /* DR 0.31 Hz, OS Ratio 32 */
++#define MAG3110_DROS_0016_64 30 /* DR 0.16 Hz, OS Ratio 64 */
++#define MAG3110_DROS_0008_128 31 /* DR 0.08 Hz, OS Ratio 128 */
++#define MAG3110_DROS_DEFAULT MAG3110_DROS_0125_128
++ /* Default Setting for testing*/
++
++namespace upm {
++
++typedef struct {
++ int16_t x;
++ int16_t y;
++ int16_t z;
++ uint8_t status;
++ int8_t dtemp;
++} mag3110_data_t;
++
++/**
++ * @brief MAG3110 Three-Axis Digital Magnetometer
++ * @defgroup mag3110 libupm-mag3110
++ * @ingroup freescale i2c accelerometer compass
++ */
++
++/**
++ * @library mag3110
++ * @sensor mag3110
++ * @comname MAG3110 Three-Axis Digital Magnetometer
++ * @type accelerometer compass
++ * @man freescale
++ * @web http://www.nxp.com/assets/documents/data/en/data-sheets/MAG3110.pdf
++ * @con i2c
++ *
++ * @brief API for the MAG3110 Three-Axis Digital Magnetometer
++ *
++ * Description in web-link above:
++ * The MAG3110 is a small, low-power digital 3D magnetic sensor with a wide
++ * dynamic range to allow operation in PCBs with high extraneous magnetic
++ * fields.
++ * It measures the components of the local magnetic field, the sum of the
++ * geomagnetic field and the magnetic field created by components on the
++ * circuit board.
++ * It can be used in conjunction with a 3-axis accelerometer so that
++ * orientation-independent accurate compass heading information may be achieved
++ * It is capable of measuring local magnetic fields up to 10 Gauss with output
++ * data rates up to 80 Hz.
++ *
++ * @snippet mag3110.cxx Interesting
++ */
++class MAG3110 {
++ public:
++ /**
++ *
++ * Instantiates an MAG3110 object
++ *
++ * @param bus Number of the used bus
++ * @param dros Data rate and over sampling selection
++ * @param devAddr Address of the used I2C device
++ */
++ MAG3110 (int bus, uint8_t dros=MAG3110_DROS_DEFAULT,
++ int devAddr=MAG3110_I2C_ADDRESS);
++
++ /**
++ * Check device_id of sensor
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int checkID(void);
++
++ /**
++ * Set user offset correction
++ * Offset correction register will be erased after accelerometer reset
++ *
++ * @param x Offset correction value for x-axis
++ * @param y Offset correction value for y-axis
++ * @param z Offset correction value for z-axis
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setUserOffset(int16_t x, int16_t y, int16_t z);
++
++ /**
++ * Set active mode, this enables periodic measurements
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setActive(void);
++
++ /**
++ * Set standby mode, this disables periodic measurements
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setStandby(void);
++
++ /**
++ * Check for new set of measurement data.
++ *
++ * @return >0 if x-, y- and z-axis new sample is ready
++ * 0 if measurement is in progress
++ */
++ int isReady(void);
++
++ /**
++ * Read magnetometer's data and saves them to variables
++ *
++ * Info: To get the actual values for the magnetic field someone
++ * has to divide the returned values from the magnetometer by 10
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int sampleData(void);
++
++ /**
++ * Get x-axis magnetic field strength
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The x-axis magnetic field strength on success
++ * -999 on error
++ */
++ int16_t getX(int bSampleData = 0);
++
++ /**
++ * Get y-axis magnetic field strength
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The y-axis magnetic field strength on success
++ * -999 on error
++ */
++ int16_t getY(int bSampleData = 0);
++
++ /**
++ * Get z-axis magnetic field strength
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The z-axis magnetic field strength on success
++ * -999 on error
++ */
++ int16_t getZ(int bSampleData = 0);
++
++ /**
++ * Get value of status register
++ *
++ * @return Value of status register
++ */
++ uint8_t getStatus(void);
++
++ /**
++ * Get die temperature
++ *
++ * @return Die temperature
++ */
++ int8_t getDieTemperature(void);
++
++ /**
++ * Get sensor values
++ *
++ * @param data Sensor values
++ * @param bSampleData Flag to read sensor
++ * @return 0 on success
++ * -1 on error
++ */
++ int getData(mag3110_data_t* data, int bSampleData = 0);
++
++ private:
++
++ std::string m_name;
++
++ int m_controlAddr;
++ int m_bus;
++ mraa::I2c m_i2ControlCtx;
++
++ mag3110_data_t s_data[1];
++};
++
++}
+diff --git a/src/mag3110/pyupm_mag3110.i b/src/mag3110/pyupm_mag3110.i
+new file mode 100644
+index 0000000..f125545
+--- /dev/null
++++ b/src/mag3110/pyupm_mag3110.i
+@@ -0,0 +1,15 @@
++// Include doxygen-generated documentation
++%include "pyupm_doxy2swig.i"
++%module pyupm_mag3110
++%include "../upm.i"
++
++%feature("autodoc", "3");
++
++#ifdef DOXYGEN
++%include "mag3110_doc.i"
++#endif
++
++%include "mag3110.hpp"
++%{
++ #include "mag3110.hpp"
++%}
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm/0004-tmp006-Added-upm-support-for-sensor-TMP006.patch b/recipes-devtools/upm/upm/0004-tmp006-Added-upm-support-for-sensor-TMP006.patch
new file mode 100644
index 0000000..35dd5af
--- /dev/null
+++ b/recipes-devtools/upm/upm/0004-tmp006-Added-upm-support-for-sensor-TMP006.patch
@@ -0,0 +1,561 @@
+From 00fae9a3ed70f28e4d4ae0f2cfc9116dd45a6571 Mon Sep 17 00:00:00 2001
+From: Norbert Wesp <nwesp@phytec.de>
+Date: Fri, 10 Feb 2017 14:47:03 +0100
+Subject: [PATCH 4/6] tmp006: Added upm support for sensor TMP006
+
+TMP006 is a infrared-thermopile sensor.
+Examples will be added at a later commit.
+
+Signed-off-by: Norbert Wesp <nwesp@phytec.de>
+---
+ src/tmp006/CMakeLists.txt | 5 +
+ src/tmp006/javaupm_tmp006.i | 19 ++++
+ src/tmp006/jsupm_tmp006.i | 8 ++
+ src/tmp006/pyupm_tmp006.i | 15 +++
+ src/tmp006/tmp006.cpp | 248 ++++++++++++++++++++++++++++++++++++++++++++
+ src/tmp006/tmp006.hpp | 202 ++++++++++++++++++++++++++++++++++++
+ 6 files changed, 497 insertions(+)
+ create mode 100644 src/tmp006/CMakeLists.txt
+ create mode 100644 src/tmp006/javaupm_tmp006.i
+ create mode 100644 src/tmp006/jsupm_tmp006.i
+ create mode 100644 src/tmp006/pyupm_tmp006.i
+ create mode 100644 src/tmp006/tmp006.cpp
+ create mode 100644 src/tmp006/tmp006.hpp
+
+diff --git a/src/tmp006/CMakeLists.txt b/src/tmp006/CMakeLists.txt
+new file mode 100644
+index 0000000..dd247cf
+--- /dev/null
++++ b/src/tmp006/CMakeLists.txt
+@@ -0,0 +1,5 @@
++set (libname "tmp006")
++set (libdescription "IR-Termopile Sensor")
++set (module_src ${libname}.cpp)
++set (module_hpp ${libname}.hpp)
++upm_module_init()
+diff --git a/src/tmp006/javaupm_tmp006.i b/src/tmp006/javaupm_tmp006.i
+new file mode 100644
+index 0000000..a52d474
+--- /dev/null
++++ b/src/tmp006/javaupm_tmp006.i
+@@ -0,0 +1,19 @@
++%module javaupm_tmp006
++%include "../upm.i"
++
++%{
++ #include "tmp006.hpp"
++%}
++
++%include "tmp006.hpp"
++
++%pragma(java) jniclasscode=%{
++ static {
++ try {
++ System.loadLibrary("javaupm_tmp006");
++ } catch (UnsatisfiedLinkError e) {
++ System.err.println("Native code library failed to load. \n" + e);
++ System.exit(1);
++ }
++ }
++%}
+\ No newline at end of file
+diff --git a/src/tmp006/jsupm_tmp006.i b/src/tmp006/jsupm_tmp006.i
+new file mode 100644
+index 0000000..66c9fd9
+--- /dev/null
++++ b/src/tmp006/jsupm_tmp006.i
+@@ -0,0 +1,8 @@
++%module jsupm_tmp006
++%include "../upm.i"
++
++%{
++ #include "tmp006.hpp"
++%}
++
++%include "tmp006.hpp"
+diff --git a/src/tmp006/pyupm_tmp006.i b/src/tmp006/pyupm_tmp006.i
+new file mode 100644
+index 0000000..e145f3d
+--- /dev/null
++++ b/src/tmp006/pyupm_tmp006.i
+@@ -0,0 +1,15 @@
++// Include doxygen-generated documentation
++%include "pyupm_doxy2swig.i"
++%module pyupm_tmp006
++%include "../upm.i"
++
++%feature("autodoc", "3");
++
++#ifdef DOXYGEN
++%include "tmp006_doc.i"
++#endif
++
++%include "tmp006.hpp"
++%{
++ #include "tmp006.hpp"
++%}
+diff --git a/src/tmp006/tmp006.cpp b/src/tmp006/tmp006.cpp
+new file mode 100644
+index 0000000..be9128a
+--- /dev/null
++++ b/src/tmp006/tmp006.cpp
+@@ -0,0 +1,248 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver tmp006 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <iostream>
++#include <string>
++#include <stdexcept>
++
++#include <unistd.h>
++#include <stdlib.h>
++#include <endian.h>
++
++#include "tmp006.hpp"
++
++using namespace upm;
++
++TMP006::TMP006(int bus, uint8_t conv_rate, int devAddr) : m_i2ControlCtx(bus) {
++ uint8_t reg[2];
++ uint16_t tmp;
++
++ m_temperature = 0;
++
++ m_name = TMP006_NAME;;
++
++ m_controlAddr = devAddr;
++ m_bus = bus;
++
++ if (conv_rate > TMP006_CONFIG_CR_AS16) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_conv_rate() failed");
++ }
++
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ if (checkID() != 0) {
++ /* sensor_id does not match! maybe wrong sensor chosen? */
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": checkID() failed");
++ }
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_CONFIGURATION);
++ reg[0] = (tmp >> 8);
++
++ tmp = TMP006_CONFIG_CR(conv_rate);
++ reg[1] = (tmp >> 8);
++
++ tmp = ((uint16_t)reg[1] << 8) | reg[0];
++
++ ret = m_i2ControlCtx.writeWordReg(TMP006_CONFIGURATION, tmp);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ }
++}
++
++int
++TMP006::checkID(void)
++{
++ uint8_t tmp[2];
++ uint16_t id;
++ int re = 0;
++
++ re = m_i2ControlCtx.readBytesReg(TMP006_DEVICE_ID_REG, tmp, 2);
++ if (re != 2) {
++ /* not enough bytes were read! */
++ return -1;
++ }
++
++ id = ((uint16_t)tmp[0] << 8) | tmp[1];
++
++ if (id != TMP006_DEVICE_ID) {
++ return -1;
++ }
++
++ return 0;
++}
++
++void
++TMP006::resetSensor(void)
++{
++ uint8_t reg[2];
++ uint16_t tmp = TMP006_RST_SOFT;
++ reg[0] = (tmp >> 8);
++ reg[1] = (tmp & 0x00ff);
++ tmp = ((uint16_t)reg[1] << 8) | reg[0];
++
++ mraa::Result ret = m_i2ControlCtx.writeWordReg(TMP006_CONFIGURATION, tmp);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ }
++}
++
++void
++TMP006::setActive(void)
++{
++ uint8_t reg[2];
++ uint16_t tmp;
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_CONFIGURATION);
++ reg[0] = (tmp >> 8);
++ reg[1] = (tmp & 0x00ff);
++ reg[1] |= (TMP006_CONFIG_MOD(TMP006_CONFIG_MOD_CC) >> 8);
++
++ tmp = ((uint16_t)reg[0] << 8) | reg[1];
++
++ mraa::Result ret = m_i2ControlCtx.writeWordReg(TMP006_CONFIGURATION, tmp);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ }
++}
++
++void
++TMP006::setStandby(void)
++{
++ uint8_t reg[2];
++ uint16_t tmp;
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_CONFIGURATION);
++ reg[0] = (tmp >> 8);
++ reg[1] = (tmp & 0x00ff);
++ reg[1] &= ~(TMP006_CONFIG_MOD(TMP006_CONFIG_MOD_CC) >> 8);
++
++ tmp = ((uint16_t)reg[0] << 8) | reg[1];
++
++ mraa::Result ret = m_i2ControlCtx.writeWordReg(TMP006_CONFIGURATION, tmp);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_word_data() failed");
++ }
++}
++
++int
++TMP006::sampleData(void)
++{
++ uint8_t buf[2];
++ uint16_t rawVolt;
++ uint16_t rawTemp;
++ float tamb[1];
++ float tobj[1];
++ uint16_t tmp;
++ uint8_t drdy[1];
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_CONFIGURATION);
++ buf[0] = (tmp >> 8);
++ buf[1] = (tmp & 0x00ff);
++
++ *drdy = buf[0] & (TMP006_DRDY_DATA_RDY);
++
++ if(! (*drdy)) {
++ /* conversation in progress */
++ return -1;
++ }
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_SENSOR_VOLTAGE);
++ buf[0] = (tmp >> 8);
++ buf[1] = (tmp & 0x00ff);
++ rawVolt = ((uint16_t)buf[1] << 8) | buf[0];
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_LOCAL_TEMPERATURE);
++ buf[0] = (tmp >> 8);
++ buf[1] = (tmp & 0x00ff);
++ rawTemp = ((uint16_t)buf[1] << 8) | buf[0];
++
++ convert_data(rawVolt, rawTemp, tamb, tobj);
++ m_temperature = (uint16_t)*tobj;
++
++ return 0;
++}
++
++void
++TMP006::convert_data(int16_t rawv,int16_t rawt, float *tamb, float *tobj)
++{
++ /* calculate die temperature */
++ *tamb = (double)rawt / 128.0;
++ /* die temperature in Kelvin */
++ double tdie_k = *tamb + 273.15;
++
++ /* calculate sensor voltage */
++ double sens_v = (double)rawv * TMP006_CCONST_LSB_SIZE;
++
++ double tdiff = tdie_k - TMP006_CCONST_TREF;
++ double tdiff_pow2 = pow(tdiff, 2);
++
++ double s = TMP006_CCONST_S0 * (1 + TMP006_CCONST_A1 * tdiff
++ + TMP006_CCONST_A2 * tdiff_pow2);
++
++ double v_os = TMP006_CCONST_B0 + TMP006_CCONST_B1 * tdiff
++ + TMP006_CCONST_B2 * tdiff_pow2;
++
++ double f_obj = (sens_v-v_os) + TMP006_CCONST_C2 * pow((sens_v-v_os), 2);
++
++ double t = pow(pow(tdie_k, 4) + (f_obj / s), 0.25);
++ /* calculate object temperature in Celsius */
++ *tobj = (t - 273.15);
++}
++
++float
++TMP006::getTemperature(int bSampleData)
++{
++ if (bSampleData) {
++ if( (sampleData()) == -1) {
++ /* conversation in progress */
++ return (-273.2);
++ }
++ }
++ return (float) m_temperature;
++}
++
++uint16_t
++TMP006::getConfig(void)
++{
++ uint8_t buf[2];
++ uint16_t tmp;
++
++ tmp = m_i2ControlCtx.readWordReg(TMP006_CONFIGURATION);
++ buf[0] = (tmp >> 8);
++ buf[1] = (tmp & 0x00ff);
++
++ return ((uint16_t)buf[1] << 8) | buf[0];
++}
+diff --git a/src/tmp006/tmp006.hpp b/src/tmp006/tmp006.hpp
+new file mode 100644
+index 0000000..a260fc6
+--- /dev/null
++++ b/src/tmp006/tmp006.hpp
+@@ -0,0 +1,202 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver tmp006 by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#pragma once
++
++#include <string>
++#include <mraa/i2c.hpp>
++#include <math.h>
++
++#define TMP006_NAME "TMP006"
++#define TMP006_I2C_ADDRESS 0x41
++#define TMP006_MANUFACTURER_ID 0x5449
++#define TMP006_DEVICE_ID 0x0067
++
++#ifndef TMP006_CONVERSION_TIME
++#define TMP006_CONVERSION_TIME 1E6 /**< Default Conversion Time in us */
++#endif
++
++/* TMP006 Register Map */
++#define TMP006_SENSOR_VOLTAGE 0x00 /* Sensor voltage register */
++#define TMP006_LOCAL_TEMPERATURE 0x01 /* Ambient temperature register */
++#define TMP006_CONFIGURATION 0x02
++#define TMP006_MANUFACTURER_ID_REG 0xFE
++#define TMP006_DEVICE_ID_REG 0xFF
++
++/* TMP006 configuration register bitmap */
++#define TMP006_RST_SOFT (1 << 15)
++
++#define TMP006_CONFIG_MOD_SHIFT 12
++#define TMP006_CONFIG_MOD_MASK 0x7000
++#define TMP006_CONFIG_MOD(x) (((uint16_t)(((uint16_t)(x))<<\
++ TMP006_CONFIG_MOD_SHIFT))\
++ &TMP006_CONFIG_MOD_MASK)
++#define TMP006_CONFIG_MOD_CC 0x07
++#define TMP006_CONFIG_MOD_OFF 0x00
++
++#define TMP006_CONFIG_CR_SHIFT 9
++#define TMP006_CONFIG_CR_MASK 0x0E00
++#define TMP006_CONFIG_CR(x) (((uint16_t)(((uint16_t)(x))<<\
++ TMP006_CONFIG_CR_SHIFT))\
++ &TMP006_CONFIG_CR_MASK)
++#define TMP006_CONFIG_CR_AS1 0x00 /* Conversion Time 0.25 s, AVG Samples: 1 */
++#define TMP006_CONFIG_CR_AS2 0x01 /* Conversion Time 0.5 s, AVG Samples: 2 */
++#define TMP006_CONFIG_CR_AS4 0x02 /* Conversion Time 1 s, AVG Samples: 4 */
++#define TMP006_CONFIG_CR_AS8 0x03 /* Conversion Time 2 s, AVG Samples: 8 */
++#define TMP006_CONFIG_CR_AS16 0x04 /* Conversion Time 4 s, AVG Samples: 16 */
++#define TMP006_CONFIG_CR_DEF TMP006_CONFIG_CR_AS4 /**< Default for Testing */
++
++#define TMP006_DRDY_EN (1 << 8)
++#define TMP006_DRDY_DATA_RDY (1 << 7)
++
++/* constant values for data conversion */
++#ifndef TMP006_CCONST_S0
++#define TMP006_CCONST_S0 6.4E-14 /* Calibration Factor */
++#endif
++
++#define TMP006_CCONST_A1 1.75E-3 /* Constant \f$a_{\mathrm{1}}\f$ */
++#define TMP006_CCONST_A2 -1.678E-5 /* Constant \f$a_{\mathrm{2}}\f$ */
++#define TMP006_CCONST_TREF 298.15 /* Constant \f$T_{\mathrm{REF}}\f$ */
++#define TMP006_CCONST_B0 -2.94E-5 /* Constant \f$b_{\mathrm{0}}\f$ */
++#define TMP006_CCONST_B1 -5.7E-7 /* Constant \f$b_{\mathrm{1}}\f$ */
++#define TMP006_CCONST_B2 4.63E-9 /* Constant \f$b_{\mathrm{2}}\f$ */
++#define TMP006_CCONST_C2 13.4 /* Constant \f$c_{\mathrm{2}}\f$ */
++#define TMP006_CCONST_LSB_SIZE 156.25E-9 /* Sensor Voltage Register LSB Size */
++
++namespace upm {
++
++/**
++ * @brief TMP006 Infrared-Thermopile Sensor
++ * @defgroup tmp006 libupm-tmp006
++ * @ingroup ti i2c temp
++ */
++
++/**
++ * @library tmp006
++ * @sensor tmp006
++ * @comname TMP006 IR-Thermopile Sensor
++ * @type temp
++ * @man ti
++ * @web http://www.ti.com/product/TMP006/datasheet/abstract#SBOS5183423
++ * @con i2c
++ *
++ * @brief API for the TMP006 IR-Thermopile Sensor
++ *
++ * Description in web-link above:
++ * The TMP006 and TMP006B are fully integrated MEMs thermopile sensors that
++ * measure the temperature of an object without having to be in direct contact.
++ * The thermopile absorbs passive infrared energy from an object at wavelengths
++ * between 4 um to 16 um within the end-user defined field of view.
++ * The corresponding change in voltage across the thermopile is digitized and
++ * reported with the on-chip die thermal sensor measurement through an I2C- and
++ * SMBus-compatible interface. With this data, the target object temperature
++ * can be calculated by an external processor.
++ * The Infrared thermopile sensor is specified to operate from –40°C to +125°C.
++ * It is possible to measure an object temperature beyond the device operating
++ * range as long as the device itself does not exceed the operating temperature
++ * range (–40°C to +125°C).
++ *
++ * @snippet tmp006.cxx Interesting
++ */
++class TMP006 {
++ public:
++ /**
++ *
++ * Instantiates an TMP006 object
++ *
++ * @param bus Number of the used bus
++ * @param conv_rate Conversation rate (allowed between 0 and 4)
++ * @param devAddr Address of the used I2C device
++ */
++ TMP006 (int bus, uint8_t conv_rate=TMP006_CONFIG_CR_DEF,
++ int devAddr=TMP006_I2C_ADDRESS);
++
++ /**
++ * Check device_id of sensor
++ *
++ * @return 0 on succes
++ * -1 on error
++ */
++ int checkID(void);
++
++ /**
++ * Performs a soft reset of the TMP006 device to ensure
++ * it is in a known state.
++ */
++ void resetSensor(void);
++
++ /**
++ * Set active mode, this enables periodic measurements.
++ */
++ void setActive(void);
++
++ /**
++ * Set standby mode, this disables periodic measurements.
++ */
++ void setStandby(void);
++
++ /**
++ * Read out data of regs and call further function
++ * Also saves converted value to variable
++ */
++ int sampleData(void);
++
++ /**
++ * Convert raw sensor values to temperature.
++ *
++ * @param rawv Object voltage value
++ * @param rawt Raw die temperature value
++ * @param tamp Converted ambient temperature
++ * @param tobj Converted object temperature
++ */
++ void convert_data(int16_t rawv,int16_t rawt, float *tamb, float *tobj);
++
++ /**
++ * Get the calculated object temperature [degC]
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The object temp in degC on success
++ * and -273.2 on 'conversation in progress'
++ */
++ float getTemperature(int bSampleData = 0);
++
++ /**
++ * Get value of configuration reg
++ */
++ uint16_t getConfig(void);
++
++ private:
++
++ std::string m_name;
++
++ int m_controlAddr;
++ int m_bus;
++ mraa::I2c m_i2ControlCtx;
++
++ int32_t m_temperature;
++};
++
++}
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm/0005-mma8x5x-Added-upm-support-for-some-MMA8X5X-sensors.patch b/recipes-devtools/upm/upm/0005-mma8x5x-Added-upm-support-for-some-MMA8X5X-sensors.patch
new file mode 100644
index 0000000..833cc65
--- /dev/null
+++ b/recipes-devtools/upm/upm/0005-mma8x5x-Added-upm-support-for-some-MMA8X5X-sensors.patch
@@ -0,0 +1,933 @@
+From 8c287e445fb198cc7fceae838154ed05cb972c65 Mon Sep 17 00:00:00 2001
+From: Norbert Wesp <nwesp@phytec.de>
+Date: Fri, 10 Feb 2017 14:48:26 +0100
+Subject: [PATCH 5/6] mma8x5x: Added upm support for some MMA8X5X sensors
+
+This commit adds support for following sensors:
+MMA8652 , MMA8653, MMA8451 , MMA8452 , MMA8453
+These sensors are three-axis accelerometer.
+Examples will be added at a later commit.
+
+Signed-off-by: Norbert Wesp <nwesp@phytec.de>
+---
+ src/mma8x5x/CMakeLists.txt | 5 +
+ src/mma8x5x/javaupm_mma8x5x.i | 19 ++
+ src/mma8x5x/jsupm_mma8x5x.i | 8 +
+ src/mma8x5x/mma8x5x.cpp | 346 ++++++++++++++++++++++++++++++
+ src/mma8x5x/mma8x5x.hpp | 473 ++++++++++++++++++++++++++++++++++++++++++
+ src/mma8x5x/pyupm_mma8x5x.i | 15 ++
+ 6 files changed, 866 insertions(+)
+ create mode 100644 src/mma8x5x/CMakeLists.txt
+ create mode 100644 src/mma8x5x/javaupm_mma8x5x.i
+ create mode 100644 src/mma8x5x/jsupm_mma8x5x.i
+ create mode 100644 src/mma8x5x/mma8x5x.cpp
+ create mode 100644 src/mma8x5x/mma8x5x.hpp
+ create mode 100644 src/mma8x5x/pyupm_mma8x5x.i
+
+diff --git a/src/mma8x5x/CMakeLists.txt b/src/mma8x5x/CMakeLists.txt
+new file mode 100644
+index 0000000..8c53050
+--- /dev/null
++++ b/src/mma8x5x/CMakeLists.txt
+@@ -0,0 +1,5 @@
++set (libname "mma8x5x")
++set (libdescription "Tri-axis Accelerometer Sensor")
++set (module_src ${libname}.cpp)
++set (module_hpp ${libname}.hpp)
++upm_module_init()
+diff --git a/src/mma8x5x/javaupm_mma8x5x.i b/src/mma8x5x/javaupm_mma8x5x.i
+new file mode 100644
+index 0000000..1559737
+--- /dev/null
++++ b/src/mma8x5x/javaupm_mma8x5x.i
+@@ -0,0 +1,19 @@
++%module javaupm_mma8x5x
++%include "../upm.i"
++
++%{
++ #include "mma8x5x.hpp"
++%}
++
++%include "mma8x5x.hpp"
++
++%pragma(java) jniclasscode=%{
++ static {
++ try {
++ System.loadLibrary("javaupm_mma8x5x");
++ } catch (UnsatisfiedLinkError e) {
++ System.err.println("Native code library failed to load. \n" + e);
++ System.exit(1);
++ }
++ }
++%}
+\ No newline at end of file
+diff --git a/src/mma8x5x/jsupm_mma8x5x.i b/src/mma8x5x/jsupm_mma8x5x.i
+new file mode 100644
+index 0000000..cc0fae9
+--- /dev/null
++++ b/src/mma8x5x/jsupm_mma8x5x.i
+@@ -0,0 +1,8 @@
++%module jsupm_mma8x5x
++%include "../upm.i"
++
++%{
++ #include "mma8x5x.hpp"
++%}
++
++%include "mma8x5x.hpp"
+diff --git a/src/mma8x5x/mma8x5x.cpp b/src/mma8x5x/mma8x5x.cpp
+new file mode 100644
+index 0000000..2aaf4ad
+--- /dev/null
++++ b/src/mma8x5x/mma8x5x.cpp
+@@ -0,0 +1,346 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver mma8x5x by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <iostream>
++#include <string>
++#include <stdexcept>
++
++#include <unistd.h>
++#include <stdlib.h>
++#include <endian.h>
++#include <time.h>
++
++#include "mma8x5x.hpp"
++
++using namespace upm;
++
++MMA8X5X::MMA8X5X (int bus, mma8x5x_params_t *params,
++ int devAddr) : m_i2ControlCtx(bus) {
++ uint8_t reg;
++
++ s_data->x = 0;
++ s_data->y = 0;
++ s_data->z = 0;
++
++ m_controlAddr = devAddr;
++ m_bus = bus;
++
++ mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_address() failed");
++ }
++
++ if (setDeviceParams(params)) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": setDeviceParams() failed");
++ }
++
++ /* reset device */
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_CTRL_REG2, MMA8X5X_CTRL_REG2_RST);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++ do {
++ usleep(500000);
++ reg = m_i2ControlCtx.readReg(MMA8X5X_CTRL_REG2);
++ } while (reg & MMA8X5X_CTRL_REG2_RST);
++
++ /* configure the user offset */
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_OFF_X, s_params->offsetX);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_OFF_Y, s_params->offsetY);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_OFF_Z, s_params->offsetZ);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++
++ /* configure range */
++ reg = (s_params->range & MMA8X5X_XYZ_DATA_CFG_FS_MASK);
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_XYZ_DATA_CFG, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++
++ /* configure rate and activate the device */
++ reg = ((s_params->rate & MMA8X5X_CTRL_REG1_DR_MASK) |
++ MMA8X5X_CTRL_REG1_ACTIVE);
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_CTRL_REG1, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ }
++}
++
++int
++MMA8X5X::setDeviceName(uint8_t type)
++{
++ uint8_t id;
++
++ if (type == 0){
++ id = m_i2ControlCtx.readReg(MMA8X5X_DEVICE_ID_REG);
++ } else {
++ id = type;
++ }
++
++ switch (id) {
++ case (MMA8X5X_DEVICE_ID_MMA8652):
++ m_name = MMA8X5X_NAME_MMA8652;
++ s_params->type = MMA8X5X_DEVICE_ID_MMA8652;
++ break;
++ case (MMA8X5X_DEVICE_ID_MMA8653):
++ m_name = MMA8X5X_NAME_MMA8653;
++ s_params->type = MMA8X5X_DEVICE_ID_MMA8653;
++ break;
++ case (MMA8X5X_DEVICE_ID_MMA8451):
++ m_name = MMA8X5X_NAME_MMA8451;
++ s_params->type = MMA8X5X_DEVICE_ID_MMA8451;
++ break;
++ case (MMA8X5X_DEVICE_ID_MMA8452):
++ m_name = MMA8X5X_NAME_MMA8452;
++ s_params->type = MMA8X5X_DEVICE_ID_MMA8452;
++ break;
++ case (MMA8X5X_DEVICE_ID_MMA8453):
++ m_name = MMA8X5X_NAME_MMA8453;
++ s_params->type = MMA8X5X_DEVICE_ID_MMA8453;
++ break;
++ default:
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++MMA8X5X::setDeviceParams (mma8x5x_params_t* params)
++{
++ if (params == NULL) {
++ if (setDeviceName(0)) {
++ return -1;
++ }
++
++ s_params->rate = MMA8X5X_RATE_DEFAULT;
++ s_params->range = MMA8X5X_RANGE_DEFAULT;
++ s_params->offsetX = 0;
++ s_params->offsetY = 0;
++ s_params->offsetZ = 0;
++ } else {
++ if (params->type != MMA8X5X_DEVICE_ID_MMA8652 &&
++ params->type != MMA8X5X_DEVICE_ID_MMA8653 &&
++ params->type != MMA8X5X_DEVICE_ID_MMA8451 &&
++ params->type != MMA8X5X_DEVICE_ID_MMA8452 &&
++ params->type != MMA8X5X_DEVICE_ID_MMA8453) {
++ /* given type is not supported */
++ return -1;
++ }
++ setDeviceName(params->type);
++
++ if (params->rate != MMA8X5X_RATE_800HZ &&
++ params->rate != MMA8X5X_RATE_400HZ &&
++ params->rate != MMA8X5X_RATE_200HZ &&
++ params->rate != MMA8X5X_RATE_100HZ &&
++ params->rate != MMA8X5X_RATE_50HZ &&
++ params->rate != MMA8X5X_RATE_1HZ25 &&
++ params->rate != MMA8X5X_RATE_6HZ25 &&
++ params->rate != MMA8X5X_RATE_1HZ56) {
++ /* given rate is not supported */
++ return -1;
++ }
++ s_params->rate = params->rate;
++
++ if (params->range != MMA8X5X_RANGE_2G &&
++ params->range != MMA8X5X_RANGE_4G &&
++ params->range != MMA8X5X_RANGE_8G) {
++ /* given range is not supported */
++ return -1;
++ }
++ s_params->range = params->range;
++
++ s_params->offsetX = params->offsetX;
++ s_params->offsetY = params->offsetY;
++ s_params->offsetZ = params->offsetZ;
++ }
++
++ return 0;
++}
++
++int
++MMA8X5X::setUserOffset(int8_t x, int8_t y, int8_t z)
++{
++ mraa::Result ret = m_i2ControlCtx.writeReg(MMA8X5X_OFF_X, (uint8_t)x);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_OFF_Y, (uint8_t)y);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++ ret = m_i2ControlCtx.writeReg(MMA8X5X_OFF_Z, (uint8_t)z);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++
++ return 0;
++}
++
++int
++MMA8X5X::setActive(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(MMA8X5X_CTRL_REG1);
++ reg |= MMA8X5X_CTRL_REG1_ACTIVE;
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(MMA8X5X_CTRL_REG1, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++ return 0;
++}
++
++int
++MMA8X5X::setStandby(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(MMA8X5X_CTRL_REG1);
++ reg &= ~MMA8X5X_CTRL_REG1_ACTIVE;
++
++ mraa::Result ret = m_i2ControlCtx.writeReg(MMA8X5X_CTRL_REG1, reg);
++ if (ret != mraa::SUCCESS) {
++ throw std::invalid_argument(std::string(__FUNCTION__) +
++ ": mraa_i2c_write_byte_data() failed");
++ return -1;
++ }
++ return 0;
++}
++
++int
++MMA8X5X::isReady(void)
++{
++ uint8_t reg;
++
++ reg = m_i2ControlCtx.readReg(MMA8X5X_STATUS);
++
++ if (reg & MMA8X5X_STATUS_ZYXDR) {
++ return MMA8X5X_DATA_READY;
++ } else {
++ return MMA8X5X_NODATA;
++ }
++}
++
++int
++MMA8X5X::sampleData(void)
++{
++ uint8_t buf[7];
++ int re = 0;
++
++ re = m_i2ControlCtx.readBytesReg(MMA8X5X_STATUS, buf, 7);
++ if (re != 7) {
++ /* did not read enough bytes */
++ return -1;
++ }
++
++ s_data->x = ((int16_t)(buf[1] << 8 | buf[2])) / (16 >> s_params->range);
++ s_data->y = ((int16_t)(buf[3] << 8 | buf[4])) / (16 >> s_params->range);
++ s_data->z = ((int16_t)(buf[5] << 8 | buf[6])) / (16 >> s_params->range);
++
++ return 0;
++}
++
++int16_t
++MMA8X5X::getX(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -999;
++ }
++ }
++
++ return s_data->x;
++}
++
++int16_t
++MMA8X5X::getY(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -999;
++ }
++ }
++
++ return s_data->y;
++}
++
++int16_t
++MMA8X5X::getZ(int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -999;
++ }
++ }
++
++ return s_data->z;
++}
++
++int
++MMA8X5X::getData(mma8x5x_data_t* data, int bSampleData)
++{
++ if (bSampleData) {
++ if (sampleData() != 0) {
++ /* error in read values from reg */
++ return -1;
++ }
++ }
++
++ data->x = s_data->x;
++ data->y = s_data->y;
++ data->z = s_data->z;
++
++ return 0;
++}
+\ No newline at end of file
+diff --git a/src/mma8x5x/mma8x5x.hpp b/src/mma8x5x/mma8x5x.hpp
+new file mode 100644
+index 0000000..296e9ac
+--- /dev/null
++++ b/src/mma8x5x/mma8x5x.hpp
+@@ -0,0 +1,473 @@
++/*
++ * Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * based on: RIOT-driver mma8x5x by Johann Fischer <j.fischer@phytec.de>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#pragma once
++
++#include <string>
++#include <mraa/i2c.hpp>
++#include <stdint.h>
++#include <stdbool.h>
++
++/* Supported devices by this driver */
++#define MMA8X5X_DEVICE_ID_MMA8652 0x4a
++#define MMA8X5X_DEVICE_ID_MMA8653 0x5a
++#define MMA8X5X_DEVICE_ID_MMA8451 0x1a
++#define MMA8X5X_DEVICE_ID_MMA8452 0x2a
++#define MMA8X5X_DEVICE_ID_MMA8453 0x3a
++
++#define MMA8X5X_NAME_MMA8652 "MMA8652"
++#define MMA8X5X_NAME_MMA8653 "MMA8653"
++#define MMA8X5X_NAME_MMA8451 "MMA8451"
++#define MMA8X5X_NAME_MMA8452 "MMA8452"
++#define MMA8X5X_NAME_MMA8453 "MMA8453"
++
++/* MMA8x5x Fix settings of supported sensors */
++#define MMA8X5X_I2C_ADDRESS 0x1D
++#define MMA8X5X_DEVICE_ID_REG 0x0D
++
++/* MMA8x5x Register Map */
++#define MMA8X5X_STATUS 0x00 /* Data or FIFO Status */
++#define MMA8X5X_OUT_X_MSB 0x01 /* [7:0] are 8 MSBs of X data */
++#define MMA8X5X_OUT_X_LSB 0x02 /* [7:4] are 4 LSBs of X data */
++#define MMA8X5X_OUT_Y_MSB 0x03 /* [7:0] are 8 MSBs of Y data */
++#define MMA8X5X_OUT_Y_LSB 0x04 /* [7:4] are 4 LSBs of Y data */
++#define MMA8X5X_OUT_Z_MSB 0x05 /* [7:0] are 8 MSBs of Z data */
++#define MMA8X5X_OUT_Z_LSB 0x06 /* [7:4] are 8 LSBs of Z data */
++#define MMA8X5X_F_SETUP 0x09 /* FIFO setup */
++#define MMA8X5X_TRIG_CFG 0x0A /* Map of FIFO data capture events */
++#define MMA8X5X_SYSMOD 0x0B /* Current System mode */
++#define MMA8X5X_INT_SOURCE 0x0C /* Interrupt status */
++#define MMA8X5X_XYZ_DATA_CFG 0x0E /* Dynamic Range Settings */
++#define MMA8X5X_HP_FILTER_CUTOFF 0x0F /* High-Pass Filter Selection */
++#define MMA8X5X_PL_STATUS 0x10 /* Landscape/Portrait
++ orientation status */
++#define MMA8X5X_PL_CFG 0x11 /* Landscape/Portrait configuration */
++#define MMA8X5X_PL_COUNT 0x12 /* Landscape/Portrait debounce counter */
++#define MMA8X5X_PL_BF_ZCOMP 0x13 /* Back/Front, Z-Lock Trip threshold */
++#define MMA8X5X_P_L_THS_REG 0x14 /* Portrait/Landscape
++ Threshold and Hysteresis */
++#define MMA8X5X_FF_MT_CFG 0x15 /* Freefall/Motion
++ functional block configuration */
++#define MMA8X5X_FF_MT_SRC 0x16 /* Freefall/Motion
++ event source register */
++#define MMA8X5X_FF_MT_THS 0x17 /* Freefall/Motion threshold register */
++#define MMA8X5X_FF_MT_COUNT 0x18 /* Freefall/Motion debounce counter */
++#define MMA8X5X_TRANSIENT_CFG 0x1D /* Transient
++ functional block configuration */
++#define MMA8X5X_TRANSIENT_SRC 0x1E /* Transient event status register */
++#define MMA8X5X_TRANSIENT_THS 0x1F /* Transient event threshold */
++#define MMA8X5X_TRANSIENT_COUNT 0x20 /* Transient debounce counter */
++#define MMA8X5X_PULSE_CFG 0x21 /* Pulse enable configuration */
++#define MMA8X5X_PULSE_SRC 0x22 /* Pulse detection source */
++#define MMA8X5X_PULSE_THSX 0x23 /* X pulse threshold */
++#define MMA8X5X_PULSE_THSY 0x24 /* Y pulse threshold */
++#define MMA8X5X_PULSE_THSZ 0x25 /* Z pulse threshold */
++#define MMA8X5X_PULSE_TMLT 0x26 /* Time limit for pulse */
++#define MMA8X5X_PULSE_LTCY 0x27 /* Latency time for 2nd pulse */
++#define MMA8X5X_PULSE_WIND 0x28 /* Window time for 2nd pulse */
++#define MMA8X5X_ASLP_COUNT 0x29 /* Counter setting for Auto-SLEEP */
++#define MMA8X5X_CTRL_REG1 0x2A /* Data rates and modes setting */
++#define MMA8X5X_CTRL_REG2 0x2B /* Sleep Enable, OS modes, RST, ST */
++#define MMA8X5X_CTRL_REG3 0x2C /* Wake from Sleep, IPOL, PP_OD */
++#define MMA8X5X_CTRL_REG4 0x2D /* Interrupt enable register */
++#define MMA8X5X_CTRL_REG5 0x2E /* Interrupt pin (INT1/INT2) map */
++#define MMA8X5X_OFF_X 0x2F /* X-axis offset adjust */
++#define MMA8X5X_OFF_Y 0x30 /* Y-axis offset adjust */
++#define MMA8X5X_OFF_Z 0x31 /* Z-axis offset adjust */
++
++/* MMA8x5x Available sampling rates */
++#define MMA8X5X_RATE_800HZ (0 << 3) /* 800 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_400HZ (1 << 3) /* 400 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_200HZ (2 << 3) /* 200 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_100HZ (3 << 3) /* 100 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_50HZ (4 << 3) /* 50 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_1HZ25 (5 << 3) /* 12.5 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_6HZ25 (6 << 3) /* 6.25 Hz Ouput Data Rate in WAKE mode */
++#define MMA8X5X_RATE_1HZ56 (7 << 3) /* 1.56 Hz Ouput Data Rate in WAKE mode */
++
++#define MMA8X5X_RATE_DEFAULT MMA8X5X_RATE_200HZ
++
++/* MMA8x5x Available range options */
++#define MMA8X5X_RANGE_2G 0
++#define MMA8X5X_RANGE_4G 1
++#define MMA8X5X_RANGE_8G 2
++
++#define MMA8X5X_RANGE_DEFAULT MMA8X5X_RANGE_2G
++
++/* Named return values */
++#define MMA8X5X_OK 0 /* everything was fine */
++#define MMA8X5X_DATA_READY 1 /* new data ready to be read */
++#define MMA8X5X_NOI2C -1 /* I2C communication failed */
++#define MMA8X5X_NODEV -2 /* no MMA8X5X device found on the bus */
++#define MMA8X5X_NODATA -3 /* no data available */
++
++/* MMA8x5x Register Bitfields */
++#define MMA8X5X_STATUS_XDR (1 << 0)
++#define MMA8X5X_STATUS_YDR (1 << 1)
++#define MMA8X5X_STATUS_ZDR (1 << 2)
++#define MMA8X5X_STATUS_ZYXDR (1 << 3)
++#define MMA8X5X_STATUS_XOW (1 << 4)
++#define MMA8X5X_STATUS_YOW (1 << 5)
++#define MMA8X5X_STATUS_ZOW (1 << 6)
++#define MMA8X5X_STATUS_ZYXOW (1 << 7)
++
++#define MMA8X5X_F_STATUS_F_CNT_MASK 0x3F
++#define MMA8X5X_F_STATUS_F_WMRK_FLAG (1 << 6)
++#define MMA8X5X_F_STATUS_F_OVF (1 << 7)
++
++#define MMA8X5X_F_SETUP_MODE_MASK 0xC0
++#define MMA8X5X_F_SETUP_MODE_DISABLED 0
++#define MMA8X5X_F_SETUP_MODE_CIRCULAR 1
++#define MMA8X5X_F_SETUP_MODE_STOP 2
++#define MMA8X5X_F_SETUP_MODE_TRIGGER 3
++#define MMA8X5X_F_SETUP_F_WMRK_MASK 0x3F
++
++#define MMA8X5X_TRIG_CFG_FF_MT (1 << 2)
++#define MMA8X5X_TRIG_CFG_PULSE (1 << 3)
++#define MMA8X5X_TRIG_CFG_LNDPRT (1 << 4)
++#define MMA8X5X_TRIG_CFG_TRANS (1 << 5)
++
++#define MMA8X5X_SYSMOD_MASK 0x3
++#define MMA8X5X_SYSMOD_STANDBY 0
++#define MMA8X5X_SYSMOD_WAKE 1
++#define MMA8X5X_SYSMOD_SLEEP 2
++#define MMA8X5X_SYSMOD_FGT_MASK 0x7C
++#define MMA8X5X_SYSMOD_FGERR (1 << 7)
++
++#define MMA8X5X_INT_SOURCE_DRDY (1 << 0)
++#define MMA8X5X_INT_SOURCE_FF_MT (1 << 2)
++#define MMA8X5X_INT_SOURCE_PULSE (1 << 3)
++#define MMA8X5X_INT_SOURCE_LNDPRT (1 << 4)
++#define MMA8X5X_INT_SOURCE_TRANS (1 << 5)
++#define MMA8X5X_INT_SOURCE_FIFO (1 << 6)
++#define MMA8X5X_INT_SOURCE_ASLP (1 << 7)
++
++#define MMA8X5X_XYZ_DATA_CFG_FS_MASK 0x3
++#define MMA8X5X_XYZ_DATA_CFG_HPF_OUT (1 << 4)
++
++#define MMA8X5X_HP_FILTER_SEL_MASK 0x03
++#define MMA8X5X_HP_FILTER_LPF_EN (1 << 4)
++#define MMA8X5X_HP_FILTER_HPF_BYP (1 << 5)
++
++#define MMA8X5X_PL_STATUS_BAFRO (1 << 0)
++#define MMA8X5X_PL_STATUS_LAPO_MASK 0x6
++#define MMA8X5X_PL_STATUS_LAPO_P_UP 0
++#define MMA8X5X_PL_STATUS_LAPO_P_DOWN 1
++#define MMA8X5X_PL_STATUS_LAPO_L_RIGHT 2
++#define MMA8X5X_PL_STATUS_LAPO_L_LEFT 3
++#define MMA8X5X_PL_STATUS_LO (1 << 6)
++#define MMA8X5X_PL_STATUS_NEWLP (1 << 7)
++
++#define MMA8X5X_PL_CFG_PL_EN (1 << 6)
++#define MMA8X5X_PL_CFG_DBCNTM (1 << 7)
++
++#define MMA8X5X_PL_BF_ZCOMP_ZLOCK_MASK 0x07
++#define MMA8X5X_PL_BF_ZCOMP_BKFR_MASK 0xC0
++
++#define MMA8X5X_P_L_HYS_MASK 0x07
++#define MMA8X5X_P_L_THS_MASK 0xF8
++
++#define MMA8X5X_FF_MT_CFG_XEFE (1 << 3)
++#define MMA8X5X_FF_MT_CFG_YEFE (1 << 4)
++#define MMA8X5X_FF_MT_CFG_ZEFE (1 << 5)
++#define MMA8X5X_FF_MT_CFG_OAE (1 << 6)
++#define MMA8X5X_FF_MT_CFG_ELE (1 << 7)
++
++#define MMA8X5X_FF_MT_SRC_XHP (1 << 0)
++#define MMA8X5X_FF_MT_SRC_XHE (1 << 1)
++#define MMA8X5X_FF_MT_SRC_YHP (1 << 2)
++#define MMA8X5X_FF_MT_SRC_YHE (1 << 3)
++#define MMA8X5X_FF_MT_SRC_ZHP (1 << 4)
++#define MMA8X5X_FF_MT_SRC_ZHE (1 << 5)
++#define MMA8X5X_FF_MT_SRC_EA (1 << 7)
++
++#define MMA8X5X_FF_MT_THS_MASK 0x7F
++#define MMA8X5X_FF_MT_THS_DBCNTM (1 << 7)
++
++#define MMA8X5X_TRANSIENT_CFG_HPF_BYP (1 << 0)
++#define MMA8X5X_TRANSIENT_CFG_XTEFE (1 << 1)
++#define MMA8X5X_TRANSIENT_CFG_YTEFE (1 << 2)
++#define MMA8X5X_TRANSIENT_CFG_ZTEFE (1 << 3)
++#define MMA8X5X_TRANSIENT_CFG_ELE (1 << 4)
++
++#define MMA8X5X_TRANSIENT_SRC_XTPOL (1 << 0)
++#define MMA8X5X_TRANSIENT_SRC_XTEVENT (1 << 1)
++#define MMA8X5X_TRANSIENT_SRC_YTPOL (1 << 2)
++#define MMA8X5X_TRANSIENT_SRC_YTEVENT (1 << 3)
++#define MMA8X5X_TRANSIENT_SRC_ZTPOL (1 << 4)
++#define MMA8X5X_TRANSIENT_SRC_ZTEVENT (1 << 5)
++#define MMA8X5X_TRANSIENT_SRC_EA (1 << 6)
++
++#define MMA8X5X_TRANSIENT_THS_MASK 0x7F
++#define MMA8X5X_TRANSIENT_THS_DBCNTM (1<< 7)
++
++#define MMA8X5X_PULSE_CFG_XSPEFE (1 << 0)
++#define MMA8X5X_PULSE_CFG_XDPEFE (1 << 1)
++#define MMA8X5X_PULSE_CFG_YSPEFE (1 << 2)
++#define MMA8X5X_PULSE_CFG_YDPEFE (1 << 3)
++#define MMA8X5X_PULSE_CFG_ZSPEFE (1 << 4)
++#define MMA8X5X_PULSE_CFG_ZDPEFE (1 << 5)
++#define MMA8X5X_PULSE_CFG_ELE (1 << 6)
++#define MMA8X5X_PULSE_CFG_DPA (1 << 7)
++
++#define MMA8X5X_PULSE_SRC_POLX (1 << 0)
++#define MMA8X5X_PULSE_SRC_POLY (1 << 1)
++#define MMA8X5X_PULSE_SRC_POLZ (1 << 2)
++#define MMA8X5X_PULSE_SRC_DPE (1 << 3)
++#define MMA8X5X_PULSE_SRC_AXX (1 << 4)
++#define MMA8X5X_PULSE_SRC_AXY (1 << 5)
++#define MMA8X5X_PULSE_SRC_AXZ (1 << 6)
++#define MMA8X5X_PULSE_SRC_EA (1 << 7)
++
++#define MMA8X5X_PULSE_THSX_MASK 0x7F
++#define MMA8X5X_PULSE_THSY_MASK 0x7F
++#define MMA8X5X_PULSE_THSZ_MASK 0x7F
++
++#define MMA8X5X_CTRL_REG1_ACTIVE (1 << 0)
++#define MMA8X5X_CTRL_REG1_F_READ (1 << 1)
++#define MMA8X5X_CTRL_REG1_DR_MASK 0x38
++#define MMA8X5X_CTRL_REG1_DR_SHIFT 3
++#define MMA8X5X_CTRL_REG1_DR(x) (((uint8_t)(((uint8_t)(x))<<\
++ MMA8X5X_CTRL_REG1_DR_SHIFT))\
++ &MMA8X5X_CTRL_REG1_DR_MASK)
++#define MMA8X5X_CTRL_REG1_ASR_MASK 0xC0
++#define MMA8X5X_CTRL_REG1_ASR_50HZ 0
++#define MMA8X5X_CTRL_REG1_ASR_12HZ5 1
++#define MMA8X5X_CTRL_REG1_ASR_6HZ25 2
++#define MMA8X5X_CTRL_REG1_ASR_1HZ56 3
++
++#define MMA8X5X_CTRL_REG2_MODS_MASK 0x3
++#define MMA8X5X_CTRL_REG2_MODS_NORMAL 0
++#define MMA8X5X_CTRL_REG2_MODS_LNLP 1
++#define MMA8X5X_CTRL_REG2_MODS_HR 2
++#define MMA8X5X_CTRL_REG2_MODS_LP 3
++#define MMA8X5X_CTRL_REG2_SLPE (1 << 2)
++#define MMA8X5X_CTRL_REG2_SMODS_MASK 0x18
++#define MMA8X5X_CTRL_REG2_SMODS_NORMAL 0
++#define MMA8X5X_CTRL_REG2_SMODS_LNLP 1
++#define MMA8X5X_CTRL_REG2_SMODS_HR 2
++#define MMA8X5X_CTRL_REG2_SMODS_LP 3
++#define MMA8X5X_CTRL_REG2_RST (1 << 6)
++#define MMA8X5X_CTRL_REG2_ST (1 << 7)
++
++#define MMA8X5X_CTRL_REG3_PP_OD (1 << 0)
++#define MMA8X5X_CTRL_REG3_IPOL (1 << 1)
++#define MMA8X5X_CTRL_REG3_WAKE_FF_MT (1 << 3)
++#define MMA8X5X_CTRL_REG3_WAKE_PULSE (1 << 4)
++#define MMA8X5X_CTRL_REG3_WAKE_LNDPRT (1 << 5)
++#define MMA8X5X_CTRL_REG3_WAKE_TRANS (1 << 6)
++#define MMA8X5X_CTRL_REG3_FIFO_GATE (1 << 7)
++
++#define MMA8X5X_CTRL_REG4_INT_EN_DRDY (1 << 0)
++#define MMA8X5X_CTRL_REG4_INT_EN_FF_MT (1 << 2)
++#define MMA8X5X_CTRL_REG4_INT_EN_PULSE (1 << 3)
++#define MMA8X5X_CTRL_REG4_INT_EN_LNDPRT (1 << 4)
++#define MMA8X5X_CTRL_REG4_INT_EN_TRANS (1 << 5)
++#define MMA8X5X_CTRL_REG4_INT_EN_FIFO (1 << 6)
++#define MMA8X5X_CTRL_REG4_INT_EN_ASLP (1 << 7)
++
++#define MMA8X5X_CTRL_REG5_INT_CFG_DRDY (1 << 0)
++#define MMA8X5X_CTRL_REG5_INT_CFG_FF_MT (1 << 2)
++#define MMA8X5X_CTRL_REG5_INT_CFG_PULSE (1 << 3)
++#define MMA8X5X_CTRL_REG5_INT_CFG_LNDPRT (1 << 4)
++#define MMA8X5X_CTRL_REG5_INT_CFG_TRANS (1 << 5)
++#define MMA8X5X_CTRL_REG5_INT_CFG_FIFO (1 << 6)
++#define MMA8X5X_CTRL_REG5_INT_CFG_ASLP (1 << 7)
++
++namespace upm {
++
++typedef struct {
++ uint8_t type;
++ uint8_t rate;
++ uint8_t range;
++ uint8_t offsetX;
++ uint8_t offsetY;
++ uint8_t offsetZ;
++} mma8x5x_params_t;
++
++typedef struct {
++ int16_t x;
++ int16_t y;
++ int16_t z;
++} mma8x5x_data_t;
++
++/**
++ * @brief MMA8X5X Three-Axis Accelerometer
++ * @defgroup mma8x5x libupm-mma8x5x
++ * @ingroup freescale i2c accelerometer compass
++ */
++
++/**
++ * @library mma8x5x
++ * @sensor mma8x5x
++ * @comname MMA8X5X Three-Axis Accelerometer
++ * @altid mma8451 mma8452 mma8453 mma8652 mma8653
++ * @type accelerometer compass
++ * @man freescale
++ * @web http://www.nxp.com/products/sensors/accelerometers:DRSNSAXLRTN
++ * @con i2c
++ *
++ * @brief API for the MMA8X5X Three-Axis Accelerometer
++ *
++ * Description in web-link above:
++ * The NXP MMA8X5X are low-power, three-axis capacitive micromachined
++ * accelerometer with 10/12/14 bits of resolution. These accelerometer
++ * are packed with embedded functions with flexible user-programmable
++ * options configurable to two interrupt pins. The MMA8X5X have user-selectable
++ * full scales of ±2g/±4g/±8g.
++ *
++ * @snippet mma8x5x.cxx Interesting
++ */
++class MMA8X5X {
++ public:
++ /**
++ *
++ * Instantiates an MMA8X5X object
++ *
++ * @param bus Number of the used bus
++ * @params params Params of device
++ * @param devAddr Address of the used I2C device
++ */
++ MMA8X5X (int bus, mma8x5x_params_t* params=NULL,
++ int devAddr=MMA8X5X_I2C_ADDRESS);
++
++ /**
++ * Set device name and type matching given type or
++ * read out devive_id to set name and type of device
++ *
++ * @param type Type of device if set or
++ * 0 if needed to find out by it
++ * @return 0 on success
++ * -1 on error
++ */
++ int setDeviceName(uint8_t type);
++
++ /**
++ * Set device params to given data or
++ * set default params and read out devive_id to set type of device
++ *
++ * @param params Params of device if set by user
++ * NULL if it is not set by user
++ * @return 0 on success
++ * -1 on error
++ */
++ int setDeviceParams(mma8x5x_params_t* params);
++
++ /**
++ * Set user offset correction
++ * Offset correction register will be erased after accelerometer reset
++ *
++ * @param x Offset correction value for x-axis
++ * @param y Offset correction value for y-axis
++ * @param z Offset correction value for z-axis
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setUserOffset(int8_t x, int8_t y, int8_t z);
++
++ /**
++ * Set active mode, this enables periodic measurements
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setActive(void);
++
++ /**
++ * Set standby mode, this disables periodic measurements
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int setStandby(void);
++
++ /**
++ * Check for new set of measurement data.
++ *
++ * @return MMA8X5X_DATA_READY if new sample is ready
++ * MMA8X5X_NODATA if nothing is available
++ */
++ int isReady(void);
++
++ /**
++ * Read & calculate accelerometer data in mg & saves them to variables
++ *
++ * @return 0 on success
++ * -1 on error
++ */
++ int sampleData(void);
++
++ /**
++ * Get x-axis acceleration
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The x-axis acceleration on success
++ * -999 on error
++ */
++ int16_t getX(int bSampleData = 0);
++
++ /**
++ * Get y-axis acceleration
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The y-axis acceleration on success
++ * -999 on error
++ */
++ int16_t getY(int bSampleData = 0);
++
++ /**
++ * Get z-axis acceleration
++ *
++ * @param bSampleData Flag to read sensor
++ * @return The z-axis acceleration on success
++ * -999 on error
++ */
++ int16_t getZ(int bSampleData = 0);
++
++ /**
++ * Get sensor values
++ *
++ * @param data Sensor values
++ * @param bSampleData Flag to read sensor
++ * @return 0 on success
++ * -1 on error
++ */
++ int getData(mma8x5x_data_t* data, int bSampleData = 0);
++
++ private:
++
++ std::string m_name;
++
++ int m_controlAddr;
++ int m_bus;
++ mraa::I2c m_i2ControlCtx;
++
++ mma8x5x_params_t s_params[1];
++ mma8x5x_data_t s_data[1];
++};
++
++}
+diff --git a/src/mma8x5x/pyupm_mma8x5x.i b/src/mma8x5x/pyupm_mma8x5x.i
+new file mode 100644
+index 0000000..bfeaa19
+--- /dev/null
++++ b/src/mma8x5x/pyupm_mma8x5x.i
+@@ -0,0 +1,15 @@
++// Include doxygen-generated documentation
++%include "pyupm_doxy2swig.i"
++%module pyupm_mma8x5x
++%include "../upm.i"
++
++%feature("autodoc", "3");
++
++#ifdef DOXYGEN
++%include "mma8x5x_doc.i"
++#endif
++
++%include "mma8x5x.hpp"
++%{
++ #include "mma8x5x.hpp"
++%}
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm/0006-examples-Added-some-examples-for-added-sensors.patch b/recipes-devtools/upm/upm/0006-examples-Added-some-examples-for-added-sensors.patch
new file mode 100644
index 0000000..a5e0549
--- /dev/null
+++ b/recipes-devtools/upm/upm/0006-examples-Added-some-examples-for-added-sensors.patch
@@ -0,0 +1,815 @@
+From 6db5c713885b02f5417a532ac2ac6b4fcaa6c75a Mon Sep 17 00:00:00 2001
+From: Norbert Wesp <nwesp@phytec.de>
+Date: Fri, 10 Feb 2017 14:51:40 +0100
+Subject: [PATCH] examples: Added some examples for added sensors
+
+For each added sensor I wrote an c++ and python example:
+Sensors: HDC1000, MAG3110, MMA8X5X, TCS37727, TMP006
+I also added these examples in doxy/samples.mapping.txt
+and added the .cxx-examples to the examples/c++/CMakeLists.txt.
+
+Signed-off-by: Norbert Wesp <nwesp@phytec.de>
+---
+ doxy/samples.mapping.txt | 5 +++
+ examples/c++/CMakeLists.txt | 5 +++
+ examples/c++/hdc1000.cxx | 67 +++++++++++++++++++++++++++++++++
+ examples/c++/mag3110.cxx | 76 +++++++++++++++++++++++++++++++++++++
+ examples/c++/mma8x5x.cxx | 91 +++++++++++++++++++++++++++++++++++++++++++++
+ examples/c++/tcs37727.cxx | 77 ++++++++++++++++++++++++++++++++++++++
+ examples/c++/tmp006.cxx | 69 ++++++++++++++++++++++++++++++++++
+ examples/python/hdc1000.py | 57 ++++++++++++++++++++++++++++
+ examples/python/mag3110.py | 62 ++++++++++++++++++++++++++++++
+ examples/python/mma8x5x.py | 62 ++++++++++++++++++++++++++++++
+ examples/python/tcs37727.py | 63 +++++++++++++++++++++++++++++++
+ examples/python/tmp006.py | 60 ++++++++++++++++++++++++++++++
+ 12 files changed, 694 insertions(+)
+ create mode 100644 examples/c++/hdc1000.cxx
+ create mode 100644 examples/c++/mag3110.cxx
+ create mode 100644 examples/c++/mma8x5x.cxx
+ create mode 100644 examples/c++/tcs37727.cxx
+ create mode 100644 examples/c++/tmp006.cxx
+ create mode 100644 examples/python/hdc1000.py
+ create mode 100644 examples/python/mag3110.py
+ create mode 100644 examples/python/mma8x5x.py
+ create mode 100644 examples/python/tcs37727.py
+ create mode 100644 examples/python/tmp006.py
+
+diff --git a/doxy/samples.mapping.txt b/doxy/samples.mapping.txt
+index 492c967..e4231a3 100644
+--- a/doxy/samples.mapping.txt
++++ b/doxy/samples.mapping.txt
+@@ -71,3 +71,8 @@ vdiv.cxx VDivSample.java vdiv.js vdiv.py
+ water.cxx WaterSample.java water.js water.py
+ wt5001.cxx WT5001Sample.java wt5001.js wt5001.py
+ yg1006.cxx YG1006Sample.java yg1006.js yg1006.py
++hdc1000.cxx hdc1000.py
++mag3110.cxx mag3110.py
++mma8x5x.cxx mma8x5x.py
++tcs37727.cxx tcs37727.py
++tmp006.cxx tmp006.py
+diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt
+index f2e5e55..85cd4cf 100644
+--- a/examples/c++/CMakeLists.txt
++++ b/examples/c++/CMakeLists.txt
+@@ -329,6 +329,11 @@ add_example (rf22-server)
+ add_example (rf22-client)
+ add_example (mcp2515)
+ add_example (max30100)
++add_example (hdc1000)
++add_example (mag3110)
++add_example (mma8x5x)
++add_example (tcs37727)
++add_example (tmp006)
+
+ # These are special cases where you specify example binary, source file and module(s)
+ include_directories (${PROJECT_SOURCE_DIR}/src)
+diff --git a/examples/c++/hdc1000.cxx b/examples/c++/hdc1000.cxx
+new file mode 100644
+index 0000000..a05d998
+--- /dev/null
++++ b/examples/c++/hdc1000.cxx
+@@ -0,0 +1,67 @@
++/* Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <unistd.h>
++#include <iostream>
++#include <signal.h>
++
++#include "hdc1000.hpp"
++
++using namespace upm;
++
++bool run = true;
++
++void sig_handler(int sig)
++{
++ if (sig == SIGINT)
++ run = false;
++}
++
++int main(int argc, char **argv)
++{
++ signal(SIGINT, sig_handler);
++
++//! [Interesting]
++ cout << "Initializing test-application..." << endl;
++
++ // Instantiate an HDC1000 instance on bus 1
++ upm::HDC1000 *mySensor = new upm::HDC1000(1);
++
++ // update and print available values every second
++ while (run)
++ {
++ cout << "Humidity: " << mySensor->getHumidity(true) << endl
++ << "Temperature: " << mySensor->getTemperature(true) << endl;
++
++ cout << endl;
++
++ sleep(1);
++ }
++
++ cout << "Exiting test-application..." << endl;
++
++ delete mySensor;
++//! [Interesting]
++
++ return 0;
++}
+\ No newline at end of file
+diff --git a/examples/c++/mag3110.cxx b/examples/c++/mag3110.cxx
+new file mode 100644
+index 0000000..096d33d
+--- /dev/null
++++ b/examples/c++/mag3110.cxx
+@@ -0,0 +1,76 @@
++/* Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <unistd.h>
++#include <iostream>
++#include <signal.h>
++
++#include "mag3110.hpp"
++
++using namespace upm;
++
++bool run = true;
++
++void sig_handler(int sig)
++{
++ if (sig == SIGINT)
++ run = false;
++}
++
++int main(int argc, char **argv)
++{
++ signal(SIGINT, sig_handler);
++
++//! [Interesting]
++ upm::mag3110_data_t data;
++
++ cout << "Initializing test-application..." << endl;
++
++ // Instantiate an MAG3110 instance on bus 1
++ upm::MAG3110 *mySensor = new upm::MAG3110(1);
++
++ // activate periodic measurements
++ mySensor->setActive();
++
++ // update and print available values every second
++ while (run)
++ {
++ mySensor->getData (&data, true);
++ cout << "x: " << data.x << endl
++ << "y: " << data.y << endl
++ << "z: " << data.z << endl
++ << "Status: " << data.status << endl
++ << "Die temperature: " << data.dtemp << endl;
++
++ cout << endl;
++
++ sleep(1);
++ }
++
++ cout << "Exiting test-application..." << endl;
++
++ delete mySensor;
++//! [Interesting]
++
++ return 0;
++}
+\ No newline at end of file
+diff --git a/examples/c++/mma8x5x.cxx b/examples/c++/mma8x5x.cxx
+new file mode 100644
+index 0000000..16c5557
+--- /dev/null
++++ b/examples/c++/mma8x5x.cxx
+@@ -0,0 +1,91 @@
++/* Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <unistd.h>
++#include <iostream>
++#include <signal.h>
++
++#include "mma8x5x.hpp"
++
++using namespace upm;
++
++bool run = true;
++
++void sig_handler(int sig)
++{
++ if (sig == SIGINT)
++ run = false;
++}
++
++int main(int argc, char **argv)
++{
++ signal(SIGINT, sig_handler);
++
++//! [Interesting]
++ upm::mma8x5x_data_t data;
++
++ // U can set your own parameters for an MMA8X5X instance with
++ /*
++ upm::mma8x5x_params_t params;
++ params.type = <device-id>; device-id of your sensor
++ params.rate = <sampling-rate>; between 0<<3 and 7<<3
++ params.range = <range>; between 0 and 2
++ params.offsetX = <x-axis offset>; between 0 and 255
++ params.offsetY = <y-axis offset>; between 0 and 255
++ params.offsetZ = <z-axis offset>; between 0 and 255
++ */
++
++ cout << "Initializing test-application..." << endl;
++
++ // Instantiate an MMA8X5X instance on bus 1 with default parameters
++ // The sensor-type will be detected by reading out the device-id
++ upm::MMA8X5X *mySensor = new upm::MMA8X5X(1);
++
++ // If u have set own parameters use this one
++ /*
++ upm::MMA8X5X *mySensor = new upm::MMA8X5X(1, &params);
++ */
++
++ // activate periodic measurements
++ mySensor->setActive();
++
++ // update and print available values every second
++ while (run)
++ {
++ mySensor->getData (&data, true);
++ cout << "x: " << (int)data.x << endl
++ << "y: " << (int)data.y << endl
++ << "z: " << (int)data.z << endl;
++
++ cout << endl;
++
++ sleep(1);
++ }
++
++ cout << "Exiting test-application..." << endl;
++
++ delete mySensor;
++//! [Interesting]
++
++ return 0;
++}
+\ No newline at end of file
+diff --git a/examples/c++/tcs37727.cxx b/examples/c++/tcs37727.cxx
+new file mode 100644
+index 0000000..293bcea
+--- /dev/null
++++ b/examples/c++/tcs37727.cxx
+@@ -0,0 +1,77 @@
++/* Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <unistd.h>
++#include <iostream>
++#include <signal.h>
++
++#include "tcs37727.hpp"
++
++using namespace upm;
++
++bool run = true;
++
++void sig_handler(int sig)
++{
++ if (sig == SIGINT)
++ run = false;
++}
++
++int main(int argc, char **argv)
++{
++ signal(SIGINT, sig_handler);
++
++//! [Interesting]
++ upm::tcs37727_data_t data;
++
++ cout << "Initializing test-application..." << endl;
++
++ // Instantiate an TCS37727 instance on bus 1
++ upm::TCS37727 *mySensor = new upm::TCS37727(1);
++
++ // activate periodic measurements
++ mySensor->setActive();
++
++ // update and print available values every second
++ while (run)
++ {
++ mySensor->getData (&data, true);
++ cout << "Red: " << (int)data.red << endl
++ << "Green: " << (int)data.green << endl
++ << "Blue: " << (int)data.blue << endl
++ << "Clear: " << (int)data.clear << endl
++ << "Lux: " << (int)data.lux << endl
++ << "Color temperature: " << (int)data.ct << endl;
++
++ cout << endl;
++
++ sleep(1);
++ }
++
++ cout << "Exiting test-application..." << endl;
++
++ delete mySensor;
++//! [Interesting]
++
++ return 0;
++}
+diff --git a/examples/c++/tmp006.cxx b/examples/c++/tmp006.cxx
+new file mode 100644
+index 0000000..fda1dd7
+--- /dev/null
++++ b/examples/c++/tmp006.cxx
+@@ -0,0 +1,69 @@
++/* Author: Norbert Wesp <nwesp@phytec.de>
++ * Copyright (c) 2017 Phytec Messtechnik GmbH.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * "Software"), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#include <unistd.h>
++#include <iostream>
++#include <signal.h>
++
++#include "tmp006.hpp"
++
++using namespace upm;
++
++bool run = true;
++
++void sig_handler(int sig)
++{
++ if (sig == SIGINT)
++ run = false;
++}
++
++int main(int argc, char **argv)
++{
++ signal(SIGINT, sig_handler);
++
++//! [Interesting]
++ cout << "Initializing test-application..." << endl;
++
++ // Instantiate an TMP006 instance on bus 1
++ upm::TMP006 *mySensor = new upm::TMP006(1);
++
++ // activate periodic measurements
++ mySensor->setActive();
++
++ // update and print available values every second
++ while (run)
++ {
++ // Print out temperature value in °C
++ cout << "Temperature: " << mySensor->getTemperature(true) << " °C"
++ << endl;
++
++ sleep(1);
++ }
++
++ cout << "Exiting test-application..." << endl;
++
++ delete mySensor;
++//! [Interesting]
++
++ return 0;
++}
+diff --git a/examples/python/hdc1000.py b/examples/python/hdc1000.py
+new file mode 100644
+index 0000000..9ab3b5b
+--- /dev/null
++++ b/examples/python/hdc1000.py
+@@ -0,0 +1,57 @@
++#!/usr/bin/python
++# Author: Norbert Wesp <nwesp@phytec.de>
++# Copyright (c) 2017 Phytec Messtechnik GmbH.
++#
++# based on: tcs3414cs.py
++#
++# Permission is hereby granted, free of charge, to any person obtaining
++# a copy of this software and associated documentation files (the
++# "Software"), to deal in the Software without restriction, including
++# without limitation the rights to use, copy, modify, merge, publish,
++# distribute, sublicense, and/or sell copies of the Software, and to
++# permit persons to whom the Software is furnished to do so, subject to
++# the following conditions:
++#
++# The above copyright notice and this permission notice shall be
++# included in all copies or substantial portions of the Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++from __future__ import print_function
++import time, sys, signal, atexit
++from upm import pyupm_hdc1000 as HDC1000
++
++def main():
++ # Instantiate the Temperature and Humidity Sensor on I2C on bus 1
++ mySensor = HDC1000.HDC1000(1)
++
++ ## Exit handlers ##
++ # This stops python from printing a stacktrace when you hit control-C
++ def SIGINTHandler(signum, frame):
++ raise SystemExit
++
++ # This lets you run code on exit,
++ # including functions from mySensor
++ def exitHandler():
++ print("Exiting")
++ sys.exit(0)
++
++ # Register exit handlers
++ atexit.register(exitHandler)
++ signal.signal(signal.SIGINT, SIGINTHandler)
++
++ # Print out the humidity and temperature value every 0.5 seconds
++ while(1):
++ mySensor.getHumidity(True)
++ mySensor.getTemperature(True)
++
++ time.sleep(.5)
++
++if __name__ == '__main__':
++ main()
+diff --git a/examples/python/mag3110.py b/examples/python/mag3110.py
+new file mode 100644
+index 0000000..8e64d4b
+--- /dev/null
++++ b/examples/python/mag3110.py
+@@ -0,0 +1,62 @@
++#!/usr/bin/python
++# Author: Norbert Wesp <nwesp@phytec.de>
++# Copyright (c) 2017 Phytec Messtechnik GmbH.
++#
++# based on: tcs3414cs.py
++#
++# Permission is hereby granted, free of charge, to any person obtaining
++# a copy of this software and associated documentation files (the
++# "Software"), to deal in the Software without restriction, including
++# without limitation the rights to use, copy, modify, merge, publish,
++# distribute, sublicense, and/or sell copies of the Software, and to
++# permit persons to whom the Software is furnished to do so, subject to
++# the following conditions:
++#
++# The above copyright notice and this permission notice shall be
++# included in all copies or substantial portions of the Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++from __future__ import print_function
++import time, sys, signal, atexit
++from upm import pyupm_mag3110 as MAG3110
++
++def main():
++ # Instantiate the Three-Axis Digital Magnetometer Sensor on I2C on bus 1
++ mySensor = MAG3110.MAG3110(1)
++
++ ## Exit handlers ##
++ # This stops python from printing a stacktrace when you hit control-C
++ def SIGINTHandler(signum, frame):
++ raise SystemExit
++
++ # This lets you run code on exit,
++ # including functions from mySensor
++ def exitHandler():
++ print("Exiting")
++ sys.exit(0)
++
++ # Register exit handlers
++ atexit.register(exitHandler)
++ signal.signal(signal.SIGINT, SIGINTHandler)
++
++ data = MAG3110.mag3110_data_t()
++
++ # activate periodic measurements
++ mySensor.setActive();
++
++ # Print out the x, y, z, status and die temperature value every 0.5 seconds
++ while(1):
++ mySensor.getData(data, True)
++ print(data.x, data.y, data.z, hex(data.status), data.dtemp)
++
++ time.sleep(.5)
++
++if __name__ == '__main__':
++ main()
+diff --git a/examples/python/mma8x5x.py b/examples/python/mma8x5x.py
+new file mode 100644
+index 0000000..51bb962
+--- /dev/null
++++ b/examples/python/mma8x5x.py
+@@ -0,0 +1,62 @@
++#!/usr/bin/python
++# Author: Norbert Wesp <nwesp@phytec.de>
++# Copyright (c) 2017 Phytec Messtechnik GmbH.
++#
++# based on: tcs3414cs.py
++#
++# Permission is hereby granted, free of charge, to any person obtaining
++# a copy of this software and associated documentation files (the
++# "Software"), to deal in the Software without restriction, including
++# without limitation the rights to use, copy, modify, merge, publish,
++# distribute, sublicense, and/or sell copies of the Software, and to
++# permit persons to whom the Software is furnished to do so, subject to
++# the following conditions:
++#
++# The above copyright notice and this permission notice shall be
++# included in all copies or substantial portions of the Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++from __future__ import print_function
++import time, sys, signal, atexit
++from upm import pyupm_mma8x5x as MMA8X5X
++
++def main():
++ # Instantiate the Three-Axis Accelerometer Sensor on I2C on bus 1
++ mySensor = MMA8X5X.MMA8X5X(1)
++
++ ## Exit handlers ##
++ # This stops python from printing a stacktrace when you hit control-C
++ def SIGINTHandler(signum, frame):
++ raise SystemExit
++
++ # This lets you run code on exit,
++ # including functions from mySensor
++ def exitHandler():
++ print("Exiting")
++ sys.exit(0)
++
++ # Register exit handlers
++ atexit.register(exitHandler)
++ signal.signal(signal.SIGINT, SIGINTHandler)
++
++ data = MMA8X5X.mma8x5x_data_t()
++
++ # activate periodic measurements
++ mySensor.setActive();
++
++ # Print out the x, y, z value every 0.5 seconds
++ while(1):
++ mySensor.getData(data, True)
++ print(data.x, data.y, data.z)
++
++ time.sleep(.5)
++
++if __name__ == '__main__':
++ main()
+diff --git a/examples/python/tcs37727.py b/examples/python/tcs37727.py
+new file mode 100644
+index 0000000..f9a881d
+--- /dev/null
++++ b/examples/python/tcs37727.py
+@@ -0,0 +1,63 @@
++#!/usr/bin/python
++# Author: Norbert Wesp <nwesp@phytec.de>
++# Copyright (c) 2017 Phytec Messtechnik GmbH.
++#
++# based on: tcs3414cs.py
++#
++# Permission is hereby granted, free of charge, to any person obtaining
++# a copy of this software and associated documentation files (the
++# "Software"), to deal in the Software without restriction, including
++# without limitation the rights to use, copy, modify, merge, publish,
++# distribute, sublicense, and/or sell copies of the Software, and to
++# permit persons to whom the Software is furnished to do so, subject to
++# the following conditions:
++#
++# The above copyright notice and this permission notice shall be
++# included in all copies or substantial portions of the Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++from __future__ import print_function
++import time, sys, signal, atexit
++from upm import pyupm_tcs37727 as TCS37727
++
++def main():
++ # Instantiate the color sensor on I2C on bus 1
++ mySensor = TCS37727.TCS37727(1)
++
++ ## Exit handlers ##
++ # This stops python from printing a stacktrace when you hit control-C
++ def SIGINTHandler(signum, frame):
++ raise SystemExit
++
++ # This lets you run code on exit,
++ # including functions from mySensor
++ def exitHandler():
++ print("Exiting")
++ sys.exit(0)
++
++ # Register exit handlers
++ atexit.register(exitHandler)
++ signal.signal(signal.SIGINT, SIGINTHandler)
++
++ data = TCS37727.tcs37727_data_t()
++
++ # activate periodic measurements
++ mySensor.setActive();
++
++ # Print out the red, green, blue, clear, lux and color-temperature value
++ # every 0.5 seconds
++ while(1):
++ mySensor.getData(data, True)
++ print(data.red, data.green, data.blue, data.clear, data.lux, data.ct)
++
++ time.sleep(.5)
++
++if __name__ == '__main__':
++ main()
+diff --git a/examples/python/tmp006.py b/examples/python/tmp006.py
+new file mode 100644
+index 0000000..d75e54a
+--- /dev/null
++++ b/examples/python/tmp006.py
+@@ -0,0 +1,60 @@
++#!/usr/bin/python
++# Author: Norbert Wesp <nwesp@phytec.de>
++# Copyright (c) 2017 Phytec Messtechnik GmbH.
++#
++# based on: tcs3414cs.py
++#
++# Permission is hereby granted, free of charge, to any person obtaining
++# a copy of this software and associated documentation files (the
++# "Software"), to deal in the Software without restriction, including
++# without limitation the rights to use, copy, modify, merge, publish,
++# distribute, sublicense, and/or sell copies of the Software, and to
++# permit persons to whom the Software is furnished to do so, subject to
++# the following conditions:
++#
++# The above copyright notice and this permission notice shall be
++# included in all copies or substantial portions of the Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++from __future__ import print_function
++import time, sys, signal, atexit
++from upm import pyupm_tmp006 as TMP006
++
++def main():
++ # Instantiate the Infrared-Thermopile Sensor on I2C on bus 1
++ mySensor = TMP006.TMP006(1)
++
++ ## Exit handlers ##
++ # This stops python from printing a stacktrace when you hit control-C
++ def SIGINTHandler(signum, frame):
++ raise SystemExit
++
++ # This lets you run code on exit,
++ # including functions from mySensor
++ def exitHandler():
++ print("Exiting")
++ sys.exit(0)
++
++ # Register exit handlers
++ atexit.register(exitHandler)
++ signal.signal(signal.SIGINT, SIGINTHandler)
++
++ # activate periodic measurements
++ mySensor.setActive();
++
++ # Print out temperature value and config-reg in hex every 0.5 seconds
++ while(1):
++ mySensor.getTemperature(True)
++ hex(mySensor.getConfig())
++
++ time.sleep(.5)
++
++if __name__ == '__main__':
++ main()
+--
+1.9.1
+
diff --git a/recipes-devtools/upm/upm_1.1.0.bb b/recipes-devtools/upm/upm_1.1.0.bb
new file mode 100644
index 0000000..f43ed38
--- /dev/null
+++ b/recipes-devtools/upm/upm_1.1.0.bb
@@ -0,0 +1,100 @@
+SUMMARY = "Sensor/Actuator repository for Mraa"
+SECTION = "libs"
+AUTHOR = "Brendan Le Foll, Tom Ingleby, Yevgeniy Kiveisha"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=66493d54e65bfc12c7983ff2e884f37f"
+
+DEPENDS = "libjpeg-turbo mraa"
+
+SRC_URI = "https://github.com/intel-iot-devkit/upm/archive/v${PV}.tar.gz"
+SRC_URI += "\
+ file://0001-FindNodejs.cmake-parse-V8_MAJOR_VERSION-from-nodejs-.patch \
+ file://0001-tcs37727-Added-upm-support-for-color-sensor-TCS37727.patch \
+ file://0002-hdc1000-Added-upm-support-for-sensor-HDC1000.patch \
+ file://0003-mag3110-Added-upm-support-for-sensor-MAG3110.patch \
+ file://0004-tmp006-Added-upm-support-for-sensor-TMP006.patch \
+ file://0005-mma8x5x-Added-upm-support-for-some-MMA8X5X-sensors.patch \
+ file://0006-examples-Added-some-examples-for-added-sensors.patch \
+"
+
+SRC_URI[md5sum] = "a5d64c79346220e68c62a42607cb20f9"
+SRC_URI[sha256sum] = "81d53b754c261075e7b58502bcfba6bd92a94399c9eece0ddd11a85d74356877"
+
+inherit distutils-base pkgconfig python-dir cmake
+
+CFLAGS_append_edison = " -msse3 -mfpmath=sse"
+
+FILES_${PN}-doc += " ${datadir}/upm/examples/"
+RDEPENDS_${PN} += " mraa"
+
+# override this in local.conf to get a subset of bindings.
+# BINDINGS_pn-upm="python"
+# will result in only the python bindings being built/packaged.
+
+BINDINGS ?= "python nodejs"
+
+PACKAGECONFIG ??= "${@bb.utils.contains('PACKAGES', 'node-${PN}', 'nodejs', '', d)} \
+ ${@bb.utils.contains('PACKAGES', 'python-${PN}', 'python', '', d)} \
+ ${@bb.utils.contains('PACKAGES', '${PN}-java', 'java', '', d)}"
+
+PACKAGECONFIG[python] = "-DBUILDSWIGPYTHON=ON, -DBUILDSWIGPYTHON=OFF, swig-native ${PYTHON_PN},"
+PACKAGECONFIG[nodejs] = "-DBUILDSWIGNODE=ON, -DBUILDSWIGNODE=OFF, swig-native nodejs,"
+PACKAGECONFIG[java] = "-DBUILDSWIGJAVA=ON, -DBUILDSWIGJAVA=OFF, swig-native openjdk-8-native,"
+
+
+### Python ###
+
+# Python dependency in PYTHON_PN (from poky/meta/classes/python-dir.bbclass)
+# Possible values for PYTHON_PN: "python" or "python3"
+
+# python-upm package containing Python bindings
+FILES_${PYTHON_PN}-${PN} = "${PYTHON_SITEPACKAGES_DIR} \
+ ${datadir}/${BPN}/examples/python/ \
+ ${prefix}/src/debug/${BPN}/${PV}-${PR}/build/src/*/pyupm_* \
+ "
+RDEPENDS_${PYTHON_PN}-${PN} += "${PYTHON_PN} mraa"
+INSANE_SKIP_${PYTHON_PN}-${PN} = "debug-files"
+
+
+### Node ###
+
+# node-upm package containing Nodejs bindings
+FILES_node-${PN} = "${prefix}/lib/node_modules/ \
+ ${datadir}/${BPN}/examples/javascript/ \
+ "
+RDEPENDS_node-${PN} += "nodejs mraa"
+INSANE_SKIP_node-${PN} = "debug-files"
+
+
+### Java ###
+
+# upm-java package containing Java bindings
+FILES_${PN}-java = "${libdir}/libjava*.so \
+ ${libdir}/java/ \
+ ${datadir}/${BPN}/examples/java/ \
+ ${prefix}/src/debug/${BPN}/${PV}-${PR}/build/src/*/*javaupm_* \
+ ${libdir}/.debug/libjava*.so \
+ "
+
+RDEPENDS_${PN}-java += "${@bb.utils.contains('PACKAGES', '${PN}-java', 'java2-runtime mraa-java', '', d)}"
+INSANE_SKIP_${PN}-java = "debug-files"
+
+export JAVA_HOME="${STAGING_DIR}/${BUILD_SYS}/usr/lib/jvm/openjdk-8-native"
+
+cmake_do_generate_toolchain_file_append() {
+ echo "
+set (JAVA_AWT_INCLUDE_PATH ${JAVA_HOME}/include CACHE PATH \"AWT include path\" FORCE)
+set (JAVA_AWT_LIBRARY ${JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH \"AWT Library\" FORCE)
+set (JAVA_INCLUDE_PATH ${JAVA_HOME}/include CACHE PATH \"java include path\" FORCE)
+set (JAVA_INCLUDE_PATH2 ${JAVA_HOME}/include/linux CACHE PATH \"java include path\" FORCE)
+set (JAVA_JVM_LIBRARY ${JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH \"path to JVM\" FORCE)
+" >> ${WORKDIR}/toolchain.cmake
+}
+
+
+
+### Include desired language bindings ###
+PACKAGES =+ "${@bb.utils.contains('BINDINGS', 'java', '${PN}-java', '', d)}"
+PACKAGES =+ "${@bb.utils.contains('BINDINGS', 'nodejs', 'node-${PN}', '', d)}"
+PACKAGES =+ "${@bb.utils.contains('BINDINGS', 'python', 'python-${PN}', '', d)}"