summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Habibulla <moch@google.com>2016-07-15 20:44:53 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-07-15 20:44:53 +0000
commit9d97430478e42f35a5e00e00766c0c8279cf03dc (patch)
tree4464a7ea06d1f2d81ddaa4015ad17788bc6a76ef
parent94b0add192f544ef43d3a9b1c3e7f223dd8f35fd (diff)
parent2038aa86daa4ec99b3f199e670a95400a82eb2e0 (diff)
downloadintel-9d97430478e42f35a5e00e00766c0c8279cf03dc.tar.gz
Merge \"Revert \"libmraa: sync with upstream (SHA1: d336e9f)\"\"
am: 2038aa86da Change-Id: I712f2d819b81372dba7e8abf0fd3054666f4e3e5
-rw-r--r--peripheral/libmraa/.travis.yml40
-rw-r--r--peripheral/libmraa/Android.mk4
-rw-r--r--peripheral/libmraa/CMakeLists.txt53
-rw-r--r--peripheral/libmraa/README.md12
-rw-r--r--peripheral/libmraa/api/mraa.h1
-rw-r--r--peripheral/libmraa/api/mraa/aio.h11
-rw-r--r--peripheral/libmraa/api/mraa/aio.hpp31
-rw-r--r--peripheral/libmraa/api/mraa/common.h38
-rw-r--r--peripheral/libmraa/api/mraa/common.hpp49
-rw-r--r--peripheral/libmraa/api/mraa/firmata.h101
-rw-r--r--peripheral/libmraa/api/mraa/gpio.h30
-rw-r--r--peripheral/libmraa/api/mraa/gpio.hpp27
-rw-r--r--peripheral/libmraa/api/mraa/i2c.h28
-rw-r--r--peripheral/libmraa/api/mraa/i2c.hpp35
-rw-r--r--peripheral/libmraa/api/mraa/iio.h2
-rw-r--r--peripheral/libmraa/api/mraa/pwm.h30
-rw-r--r--peripheral/libmraa/api/mraa/pwm.hpp65
-rw-r--r--peripheral/libmraa/api/mraa/spi.h4
-rw-r--r--peripheral/libmraa/api/mraa/spi.hpp22
-rw-r--r--peripheral/libmraa/api/mraa/types.h10
-rw-r--r--peripheral/libmraa/api/mraa/types.hpp15
-rw-r--r--peripheral/libmraa/api/mraa/uart.h9
-rw-r--r--peripheral/libmraa/api/mraa/uart.hpp32
-rw-r--r--peripheral/libmraa/api/mraa/uart_ow.h197
-rw-r--r--peripheral/libmraa/api/mraa/uart_ow.hpp277
-rw-r--r--peripheral/libmraa/cmake/modules/FindJSON-C.cmake21
-rw-r--r--peripheral/libmraa/cmake/modules/FindNodejs.cmake10
-rw-r--r--peripheral/libmraa/cmake/modules/FindUDEV.cmake21
-rw-r--r--peripheral/libmraa/cmake/modules/OpenCVDetectPython.cmake160
-rw-r--r--peripheral/libmraa/docs/banana_pi.md2
-rw-r--r--peripheral/libmraa/docs/building.md10
-rw-r--r--peripheral/libmraa/docs/changelog.md45
-rw-r--r--peripheral/libmraa/docs/edison.md4
-rw-r--r--peripheral/libmraa/docs/firmata.md37
-rw-r--r--peripheral/libmraa/docs/galileorevd.md2
-rw-r--r--peripheral/libmraa/docs/galileorevh.md14
-rw-r--r--peripheral/libmraa/docs/grossetete.md112
-rw-r--r--peripheral/libmraa/docs/imraa.md63
-rw-r--r--peripheral/libmraa/docs/index.java.md2
-rw-r--r--peripheral/libmraa/docs/index.md1
-rw-r--r--peripheral/libmraa/examples/CMakeLists.txt12
-rw-r--r--peripheral/libmraa/examples/c++/CMakeLists.txt5
-rw-r--r--peripheral/libmraa/examples/c++/UartOW.cpp82
-rw-r--r--peripheral/libmraa/examples/c++/initio.cpp68
-rw-r--r--peripheral/libmraa/examples/firmata_curie_imu.c92
-rw-r--r--peripheral/libmraa/examples/hellomraa.c2
-rw-r--r--peripheral/libmraa/examples/i2c_firmata.c64
-rw-r--r--peripheral/libmraa/examples/initio.c69
-rw-r--r--peripheral/libmraa/examples/java/BlinkIO.java2
-rw-r--r--peripheral/libmraa/examples/java/Isr.java38
-rw-r--r--peripheral/libmraa/examples/javascript/firmata.js29
-rw-r--r--peripheral/libmraa/examples/javascript/gpio-tool.js25
-rw-r--r--peripheral/libmraa/examples/javascript/initio.js48
-rw-r--r--peripheral/libmraa/examples/javascript/isr.js6
-rw-r--r--peripheral/libmraa/examples/mraa-gpio.c12
-rw-r--r--peripheral/libmraa/examples/python/firmata.py29
-rw-r--r--peripheral/libmraa/examples/python/hello_isr.py27
-rw-r--r--peripheral/libmraa/examples/python/initio.py48
-rw-r--r--peripheral/libmraa/examples/uart_ow.c92
-rw-r--r--peripheral/libmraa/imraa/CMakeLists.txt17
-rw-r--r--peripheral/libmraa/imraa/imraa.c527
-rw-r--r--peripheral/libmraa/imraa/imraa.conf12
-rw-r--r--peripheral/libmraa/imraa/imraa.service9
-rw-r--r--peripheral/libmraa/include/firmata/firmata.h114
-rw-r--r--peripheral/libmraa/include/firmata/firmata_mraa.h38
-rw-r--r--peripheral/libmraa/include/java/mraajni.h46
-rw-r--r--peripheral/libmraa/include/mraa_adv_func.h15
-rw-r--r--peripheral/libmraa/include/mraa_internal.h20
-rw-r--r--peripheral/libmraa/include/mraa_internal_types.h68
-rw-r--r--peripheral/libmraa/include/mraa_lang_func.h35
-rw-r--r--peripheral/libmraa/include/python/mraapy.h27
-rw-r--r--peripheral/libmraa/include/x86/intel_gt_tuchuck.h42
-rw-r--r--peripheral/libmraa/jsstub/Gruntfile.js17
-rw-r--r--peripheral/libmraa/jsstub/README.md51
-rw-r--r--peripheral/libmraa/jsstub/index.js223
-rw-r--r--peripheral/libmraa/jsstub/package.json34
-rw-r--r--peripheral/libmraa/jsstub/test/index.js32
-rw-r--r--peripheral/libmraa/jsstub/test/lightbulb.js32
-rw-r--r--peripheral/libmraa/src/CMakeLists.txt61
-rw-r--r--peripheral/libmraa/src/aio/aio.c97
-rw-r--r--peripheral/libmraa/src/arm/beaglebone.c14
-rw-r--r--peripheral/libmraa/src/arm/raspberry_pi.c2
-rw-r--r--peripheral/libmraa/src/firmata/CMakeLists.txt8
-rw-r--r--peripheral/libmraa/src/firmata/firmata.c361
-rw-r--r--peripheral/libmraa/src/firmata/firmata_mraa.c697
-rw-r--r--peripheral/libmraa/src/gpio/gpio.c304
-rw-r--r--peripheral/libmraa/src/i2c/i2c.c84
-rw-r--r--peripheral/libmraa/src/iio/iio.c30
-rw-r--r--peripheral/libmraa/src/java/CMakeLists.txt15
-rw-r--r--peripheral/libmraa/src/java/manifest.txt.in7
-rw-r--r--peripheral/libmraa/src/java/mraajava.i52
-rw-r--r--peripheral/libmraa/src/java/mraajni.c102
-rw-r--r--peripheral/libmraa/src/javascript/CMakeLists.txt54
-rw-r--r--peripheral/libmraa/src/javascript/binding.gyp.cmake47
-rw-r--r--peripheral/libmraa/src/javascript/doxygen2jsdoc_custom.json2
-rw-r--r--peripheral/libmraa/src/javascript/mraajs.i7
-rw-r--r--peripheral/libmraa/src/javascript/package.json.cmake2
-rw-r--r--peripheral/libmraa/src/mraa.c500
-rw-r--r--peripheral/libmraa/src/mraa.i13
-rw-r--r--peripheral/libmraa/src/mraa.pc.cmake2
-rw-r--r--peripheral/libmraa/src/pwm/pwm.c289
-rw-r--r--peripheral/libmraa/src/python/CMakeLists.txt55
-rw-r--r--peripheral/libmraa/src/python/docs/CMakeLists.txt (renamed from peripheral/libmraa/src/python/python2/docs/CMakeLists.txt)2
-rw-r--r--peripheral/libmraa/src/python/docs/conf.py.in (renamed from peripheral/libmraa/src/python/python2/docs/conf.py.in)2
-rw-r--r--peripheral/libmraa/src/python/docs/example.rst (renamed from peripheral/libmraa/src/python/python2/docs/example.rst)6
-rw-r--r--peripheral/libmraa/src/python/docs/index.rst (renamed from peripheral/libmraa/src/python/python2/docs/index.rst)0
-rw-r--r--peripheral/libmraa/src/python/docs/mraa.rst (renamed from peripheral/libmraa/src/python/python2/docs/mraa.rst)0
-rw-r--r--peripheral/libmraa/src/python/mraa.i (renamed from peripheral/libmraa/src/python/mraapython.i)21
-rw-r--r--peripheral/libmraa/src/python/mraapy.c91
-rw-r--r--peripheral/libmraa/src/python/python2/CMakeLists.txt39
-rw-r--r--peripheral/libmraa/src/python/python2/mraa2.i5
-rw-r--r--peripheral/libmraa/src/python/python3/CMakeLists.txt24
-rw-r--r--peripheral/libmraa/src/python/python3/mraa3.i3
-rw-r--r--peripheral/libmraa/src/spi/spi.c8
-rw-r--r--peripheral/libmraa/src/uart/uart.c113
-rw-r--r--peripheral/libmraa/src/uart_ow/CMakeLists.txt7
-rw-r--r--peripheral/libmraa/src/uart_ow/uart_ow.c519
-rw-r--r--peripheral/libmraa/src/usb/ftdi_ft4222.c46
-rw-r--r--peripheral/libmraa/src/x86/intel_edison_fab_c.c369
-rw-r--r--peripheral/libmraa/src/x86/intel_galileo_rev_d.c57
-rw-r--r--peripheral/libmraa/src/x86/intel_galileo_rev_g.c637
-rw-r--r--peripheral/libmraa/src/x86/intel_gt_tuchuck.c646
-rw-r--r--peripheral/libmraa/src/x86/intel_nuc5.c4
-rw-r--r--peripheral/libmraa/src/x86/up.c25
-rw-r--r--peripheral/libmraa/src/x86/x86.c9
-rw-r--r--peripheral/libmraa/tests/CMakeLists.txt17
-rwxr-xr-xperipheral/libmraa/tests/platform_checks.py2
127 files changed, 1254 insertions, 7939 deletions
diff --git a/peripheral/libmraa/.travis.yml b/peripheral/libmraa/.travis.yml
index 0a52084..2d22386 100644
--- a/peripheral/libmraa/.travis.yml
+++ b/peripheral/libmraa/.travis.yml
@@ -1,36 +1,32 @@
language: cpp
-sudo: false
env:
- - NODE010=true
- - NODE012=true
+ - CC=gcc CXX=gcc
+ - CC=clang CXX=clang++
- NODE4=true
- NODE5=true
-compiler:
- - clang
- - gcc
+ - NODE012=true
install:
- if [ "${NODE4}" ]; then export CC=gcc-4.8 CXX=g++-4.8; fi
+ - sudo add-apt-repository --yes ppa:kalakris/cmake
+ - sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
+ - sudo apt-get update -qq
+ - sudo apt-get install -y -qq swig3.0 python git cmake
+ - sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
+ - sudo update-java-alternatives -s java-8-oracle
before_script:
- # Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
- - if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
- - if [ "${NODE012}" ]; then nvm install 0.12; fi
- - if [ "${NODE4}" ]; then nvm install 4.1; fi
- - if [ "${NODE5}" ]; then nvm install 5; fi
- # Handle 0.10 NODE_ROOT_DIR differently than other versions
- - if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
- - wget http://prdownloads.sourceforge.net/swig/swig-3.0.10.tar.gz && tar xf swig-3.0.10.tar.gz && cd swig-3.0.10 && ./configure --prefix=/home/travis/ && make && make install && cd ..
+ - export NODE_ROOT_DIR="/home/travis/.nvm/v0.10.36/include"
+ - if [ "$CC" = "gcc" ]; then export BUILDJAVA=ON; else export BUILDJAVA=OFF; fi
+ - export JAVA_HOME=/usr/lib/jvm/java-8-oracle
+ - if [ "${NODE4}" ]; then nvm install 4.1; export CC=gcc-4.8; export CXX=g++-4.8; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`/include"; fi
+ - if [ "${NODE5}" ]; then nvm install 5; export CC=gcc-4.8; export CXX=g++-4.8; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`/include"; fi
+ - if [ "${NODE012}" ]; then nvm install 0.12; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`/include"; fi
script:
- - echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
- - mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DCMAKE_INSTALL_PREFIX:PATH=../install -DSWIG_EXECUTABLE=/home/travis/bin/swig -DSWIG_DIR:PATH=/home/travis/share/swig/3.0.10/ .. && make install && make test
+ - mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" .. && make && make test
addons:
apt:
sources:
+ - llvm-toolchain-precise-3.6
- ubuntu-toolchain-r-test
- - kalakris-cmake
packages:
+ - clang-3.6
- g++-4.8
- - cmake
- - python
- - python3
- - python3-dev
- - git
diff --git a/peripheral/libmraa/Android.mk b/peripheral/libmraa/Android.mk
index 79a9fb6..ccaa41d 100644
--- a/peripheral/libmraa/Android.mk
+++ b/peripheral/libmraa/Android.mk
@@ -27,7 +27,6 @@ LOCAL_SRC_FILES := \
src/spi/spi.c \
src/aio/aio.c \
src/uart/uart.c \
- src/uart_ow/uart_ow.c \
src/x86/x86.c \
src/iio/iio.c \
src/x86/intel_galileo_rev_d.c \
@@ -38,8 +37,7 @@ LOCAL_SRC_FILES := \
src/x86/intel_sofia_3gr.c \
src/x86/intel_minnow_byt_compatible.c \
src/x86/intel_cherryhills.c \
- src/x86/up.c \
- src/x86/intel_gt_tuchuck.c
+ src/x86/up.c
# glob.c pulled in from NetBSD project (BSD 3-clause License)
LOCAL_SRC_FILES += \
diff --git a/peripheral/libmraa/CMakeLists.txt b/peripheral/libmraa/CMakeLists.txt
index e4d40b9..ffd9e06 100644
--- a/peripheral/libmraa/CMakeLists.txt
+++ b/peripheral/libmraa/CMakeLists.txt
@@ -5,17 +5,11 @@ FIND_PACKAGE (Threads REQUIRED)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer ")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall ")
+set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
-# Set CMAKE_INSTALL_LIBDIR if not defined
+# Set CMAKE_LIB_INSTALL_DIR if not defined
include(GNUInstallDirs)
-# Older cmake might not pick CMAKE_INSTALL_LIBDIR right
-if (CMAKE_INSTALL_LIBDIR)
- set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
-else ()
- set (LIB_INSTALL_DIR "lib" CACHE PATH "Installation path for libraries")
-endif ()
-
# By default, build shared object libraries on linux
if (UNIX AND NOT APPLE)
if (NOT DEFINED BUILD_SHARED_LIBS)
@@ -31,11 +25,11 @@ include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
message (WARNING " - Install git to compile a production libmraa!")
- set (VERSION "v1.1.1-dirty")
+ set (VERSION "v0.9.6-dirty")
endif ()
-message (STATUS "INFO - libmraa Version ${VERSION}")
-message (STATUS "INFO - cmake Version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
+message (INFO " - libmraa Version ${VERSION}")
+message (INFO " - cmake Version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
#parse the version information into pieces.
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
@@ -69,19 +63,17 @@ option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDSWIGJAVA "Build Java API." OFF)
option (USBPLAT "Detection USB platform." OFF)
-option (FIRMATA "Add Firmata support to mraa." OFF)
-option (ONEWIRE "Add Onewire support to mraa." ON)
-option (IMRAA "Add Imraa support to mraa." OFF)
option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
+option (BUILDPYTHON3 "Use python3 for building/installing/testing" OFF)
option (ENABLEEXAMPLES "Disable building of examples" ON)
option (INSTALLGPIOTOOL "Install gpio tool" OFF)
option (INSTALLTOOLS "Install all tools" OFF)
option (BUILDARCH "Override architecture to build for - override" OFF)
option (BUILDTESTS "Override the addition of tests" ON)
-set (MRAAPLATFORMFORCE "ALL" CACHE STRING "Override platform to build for")
+set (MRAAPLATFORMFORCE "" CACHE STRING "ALL")
if (NOT BUILDSWIG)
set (BUILDSWIGPYTHON OFF)
@@ -92,10 +84,10 @@ endif()
if (NOT BUILDARCH)
include (TargetArch)
target_architecture (DETECTED_ARCH)
- message (STATUS "INFO - Target arch is ${DETECTED_ARCH}")
+ message( INFO " - Target arch is ${DETECTED_ARCH}")
else ()
set (DETECTED_ARCH ${BUILDARCH})
- message (STATUS "INFO - Override arch is ${DETECTED_ARCH}")
+ message( INFO " - Override arch is ${DETECTED_ARCH}")
endif()
if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
@@ -104,11 +96,16 @@ if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
elseif (DETECTED_ARCH MATCHES "arm.*")
set (ARMPLAT ON)
else ()
- message (FATAL_ERROR "Only x86 and arm platforms currently supported")
+ message(FATAL_ERROR "Only x86 and arm platforms currently supported")
endif()
if (BUILDSWIGPYTHON OR BUILDTESTS)
- include (cmake/modules/OpenCVDetectPython.cmake)
+ if (BUILDPYTHON3)
+ set (PYTHONBUILD_VERSION 3)
+ else ()
+ set (PYTHONBUILD_VERSION 2.7)
+ endif ()
+ find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
endif ()
if (BUILDDOC)
@@ -140,9 +137,9 @@ if (IPK)
set (TARGET_ARCH ${DETECTED_ARCH})
endif ()
endif ()
- message (STATUS "INFO - Package arch is ${TARGET_ARCH}")
+ message (INFO " - Package arch is ${TARGET_ARCH}")
- set(CPACK_GENERATOR "DEB")
+ set(CPACK_GENERATOR "DEB" "TGZ")
set(OPKG_ARCH ${TARGET_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
@@ -164,7 +161,7 @@ if (IPK)
endif()
if (RPM)
- message (STATUS "INFO - Enabled RPM packaging for ${DETECTED_ARCH}")
+ message (INFO " - Enabled RPM packaging for ${DETECTED_ARCH}")
set(CMAKE_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
@@ -192,11 +189,9 @@ if (ENABLEEXAMPLES)
add_subdirectory (examples)
endif ()
-if (IMRAA)
- add_subdirectory (imraa)
-endif ()
-
-if (BUILDTESTS AND PYTHON_DEFAULT_EXECUTABLE)
- enable_testing ()
- add_subdirectory (tests)
+if (BUILDTESTS)
+ if (${PYTHONINTERP_FOUND})
+ enable_testing ()
+ add_subdirectory (tests)
+ endif ()
endif ()
diff --git a/peripheral/libmraa/README.md b/peripheral/libmraa/README.md
index 4a2a182..c515997 100644
--- a/peripheral/libmraa/README.md
+++ b/peripheral/libmraa/README.md
@@ -1,13 +1,10 @@
-<p align="center">
- <img src="http://iotdk.intel.com/misc/logos/mraa.png" height="150px" width="auto" algt="Mraa Logo"/>
-</p>
libmraa - Low Level Skeleton Library for Communication on GNU/Linux platforms
==============
-Libmraa is a C/C++ library with bindings to Java, Python and JavaScript to
-interface with the IO on Galileo, Edison & other platforms, with a structured
-and sane API where port names/numbering matches the board that you are on. Use
-of libmraa does not tie you to specific hardware with board detection done at
+Libmraa is a C/C++ library with bindings to javascript & python to interface
+with the IO on Galileo, Edison & other platforms, with a structured and sane
+API where port names/numbering matches the board that you are on. Use of
+libmraa does not tie you to specific hardware with board detection done at
runtime you can create portable code that will work across the supported
platforms.
@@ -27,7 +24,6 @@ X86
* [Minnowboard Max](../master/docs/minnow_max.md)
* [NUC 5th generation](../master/docs/intel_nuc5.md)
* [UP](../master/docs/up.md)
-* [Intel Grosse Tete](../master/docs/grossetete.md)
ARM
---
diff --git a/peripheral/libmraa/api/mraa.h b/peripheral/libmraa/api/mraa.h
index 70fde77..b3b0d59 100644
--- a/peripheral/libmraa/api/mraa.h
+++ b/peripheral/libmraa/api/mraa.h
@@ -33,7 +33,6 @@ extern "C" {
#include "mraa/spi.h"
#include "mraa/i2c.h"
#include "mraa/uart.h"
-#include "mraa/uart_ow.h"
#ifdef __cplusplus
}
diff --git a/peripheral/libmraa/api/mraa/aio.h b/peripheral/libmraa/api/mraa/aio.h
index 23c0857..753c907 100644
--- a/peripheral/libmraa/api/mraa/aio.h
+++ b/peripheral/libmraa/api/mraa/aio.h
@@ -59,20 +59,19 @@ typedef struct _aio* mraa_aio_context;
mraa_aio_context mraa_aio_init(unsigned int pin);
/**
- * Read the input voltage. By default mraa will shift the raw value up or down
- * to a 10 bit value.
+ * Read the input voltage. By default mraa will shift
+ * the raw value up or down to a 10 bit value.
*
* @param dev The AIO context
- * @returns The current input voltage or -1 for error
+ * @returns The current input voltage.
*/
-int mraa_aio_read(mraa_aio_context dev);
+unsigned int mraa_aio_read(mraa_aio_context dev);
/**
* Read the input voltage and return it as a normalized float (0.0f-1.0f).
*
* @param dev The AIO context
- * @returns The current input voltage as a normalized float (0.0f-1.0f), error
- * will be signaled by -1.0f
+ * @returns The current input voltage as a normalized float (0.0f-1.0f)
*/
float mraa_aio_read_float(mraa_aio_context dev);
diff --git a/peripheral/libmraa/api/mraa/aio.hpp b/peripheral/libmraa/api/mraa/aio.hpp
index 38ea8bc..9b07854 100644
--- a/peripheral/libmraa/api/mraa/aio.hpp
+++ b/peripheral/libmraa/api/mraa/aio.hpp
@@ -47,7 +47,7 @@ class Aio
*
* @param pin channel number to read ADC inputs
*/
- Aio(int pin)
+ Aio(unsigned int pin)
{
m_aio = mraa_aio_init(pin);
if (m_aio == NULL) {
@@ -55,19 +55,6 @@ class Aio
}
}
/**
- * Aio Constructor, takes a pointer to the AIO context and initialises
- * the AIO class
- *
- * @param void * to an AIO context
- */
- Aio(void* aio_context)
- {
- m_aio = (mraa_aio_context) aio_context;
- if (m_aio == NULL) {
- throw std::invalid_argument("Invalid AIO context");
- }
- }
- /**
* Aio destructor
*/
~Aio()
@@ -78,32 +65,22 @@ class Aio
* Read a value from the AIO pin. By default mraa will shift
* the raw value up or down to a 10 bit value.
*
- * @throws std::invalid_argument in case of error
* @returns The current input voltage. By default, a 10bit value
*/
- unsigned int
+ int
read()
{
- int x = mraa_aio_read(m_aio);
- if (x == -1) {
- throw std::invalid_argument("Unknown error in Aio::read()");
- }
- return (unsigned int) x;
+ return mraa_aio_read(m_aio);
}
/**
* Read a value from the AIO pin and return it as a normalized float.
*
- * @throws std::invalid_argument in case of error
* @returns The current input voltage as a normalized float (0.0f-1.0f)
*/
float
readFloat()
{
- float x = mraa_aio_read_float(m_aio);
- if (x == -1.0f) {
- throw std::invalid_argument("Unknown error in Aio::readFloat()");
- }
- return x;
+ return mraa_aio_read_float(m_aio);
}
/**
* Set the bit value which mraa will shift the raw reading
diff --git a/peripheral/libmraa/api/mraa/common.h b/peripheral/libmraa/api/mraa/common.h
index c0467ba..0357f0c 100644
--- a/peripheral/libmraa/api/mraa/common.h
+++ b/peripheral/libmraa/api/mraa/common.h
@@ -64,7 +64,9 @@ typedef unsigned int mraa_boolean_t;
*
* Detects running platform and attempts to use included pinmap, this is run on
* module/library init/load but is handy to rerun to check board initialised
- * correctly. MRAA_SUCCESS inidicates correct initialisation.
+ * correctly. MRAA_SUCCESS inidicates correct (first time) initialisation
+ * whilst MRAA_ERROR_PLATFORM_ALREADY_INITIALISED indicates the board is
+ * already initialised correctly
*
* @return Result of operation
*/
@@ -159,7 +161,7 @@ const char* mraa_get_platform_version(int platform_offset);
* @param priority Value from typically 0 to 99
* @return The priority value set
*/
-int mraa_set_priority(const int priority);
+int mraa_set_priority(const unsigned int priority);
/** Get the version string of mraa autogenerated from git tag
*
@@ -214,7 +216,7 @@ int mraa_get_i2c_bus_count();
* @param i2c_bus the logical I2C bus number
* @return I2C adapter number in sysfs. Function will return -1 on failure
*/
-int mraa_get_i2c_bus_id(int i2c_bus);
+int mraa_get_i2c_bus_id(unsigned int i2c_bus);
/**
* Get specified platform pincount, board must be initialised.
@@ -274,37 +276,7 @@ int mraa_get_sub_platform_id(int pin_or_bus_index);
*/
int mraa_get_sub_platform_index(int pin_or_bus_id);
-/**
- * Add mraa subplatform
- *
- * @param subplatform type
- * @param uart device subplatform is on
- *
- * @return mraa_result_t indicating success
- */
-mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev);
-/**
- * Remove a mraa subplatform
- *
- * @param subplatform type
- *
- * @return mraa_result indicating success
- */
-mraa_result_t mraa_remove_subplatform(mraa_platform_t subplatformtype);
-
-/**
- * Create IO using a description in the format:
- * [io]-[pin]
- * [io]-[raw]-[pin]
- * [io]-[raw]-[id]-[pin]
- * [io]-[raw]-[path]
- *
- * @param IO description
- *
- * @return void* to IO context or NULL
- */
-void* mraa_init_io(const char* desc);
#ifdef __cplusplus
}
diff --git a/peripheral/libmraa/api/mraa/common.hpp b/peripheral/libmraa/api/mraa/common.hpp
index 29894d3..26f4a60 100644
--- a/peripheral/libmraa/api/mraa/common.hpp
+++ b/peripheral/libmraa/api/mraa/common.hpp
@@ -46,7 +46,9 @@ namespace mraa
*
* Detects running platform and attempts to use included pinmap, this is run on
* module/library init/load but is handy to rerun to check board initialised
- * correctly. mraa::SUCCESS inidicates correct initialisation.
+ * correctly. MRAA_SUCCESS inidicates correct (first time) initialisation
+ * whilst MRAA_ERROR_PLATFORM_ALREADY_INITIALISED indicates the board is
+ * already initialised correctly
*
* @return Result of operation
*/
@@ -78,7 +80,7 @@ getVersion()
* @return The priority value set
*/
inline int
-setPriority(const int priority)
+setPriority(const unsigned int priority)
{
return mraa_set_priority(priority);
}
@@ -195,7 +197,7 @@ getI2cBusCount()
* @return I2C adapter number in sysfs. Function will return -1 on failure
*/
inline int
-getI2cBusId(int i2c_bus)
+getI2cBusId(unsigned int i2c_bus)
{
return mraa_get_i2c_bus_id(i2c_bus);
}
@@ -258,7 +260,7 @@ isSubPlatformId(int pin_or_bus_id)
*
* @return int sub platform pin or bus number
*/
-inline int
+inline int
getSubPlatformId(int pin_or_bus_index)
{
return mraa_get_sub_platform_id(pin_or_bus_index);
@@ -288,43 +290,4 @@ getDefaultI2cBus(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
{
return mraa_get_default_i2c_bus(platform_offset);
}
-
-/**
- * Add mraa subplatform
- *
- * @param subplatformtype the type of subplatform to add
- * (e.g. MRAA_GENERIC_FIRMATA)
- * @param uart_dev subplatform device string (e.g. "/dev/ttyACM0")
- * @return Result of operation
- */
-inline Result
-addSubplatform(Platform subplatformtype, std::string uart_dev)
-{
- return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, uart_dev.c_str());
-}
-
-inline Result
-removeSubplatform(Platform subplatformtype)
-{
- return (Result) mraa_remove_subplatform((mraa_platform_t) subplatformtype);
-}
-
-/**
- * Create IO using a description in the format:
- * [io]-[pin]
- * [io]-[raw]-[pin]
- * [io]-[raw]-[id]-[pin]
- * [io]-[raw]-[path]
- *
- * @param IO description
- *
- * @return class T initialised using pointer to IO or NULL
- */
-template <class T>
-inline T*
-initIo(std::string desc)
-{
- return new T(mraa_init_io(desc.c_str()));
-}
-
}
diff --git a/peripheral/libmraa/api/mraa/firmata.h b/peripheral/libmraa/api/mraa/firmata.h
deleted file mode 100644
index ba8684e..0000000
--- a/peripheral/libmraa/api/mraa/firmata.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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
-
-/**
- * @file
- * @brief Firmata IO
- *
- * Firmata IO lets you SYSEX messages construct and ask for a callback on a
- * SYSEX messages. This is meant to provide a way to call custom firmata APIs
- * especially using the Custom firmata API
- *
- * @snippet firmata_curie_imu.c Interesting
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "common.h"
-
-/**
- * Opaque pointer definition to the internal struct _firmata. This context
- * refers to one firmata 'extension' letting you write/return SYSEX messages
- * directly
- */
-typedef struct _firmata* mraa_firmata_context;
-
-/**
- * Initialise firmata context on a feature. This feature is what will be
- * listened on if you request a response callback
- *
- * @param firmata feature
- * @return firmata context or NULL
- */
-mraa_firmata_context mraa_firmata_init(int feature);
-
-/**
- * Sends a custom SYSEX message to the firmata board.
- *
- * @param dev The Firmata context
- * @param msg The SYSEX message
- * @param length The length of the sysex message
- */
-mraa_result_t mraa_firmata_write_sysex(mraa_firmata_context dev, char* msg, int length);
-
-/**
- * Set a callback on 'feature'. This function is not thread safe and threads
- * calling it need to make sure they are the only thread calling this.
- *
- * @param dev The Firmata context
- * @param fptr Function pointer to function to be called when interrupt is
- * triggered, the returned buffer and length are the arguments.
- * @return Result of operation
- */
-mraa_result_t mraa_firmata_response(mraa_firmata_context dev, void (*fptr)(uint8_t*, int));
-
-/**
- * Stop getting events on feature. This is more efficient than mraa_firmata_close
- * as it can be re-enabled without adding a feature
- *
- * @param dev The Firmata context
- * @return Result of operation
- */
-mraa_result_t mraa_firmata_response_stop(mraa_firmata_context dev);
-
-/**
- * Free all firmata handle resources, this will leave an element in an array
- * internally that will be skipped, avoid closing many firmata contexts often
- * as there is a cost to doing this
- *
- * @param dev The Firmata context
- * @return Result of operation
- */
-mraa_result_t mraa_firmata_close(mraa_firmata_context dev);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/peripheral/libmraa/api/mraa/gpio.h b/peripheral/libmraa/api/mraa/gpio.h
index 32e1c6e..2287c0c 100644
--- a/peripheral/libmraa/api/mraa/gpio.h
+++ b/peripheral/libmraa/api/mraa/gpio.h
@@ -40,17 +40,21 @@
extern "C" {
#endif
-#include <stdio.h>
-#include <pthread.h>
-#include "common.h"
+#ifdef SWIGPYTHON
+#include <Python.h>
+#endif
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include <jni.h>
-extern "C" {
- void mraa_java_isr_callback(void *args);
-}
+extern JavaVM *globVM;
+extern void mraa_java_isr_callback(void *);
#endif
+#include <stdio.h>
+#include <pthread.h>
+
+#include "common.h"
+
/**
* Opaque pointer definition to the internal struct _gpio
*/
@@ -77,13 +81,13 @@ typedef enum {
} mraa_gpio_dir_t;
/**
- * Gpio Edge types for interrupts
+ * Gpio Edge types for interupts
*/
typedef enum {
MRAA_GPIO_EDGE_NONE = 0, /**< No interrupt on Gpio */
- MRAA_GPIO_EDGE_BOTH = 1, /**< Interrupt on rising & falling */
- MRAA_GPIO_EDGE_RISING = 2, /**< Interrupt on rising only */
- MRAA_GPIO_EDGE_FALLING = 3 /**< Interrupt on falling only */
+ MRAA_GPIO_EDGE_BOTH = 1, /**< Interupt on rising & falling */
+ MRAA_GPIO_EDGE_RISING = 2, /**< Interupt on rising only */
+ MRAA_GPIO_EDGE_FALLING = 3 /**< Interupt on falling only */
} mraa_gpio_edge_t;
/**
@@ -112,11 +116,11 @@ mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
/**
- * Set an interrupt on pin
+ * Set an interupt on pin
*
* @param dev The Gpio context
* @param edge The edge mode to set the gpio into
- * @param fptr Function pointer to function to be called when interrupt is
+ * @param fptr Function pointer to function to be called when interupt is
* triggered
* @param args Arguments passed to the interrupt handler (fptr)
* @return Result of operation
@@ -124,7 +128,7 @@ mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (*fptr)(void*), void* args);
/**
- * Stop the current interrupt watcher on this Gpio, and set the Gpio edge mode
+ * Stop the current interupt watcher on this Gpio, and set the Gpio edge mode
* to MRAA_GPIO_EDGE_NONE
*
* @param dev The Gpio context
diff --git a/peripheral/libmraa/api/mraa/gpio.hpp b/peripheral/libmraa/api/mraa/gpio.hpp
index e2d7ad5..98693ac 100644
--- a/peripheral/libmraa/api/mraa/gpio.hpp
+++ b/peripheral/libmraa/api/mraa/gpio.hpp
@@ -60,13 +60,13 @@ typedef enum {
} Dir;
/**
- * Gpio Edge types for interrupts
+ * Gpio Edge types for interupts
*/
typedef enum {
EDGE_NONE = 0, /**< No interrupt on Gpio */
- EDGE_BOTH = 1, /**< Interrupt on rising & falling */
- EDGE_RISING = 2, /**< Interrupt on rising only */
- EDGE_FALLING = 3 /**< Interrupt on falling only */
+ EDGE_BOTH = 1, /**< Interupt on rising & falling */
+ EDGE_RISING = 2, /**< Interupt on rising only */
+ EDGE_FALLING = 3 /**< Interupt on falling only */
} Edge;
/**
@@ -80,7 +80,7 @@ class Gpio
{
public:
/**
- * Instantiates a Gpio object
+ * Instanciates a Gpio object
*
* @param pin pin number to use
* @param owner (optional) Set pin owner, default behaviour is to 'own'
@@ -108,19 +108,6 @@ class Gpio
}
}
/**
- * Gpio Constructor, takes a pointer to the GPIO context and initialises
- * the GPIO class
- *
- * @param void * to GPIO context
- */
- Gpio(void* gpio_context)
- {
- m_gpio = (mraa_gpio_context) gpio_context;
- if (m_gpio == NULL) {
- throw std::invalid_argument("Invalid GPIO context");
- }
- }
- /**
* Gpio object destructor, this will only unexport the gpio if we where
* the owner
*/
@@ -199,7 +186,7 @@ class Gpio
* Sets a callback to be called when pin value changes
*
* @param mode The edge mode to set
- * @param fptr Function pointer to function to be called when interrupt is
+ * @param fptr Function pointer to function to be called when interupt is
* triggered
* @param args Arguments passed to the interrupt handler (fptr)
* @return Result of operation
@@ -211,7 +198,7 @@ class Gpio
}
/**
- * Exits callback - this call will not kill the isr thread immediately
+ * Exits callback - this call will not kill the isr thread immediatly
* but only when it is out of it's critical section
*
* @return Result of operation
diff --git a/peripheral/libmraa/api/mraa/i2c.h b/peripheral/libmraa/api/mraa/i2c.h
index 657a53d..d0dbde2 100644
--- a/peripheral/libmraa/api/mraa/i2c.h
+++ b/peripheral/libmraa/api/mraa/i2c.h
@@ -78,40 +78,42 @@ mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode);
/**
- * Simple bulk read from an i2c context
+ * Simple bulk read from an i2c context, this will always begin with the i2c
+ * offset 0x0
*
* @param dev The i2c context
* @param data pointer to the byte array to read data in to
* @param length max number of bytes to read
- * @return length of the read in bytes or -1
+ * @return length of the read in bytes or 0
*/
int mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length);
/**
- * Simple read for a single byte from the i2c context
+ * Simple read for a single byte from the i2c context, this will always begin
+ * with the i2c offset 0x0
*
* @param dev The i2c context
- * @return The result of the read or -1 if failed
+ * @return The result of the read and 0 if failed
*/
-int mraa_i2c_read_byte(mraa_i2c_context dev);
+uint8_t mraa_i2c_read_byte(mraa_i2c_context dev);
/**
* Read a single byte from i2c context, from designated register
*
* @param dev The i2c context
* @param command The register
- * @return The result of the read or -1 if failed
+ * @return The result of the read and 0 if failed
*/
-int mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command);
+uint8_t mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command);
/**
* Read a single word from i2c context, from designated register
*
* @param dev The i2c context
* @param command The register
- * @return The result of the read or -1 if failed
+ * @return The result of the read and 0 if failed
*/
-int mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command);
+uint16_t mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command);
/**
* Bulk read from i2c context, starting from designated register
@@ -136,7 +138,7 @@ int mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* dat
mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length);
/**
- * Write a single byte to an i2c context
+ * Write a single byte to an i2c context, always at offset 0x0
*
* @param dev The i2c context
* @param data The byte to write
@@ -165,10 +167,12 @@ mraa_result_t mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data,
mraa_result_t mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command);
/**
- * Sets the i2c slave address.
+ * Sets the i2c context address.
*
* @param dev The i2c context
- * @param address The address to set for the slave (7-bit address)
+ * @param address The address to set for the slave (ignoring the least
+ * signifcant bit). If set to 0, the slave will only respond to the
+ * general call address.
* @return Result of operation
*/
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, uint8_t address);
diff --git a/peripheral/libmraa/api/mraa/i2c.hpp b/peripheral/libmraa/api/mraa/i2c.hpp
index 52e2153..cd3c31c 100644
--- a/peripheral/libmraa/api/mraa/i2c.hpp
+++ b/peripheral/libmraa/api/mraa/i2c.hpp
@@ -62,18 +62,6 @@ class I2c
throw std::invalid_argument("Invalid i2c bus");
}
}
- /**
- * I2C constructor, takes a pointer to a I2C context and initialises the I2C class
- *
- * @param void * to an I2C context
- */
- I2c(void* i2c_context)
- {
- m_i2c = (mraa_i2c_context) i2c_context;
- if (m_i2c == NULL) {
- throw std::invalid_argument("Invalid I2C context");
- }
- }
/**
* Closes the I2c Bus used. This does not guarrantee the bus will not
@@ -115,17 +103,12 @@ class I2c
/**
* Read exactly one byte from the bus
*
- * @throws std::invalid_argument in case of error
* @return char read from the bus
*/
uint8_t
readByte()
{
- int x = mraa_i2c_read_byte(m_i2c);
- if (x == -1) {
- throw std::invalid_argument("Unknown error in I2c::readByte()");
- }
- return (uint8_t) x;
+ return (uint8_t) mraa_i2c_read_byte(m_i2c);
}
/**
@@ -145,36 +128,24 @@ class I2c
* Read byte from an i2c register
*
* @param reg Register to read from
- *
- * @throws std::invalid_argument in case of error
* @return char read from register
*/
uint8_t
readReg(uint8_t reg)
{
- int x = mraa_i2c_read_byte_data(m_i2c, reg);
- if (x == -1) {
- throw std::invalid_argument("Unknown error in I2c::readReg()");
- }
- return (uint8_t) x;
+ return mraa_i2c_read_byte_data(m_i2c, reg);
}
/**
* Read word from an i2c register
*
* @param reg Register to read from
- *
- * @throws std::invalid_argument in case of error
* @return char read from register
*/
uint16_t
readWordReg(uint8_t reg)
{
- int x = mraa_i2c_read_word_data(m_i2c, reg);
- if (x == -1) {
- throw std::invalid_argument("Unknown error in I2c::readReg()");
- }
- return (uint16_t) x;
+ return mraa_i2c_read_word_data(m_i2c, reg);
}
/**
diff --git a/peripheral/libmraa/api/mraa/iio.h b/peripheral/libmraa/api/mraa/iio.h
index a205a76..eadbab9 100644
--- a/peripheral/libmraa/api/mraa/iio.h
+++ b/peripheral/libmraa/api/mraa/iio.h
@@ -121,7 +121,7 @@ mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
int* channel2,
int* different);
-mraa_result_t mraa_iio_get_mount_matrix(mraa_iio_context dev, const char *sysfs_name, float mm[9]);
+mraa_result_t mraa_iio_get_mounting_matrix(mraa_iio_context dev, float mm[9]);
mraa_result_t mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger);
diff --git a/peripheral/libmraa/api/mraa/pwm.h b/peripheral/libmraa/api/mraa/pwm.h
index d6f17df..ef78110 100644
--- a/peripheral/libmraa/api/mraa/pwm.h
+++ b/peripheral/libmraa/api/mraa/pwm.h
@@ -65,7 +65,7 @@ mraa_pwm_context mraa_pwm_init(int pin);
mraa_pwm_context mraa_pwm_init_raw(int chipid, int pin);
/**
- * Set the output duty-cycle percentage, as a float
+ * Set the ouput duty-cycle percentage, as a float
*
* @param dev The Pwm context to use
* @param percentage A floating-point value representing percentage of output.
@@ -76,7 +76,7 @@ mraa_pwm_context mraa_pwm_init_raw(int chipid, int pin);
mraa_result_t mraa_pwm_write(mraa_pwm_context dev, float percentage);
/**
- * Read the output duty-cycle percentage, as a float
+ * Read the ouput duty-cycle percentage, as a float
*
* @param dev The Pwm context to use
* @return percentage A floating-point value representing percentage of output.
@@ -167,20 +167,38 @@ mraa_result_t mraa_pwm_owner(mraa_pwm_context dev, mraa_boolean_t owner);
mraa_result_t mraa_pwm_close(mraa_pwm_context dev);
/**
- * Get the maximum pwm period in us
+ * Set Both Period and DutyCycle on a PWM context
+ *
+ * @param dev The pwm context to use
+ * @param period represented in ms.
+ * @param duty dutycycle of the pwm signal.
+ * @return Result of operation
+ */
+mraa_result_t mraa_pwm_config_ms(mraa_pwm_context dev, int period, float duty);
+
+/**
+ * Set Both Period and DutyCycle on a PWM context. Duty represented as percentage.
*
* @param dev The pwm context to use
+ * @param period represented in ms.
+ * @param duty duty percantage. i.e. 50% = 0.5f
+ * @return Result of operation
+ */
+mraa_result_t mraa_pwm_config_percent(mraa_pwm_context dev, int period, float duty);
+
+/**
+ * Get the maximum pwm period in us
+ *
* @return max pwm in us
*/
-int mraa_pwm_get_max_period(mraa_pwm_context dev);
+int mraa_pwm_get_max_period();
/**
* Get the minimum pwm period in us
*
- * @param dev The pwm context to use
* @return min pwm in us
*/
-int mraa_pwm_get_min_period(mraa_pwm_context dev);
+int mraa_pwm_get_min_period();
#ifdef __cplusplus
}
diff --git a/peripheral/libmraa/api/mraa/pwm.hpp b/peripheral/libmraa/api/mraa/pwm.hpp
index c75255a..a449a43 100644
--- a/peripheral/libmraa/api/mraa/pwm.hpp
+++ b/peripheral/libmraa/api/mraa/pwm.hpp
@@ -46,9 +46,9 @@ class Pwm
*
* @param pin the pin number used on your board
* @param owner if you are the owner of the pin the destructor will
+ * @param chipid the pwmchip to use, use only in raw mode
* unexport the pin from sysfs, default behaviour is you are the owner
* if the pinmapper exported it
- * @param chipid the pwmchip to use, use only in raw mode
*/
Pwm(int pin, bool owner = true, int chipid = -1)
{
@@ -66,20 +66,6 @@ class Pwm
mraa_pwm_owner(m_pwm, 0);
}
}
-
- /**
- * Pwm constructor, takes a pointer to the PWM context and
- * initialises the class
- *
- * @param void * to a PWM context
- */
- Pwm(void* pwm_context)
- {
- m_pwm = (mraa_pwm_context) pwm_context;
- if (m_pwm == NULL) {
- throw std::invalid_argument("Invalid PWM context");
- }
- }
/**
* Pwm destructor
*/
@@ -91,7 +77,7 @@ class Pwm
* Set the output duty-cycle percentage, as a float
*
* @param percentage A floating-point value representing percentage of
- * output. The value should lie between 0.0f (representing 0%) and
+ * output. The value should lie between 0.0f (representing on 0%) and
* 1.0f Values above or below this range will be set at either 0.0f or
* 1.0f
* @return Result of operation
@@ -102,10 +88,10 @@ class Pwm
return (Result) mraa_pwm_write(m_pwm, percentage);
}
/**
- * Read the output duty-cycle percentage, as a float
+ * Read the ouput duty-cycle percentage, as a float
*
* @return A floating-point value representing percentage of
- * output. The value should lie between 0.0f (representing 0%) and
+ * output. The value should lie between 0.0f (representing on 0%) and
* 1.0f Values above or below this range will be set at either 0.0f or
* 1.0f
*/
@@ -148,7 +134,7 @@ class Pwm
return (Result) mraa_pwm_period_us(m_pwm, us);
}
/**
- * Set pulsewidth, as represented by seconds in a float
+ * Set pulsewidth, As represnted by seconds in a (float)
*
* @param seconds The duration of a pulse
* @return Result of operation
@@ -190,27 +176,54 @@ class Pwm
Result
enable(bool enable)
{
- return (Result) mraa_pwm_enable(m_pwm, enable);
+ if (enable)
+ return (Result) mraa_pwm_enable(m_pwm, 1);
+ else
+ return (Result) mraa_pwm_enable(m_pwm, 0);
+ }
+ /**
+ * Set the period and duty of a PWM object.
+ *
+ * @param period represented in ms.
+ * @param duty represnted in ms as float.
+ * @return Result of operation
+ */
+ Result
+ config_ms(int period, float duty)
+ {
+ return (Result) mraa_pwm_config_ms(m_pwm, period, duty);
+ }
+ /**
+ * Set the period and duty (percent) of a PWM object.
+ *
+ * @param period as represented in ms.
+ * @param duty percentage i.e. 50% = 0.5f
+ * @return Result of operation
+ */
+ Result
+ config_percent(int period, float duty)
+ {
+ return (Result) mraa_pwm_config_percent(m_pwm, period, duty);
}
/**
- * Get the maximum PWM period in us
+ * Get the maximum pwm period in us
*
- * @return max PWM period in us
+ * @return max pwm in us
*/
int
max_period()
{
- return mraa_pwm_get_max_period(m_pwm);
+ return mraa_pwm_get_max_period();
}
/**
- * Get the minimum PWM period in us
+ * Get the minimum pwm period in us
*
- * @return min PWM period in us
+ * @return min pwm in us
*/
int
min_period()
{
- return mraa_pwm_get_min_period(m_pwm);
+ return mraa_pwm_get_min_period();
}
private:
diff --git a/peripheral/libmraa/api/mraa/spi.h b/peripheral/libmraa/api/mraa/spi.h
index d53ec3a..6902a6e 100644
--- a/peripheral/libmraa/api/mraa/spi.h
+++ b/peripheral/libmraa/api/mraa/spi.h
@@ -111,13 +111,13 @@ mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
int mraa_spi_write(mraa_spi_context dev, uint8_t data);
/**
- * Write Two Bytes to the SPI device.
+ *Write Two Bytes to the SPI device.
*
* @param dev The Spi context
* @param data Data to send
* @return Data received on the miso line
*/
-int mraa_spi_write_word(mraa_spi_context dev, uint16_t data);
+uint16_t mraa_spi_write_word(mraa_spi_context dev, uint16_t data);
/**
* Write Buffer of bytes to the SPI device. The pointer return has to be
diff --git a/peripheral/libmraa/api/mraa/spi.hpp b/peripheral/libmraa/api/mraa/spi.hpp
index 94a3f64..e5ffb09 100644
--- a/peripheral/libmraa/api/mraa/spi.hpp
+++ b/peripheral/libmraa/api/mraa/spi.hpp
@@ -80,20 +80,6 @@ class Spi
}
/**
- * Spi Constructor, takes a pointer to a SPI context and initialises
- * the SPI class
- *
- * @param void * to SPI context
- */
- Spi(void* spi_context)
- {
- m_spi = (mraa_spi_context) spi_context;
- if (m_spi == NULL) {
- throw std::invalid_argument("Invalid SPI context");
- }
- }
-
- /**
* Closes spi bus
*/
~Spi()
@@ -141,10 +127,10 @@ class Spi
* Write single byte to the SPI device
*
* @param data the byte to send
- * @return data received on the miso line or -1 in case of error
+ * @return data received on the miso line
*/
- int
- writeWord(uint16_t data)
+ uint16_t
+ write_word(uint16_t data)
{
return mraa_spi_write_word(m_spi, (uint16_t) data);
}
@@ -175,7 +161,7 @@ class Spi
* @return uint8_t* data received on the miso line. Same length as passed in
*/
uint16_t*
- writeWord(uint16_t* txBuf, int length)
+ write_word(uint16_t* txBuf, int length)
{
return mraa_spi_write_buf_word(m_spi, txBuf, length);
}
diff --git a/peripheral/libmraa/api/mraa/types.h b/peripheral/libmraa/api/mraa/types.h
index 5c43dd4..fe0daad 100644
--- a/peripheral/libmraa/api/mraa/types.h
+++ b/peripheral/libmraa/api/mraa/types.h
@@ -50,14 +50,10 @@ typedef enum {
MRAA_INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
MRAA_UP = 12, /**< The UP Board */
- MRAA_INTEL_GT_TUCHUCK = 13, /**< The Intel GT Tuchuck Board */
// USB platform extenders start at 256
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
- // contains bit 9 so is subplatform
- MRAA_GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
-
MRAA_NULL_PLATFORM = 98, /**< Platform with no capabilities that hosts a sub platform */
MRAA_UNKNOWN_PLATFORM =
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
@@ -207,9 +203,7 @@ typedef enum {
MRAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
MRAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
MRAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
- MRAA_ERROR_UART_OW_SHORTED = 12, /**< UART OW Short Circuit Detected*/
- MRAA_ERROR_UART_OW_NO_DEVICES = 13, /**< UART OW No devices detected */
- MRAA_ERROR_UART_OW_DATA_ERROR = 14, /**< UART OW Data/Bus error detected */
+ MRAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
} mraa_result_t;
@@ -245,6 +239,8 @@ typedef enum {
MRAA_UART_PARITY_SPACE = 4
} mraa_uart_parity_t;
+
+
#ifdef __cplusplus
}
#endif
diff --git a/peripheral/libmraa/api/mraa/types.hpp b/peripheral/libmraa/api/mraa/types.hpp
index 4aa50a8..cc6f53a 100644
--- a/peripheral/libmraa/api/mraa/types.hpp
+++ b/peripheral/libmraa/api/mraa/types.hpp
@@ -46,18 +46,7 @@ typedef enum {
RASPBERRY_PI = 5, /**< The different Raspberry PI Models -like A,B,A+,B+ */
BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
- INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */
- A96BOARDS = 9, /**< Linaro 96boards, A prefix for 'ARM' since not allowed numerical */
- INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
- INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
- INTEL_UP = 12, /**< The UP Board */
- INTEL_GT_TUCHUCK = 13, /**< The Intel GT Board */
- FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
-
- GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
-
- NULL_PLATFORM = 98,
UNKNOWN_PLATFORM =
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
} Platform;
@@ -206,9 +195,7 @@ typedef enum {
ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
- ERROR_UART_OW_SHORTED = 12, /**< UART OW Short Circuit Detected*/
- ERROR_UART_OW_NO_DEVICES = 13, /**< UART OW No devices detected */
- ERROR_UART_OW_DATA_ERROR = 14, /**< UART OW Data/Bus error detected */
+ ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
ERROR_UNSPECIFIED = 99 /**< Unknown Error */
} Result;
diff --git a/peripheral/libmraa/api/mraa/uart.h b/peripheral/libmraa/api/mraa/uart.h
index c6f5a7a..3ca196f 100644
--- a/peripheral/libmraa/api/mraa/uart.h
+++ b/peripheral/libmraa/api/mraa/uart.h
@@ -119,15 +119,6 @@ mraa_result_t mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xo
mraa_result_t mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar);
/**
- * Set the blocking state for write operations
- *
- * @param dev The UART context
- * @param nonblock new nonblocking state
- * @return Result of operation
- */
-mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t nonblock);
-
-/**
* Get Char pointer with tty device path within Linux
* For example. Could point to "/dev/ttyS0"
*
diff --git a/peripheral/libmraa/api/mraa/uart.hpp b/peripheral/libmraa/api/mraa/uart.hpp
index 0771fdc..cc485a3 100644
--- a/peripheral/libmraa/api/mraa/uart.hpp
+++ b/peripheral/libmraa/api/mraa/uart.hpp
@@ -76,20 +76,6 @@ class Uart
}
/**
- * Uart Constructor, takes a pointer to the UART context and initialises
- * the UART class
- *
- * @param void * to a UART context
- */
- Uart(void* uart_context)
- {
- m_uart = (mraa_uart_context) uart_context;
-
- if (m_uart == NULL) {
- throw std::invalid_argument("Invalid UART context");
- }
- }
- /**
* Uart destructor
*/
~Uart()
@@ -140,17 +126,12 @@ class Uart
* Read bytes from the device into a String object
*
* @param length to read
- * @throws std::bad_alloc If there is no space left for read.
* @return string of data
*/
std::string
readStr(int length)
{
char* data = (char*) malloc(sizeof(char) * length);
- if (data == NULL) {
- throw std::bad_alloc();
- }
-
int v = mraa_uart_read(m_uart, data, (size_t) length);
std::string ret(data, v);
free(data);
@@ -255,19 +236,6 @@ class Uart
return (Result) mraa_uart_set_timeout(m_uart, read, write, interchar);
}
- /**
- * Set the blocking state for write operations
- *
- * @param dev The UART context
- * @param nonblock new nonblocking state
- * @return Result of operation
- */
- Result
- SetNonBlocking(bool nonblock)
- {
- return (Result) mraa_uart_set_non_blocking(m_uart, nonblock);
- }
-
private:
mraa_uart_context m_uart;
};
diff --git a/peripheral/libmraa/api/mraa/uart_ow.h b/peripheral/libmraa/api/mraa/uart_ow.h
deleted file mode 100644
index 7cd098f..0000000
--- a/peripheral/libmraa/api/mraa/uart_ow.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation
- *
- * 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
-
-/**
- * @file
- * @brief UART OW module
- *
- * This module allows one to use MRAA's UART support in order to
- * interact with Dallas 1-wire compliant devices on a 1-wire bus. It
- * makes use of the UART for timing purposes. The principle of
- * operation is described here:
- * https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
- *
- * It is important the you use a UART with CMOS/TTL level voltages
- * (3.3v/5v) RX and TX lines. DO NOT use standard RS232 level
- * voltages, or you are going to have a bad day.
- *
- * In addition, a diode should be placed across the RX and
- * TX lines like so:
- *
- * -|
- * U|
- * A| TX---|<--+
- * R| |
- * T| RX-------o--------o 1-wire data bus
- * -|
- *
- * The diode on TX is a 1N4148 (cheap and common), with the cathode
- * connected to TX, and the anode connected to RX and the rest of the
- * 1-wire data line.
- *
- * @snippet uart_ow.c Interesting
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-
-#include "common.h"
-#include "uart.h"
-
-/* for now, we simply use the normal MRAA UART context */
-typedef struct _mraa_uart_ow {
- mraa_uart_context uart;
- /* search state */
- unsigned char ROM_NO[8]; /* 8 byte (64b) rom code */
- int LastDiscrepancy;
- int LastFamilyDiscrepancy;
- mraa_boolean_t LastDeviceFlag;
-} *mraa_uart_ow_context;
-
-/* 8 bytes (64 bits) for a device rom code */
-static const int MRAA_UART_OW_ROMCODE_SIZE = 8;
-
-/**
- * UART One Wire ROM related Command bytes
- */
-typedef enum {
- MRAA_UART_OW_CMD_READ_ROM = 0x33, /**< read rom, when only one device on bus */
- MRAA_UART_OW_CMD_MATCH_ROM = 0x55, /**< match a specific rom code */
- MRAA_UART_OW_CMD_SKIP_ROM = 0xcc, /**< skip match/search rom */
- MRAA_UART_OW_CMD_SEARCH_ROM_ALARM = 0xec, /**< search all roms in alarm state */
- MRAA_UART_OW_CMD_SEARCH_ROM = 0xf0 /**< search all rom codes */
-} mraa_uart_ow_rom_cmd_t;
-
-/**
- * Initialise uart_ow_context, uses UART board mapping
- *
- * @param uart the index of the uart set to use
- * @return uart_ow context or NULL
- */
-mraa_uart_ow_context mraa_uart_ow_init(int uart);
-
-/**
- * Initialise a raw uart_ow_context. No board setup.
- *
- * @param path for example "/dev/ttyS0"
- * @return uart_ow context or NULL
- */
-mraa_uart_ow_context mraa_uart_ow_init_raw(const char* path);
-
-/**
- * Get char pointer with tty device path within Linux
- * For example. Could point to "/dev/ttyS0"
- *
- * @param dev uart_ow context
- * @return char pointer of device path
- */
-const char* mraa_uart_ow_get_dev_path(mraa_uart_ow_context dev);
-
-/**
- * Destroy a mraa_uart_ow_context
- *
- * @param dev uart_ow context
- * @return mraa_result_t
- */
-mraa_result_t mraa_uart_ow_stop(mraa_uart_ow_context dev);
-
-/**
- * Read a byte from the 1-wire bus
- *
- * @param dev uart_ow context
- * @return the byte read or -1 for error
- */
-int mraa_uart_ow_read_byte(mraa_uart_ow_context dev);
-
-/**
- * Write a byte to a 1-wire bus
- *
- * @param dev uart_ow context
- * @param byte the byte to write to the bus
- * @return the byte read back during the time slot or -1 for error
- */
-int mraa_uart_ow_write_byte(mraa_uart_ow_context dev, uint8_t byte);
-
-/**
- * Write a bit to a 1-wire bus and read a bit corresponding to the
- * time slot back. This is possible due to the way we wired the TX
- * and RX together with a diode, forming a loopback.
- *
- * @param dev uart_ow context
- * @param bit the bit to write to the bus
- * @return the bit read back during the time slot or -1 for error
- */
-int mraa_uart_ow_bit(mraa_uart_ow_context dev, uint8_t bit);
-
-/**
- * Send a reset pulse to the 1-wire bus and test for device presence
- *
- * @param dev uart_ow context
- * @return one of the mraa_result_t values
- */
-mraa_result_t mraa_uart_ow_reset(mraa_uart_ow_context dev);
-
-/**
- * Begin a rom code search of the 1-wire bus. This function
- * implements the 1-wire search algorithm. See the uart_ow.c example
- * for an idea on how to use this function to identify all devices
- * present on the bus.
- *
- * @param dev uart_ow context
- * @param start true to start a new search from scratch, false to
- * continue an existing search
- * @param id the 8-byte rom code id of the current matched device when
- * a device is found
- * @return one of the mraa_result_t values
- */
-mraa_result_t mraa_uart_ow_rom_search(mraa_uart_ow_context dev, mraa_boolean_t start, uint8_t* id);
-
-/**
- * Send a command byte to a device on the 1-wire bus
- *
- * @param dev uart_ow context
- * @param command the command byte to send
- * @param id the rom code id of the device to receive the command,
- * NULL for all devices on the bus
- * @return one of the mraa_result_t values
- */
-mraa_result_t mraa_uart_ow_command(mraa_uart_ow_context dev, uint8_t command, uint8_t* id);
-
-/**
- * Perform a Dallas 1-wire compliant CRC8 computation on a buffer
- *
- * @param buffer the buffer containing the data
- * @param length the length of the buffer
- * @return the computed CRC
- */
-uint8_t mraa_uart_ow_crc8(uint8_t* buffer, uint16_t length);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/peripheral/libmraa/api/mraa/uart_ow.hpp b/peripheral/libmraa/api/mraa/uart_ow.hpp
deleted file mode 100644
index d20f87e..0000000
--- a/peripheral/libmraa/api/mraa/uart_ow.hpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation
- *
- * 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 "uart_ow.h"
-#include "types.hpp"
-#include <stdexcept>
-#include <cstring>
-
-namespace mraa
-{
-
-/**
- * @brief API for UART One Wire
- *
- * This file defines the UartOW (UART to Dallas 1-wire) interface for libmraa
- *
- * @snippet UartOW.cpp Interesting
- */
-class UartOW
-{
- public:
- /**
- * UartOW Constructor, takes a pin number which will map directly to the
- * linux uart number, this 'enables' the uart, nothing more
- *
- * @throws std::invalid_argument in case of error
- * @param uart the index of the uart to use
- */
- UartOW(int uart)
- {
- m_uart = mraa_uart_ow_init(uart);
-
- if (m_uart == NULL) {
- throw std::invalid_argument("Error initialising UART_OW");
- }
- }
-
- /**
- * UartOW Constructor, takes a string to the path of the serial
- * interface that is needed.
- *
- * @throws std::invalid_argument in case of error
- * @param path the file path for the UART to use
- */
- UartOW(std::string path)
- {
- m_uart = mraa_uart_ow_init_raw(path.c_str());
-
- if (m_uart == NULL) {
- throw std::invalid_argument("Error initialising UART");
- }
- }
-
- /**
- * Uart destructor
- */
- ~UartOW()
- {
- mraa_uart_ow_stop(m_uart);
- }
-
- /**
- * Get string with tty device path within Linux
- * For example. Could point to "/dev/ttyS0"
- *
- * @return char pointer of device path
- */
- std::string
- getDevicePath()
- {
- std::string ret_val(mraa_uart_ow_get_dev_path(m_uart));
- return ret_val;
- }
-
- /**
- * Read a byte from the 1-wire bus
- *
- * @throws std::invalid_argument in case of error
- * @return the byte read
- */
- uint8_t
- readByte()
- {
- int res = mraa_uart_ow_read_byte(m_uart);
- if (res == -1) {
- throw std::invalid_argument("Unknown UART_OW error");
- }
- return (uint8_t) res;
- }
-
- /**
- * Write a byte to a 1-wire bus
- *
- * @param byte the byte to write to the bus
- *
- * @throws std::invalid_argument in case of error
- * @return the byte read back during the time slot
- */
- uint8_t
- writeByte(uint8_t byte)
- {
- int res = mraa_uart_ow_write_byte(m_uart, byte);
- if (res == -1) {
- throw std::invalid_argument("Unknown UART_OW error");
- }
- return (uint8_t) res;
- }
-
- /**
- * Write a bit to a 1-wire bus and read a bit corresponding to the
- * time slot back. This is possible due to the way we wired the TX
- * and RX together with a diode, forming a loopback.
- *
- * @param bit the bit to write to the bus
- * @throws std::invalid_argument in case of error
- * @return the bit read back during the time slot
- */
- bool
- writeBit(bool bit)
- {
- int res = mraa_uart_ow_bit(m_uart, (bit) ? 1 : 0);
- if (res == -1) {
- throw std::invalid_argument("Unknown UART_OW error");
- }
- return ((res) ? true : false);
- }
-
- /**
- * Send a reset pulse to the 1-wire bus and test for device presence
- *
- * @return one of the mraa::Result values
- */
- mraa::Result
- reset()
- {
- return (mraa::Result) mraa_uart_ow_reset(m_uart);
- }
-
- /**
- * Begin a rom code search of the 1-wire bus. This function
- * implements the 1-wire search algorithm. See the uart_ow.c example
- * for an idea on how to use this function to identify all devices
- * present on the bus.
- *
- * @param start true to start a search from scratch, false to
- * continue a previously started search
- * @param id the 8-byte rom code id of the current matched device when a
- * device is found
- * @return one of the mraa::Result values
- */
- mraa::Result
- search(bool start, uint8_t* id)
- {
- return (mraa::Result) mraa_uart_ow_rom_search(m_uart, (start) ? 1 : 0, id);
- }
-
- /**
- * Begin a rom code search of the 1-wire bus. This function
- * implements the 1-wire search algorithm. See the UartOW.cpp
- * example for an idea on how to use this function to identify all
- * devices present on the bus.
- *
- * @param start true to start a search from scratch, false to
- * continue a previously started search
- * @return an empty string if no [more] devices are found, or a
- * string containing the 8-byte romcode of a detected device.
- */
- std::string
- search(bool start)
- {
- uint8_t id[MRAA_UART_OW_ROMCODE_SIZE];
- mraa_result_t rv;
-
- rv = mraa_uart_ow_rom_search(m_uart, (start) ? 1 : 0, id);
-
- if (rv == MRAA_SUCCESS) {
- // we found one
- std::string idStr((char*) id, MRAA_UART_OW_ROMCODE_SIZE);
- return idStr;
- } else {
- // failure, or end of search
- return "";
- }
- }
-
- /**
- * Send a command byte to a device on the 1-wire bus
- *
- * @param command the command byte to send
- * @param id the rom code id of the device to receive the command,
- * NULL for all devices on the bus
- * @return one of the mraa::Result values
- */
- mraa::Result
- command(uint8_t command, uint8_t* id)
- {
- return (mraa::Result) mraa_uart_ow_command(m_uart, command, id);
- }
-
- /**
- * Send a command byte to a device on the 1-wire bus, supplying
- * the id as a std::string
- *
- * @param command the command byte to send
- * @param id std::string representing the code id of the device to
- * receive the command, or an empty string for all devices on the
- * bus. This string should be 8 bytes in size.
- * @return one of the mraa::Result values
- */
- mraa::Result
- command(uint8_t command, std::string id)
- {
- if (id.empty() == 0)
- return (mraa::Result) mraa_uart_ow_command(m_uart, command, NULL);
- else {
- if (id.size() != 8) {
- // Only 8 byte romcodes are legal.
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": id must be 8 bytes only");
- }
- return (mraa::Result) mraa_uart_ow_command(m_uart, command, (uint8_t*) id.c_str());
- }
- }
-
- /**
- * Perform a Dallas 1-wire compliant CRC8 computation on a buffer
- *
- * @param buffer the buffer containing the data
- * @param length the length of the buffer
- * @return the computed CRC
- */
- uint8_t
- crc8(uint8_t* buffer, uint16_t length)
- {
- return mraa_uart_ow_crc8(buffer, length);
- }
-
- /**
- * Perform a Dallas 1-wire compliant CRC8 computation on a
- * std::string based buffer
- *
- * @param buffer std::string buffer containing the data
- * @return the computed CRC
- */
- uint8_t
- crc8(std::string buffer)
- {
- return mraa_uart_ow_crc8((uint8_t*) buffer.c_str(), buffer.size());
- }
-
- private:
- mraa_uart_ow_context m_uart;
-};
-}
diff --git a/peripheral/libmraa/cmake/modules/FindJSON-C.cmake b/peripheral/libmraa/cmake/modules/FindJSON-C.cmake
deleted file mode 100644
index dd8a418..0000000
--- a/peripheral/libmraa/cmake/modules/FindJSON-C.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-# JSON-C_FOUND - true if library and headers were found
-# JSON-C_INCLUDE_DIRS - include directories
-# JSON-C_LIBRARIES - library directories
-
-find_package (PkgConfig)
-pkg_check_modules (PC_JSON-C QUIET json-c)
-
-find_path (JSON-C_INCLUDE_DIR json.h HINTS ${PC_JSON-C_INCLUDEDIR}
-${PC_JSON-C_INCLUDE_DIRS} PATH_SUFFIXES json-c json)
-
-find_library (JSON-C_LIBRARY NAMES json-c libjson-c HINTS ${PC_JSON-C_LIBDIR}
-${PC_JSON-C_LIBRARY_DIRS})
-
-set (JSON-C_LIBRARIES ${JSON-C_LIBRARY})
-set (JSON-C_INCLUDE_DIRS ${JSON-C_INCLUDE_DIR})
-
-include (FindPackageHandleStandardArgs)
-
-find_package_handle_standard_args (JSON-C DEFAULT_MSG JSON-C_LIBRARY JSON-C_INCLUDE_DIR)
-
-mark_as_advanced (JSON-C_INCLUDE_DIR JSON-C_LIBRARY)
diff --git a/peripheral/libmraa/cmake/modules/FindNodejs.cmake b/peripheral/libmraa/cmake/modules/FindNodejs.cmake
index 11e4363..5030768 100644
--- a/peripheral/libmraa/cmake/modules/FindNodejs.cmake
+++ b/peripheral/libmraa/cmake/modules/FindNodejs.cmake
@@ -23,13 +23,13 @@ if (UV_ROOT_DIR)
endif()
# Now look for node. Flag an error if not found
-find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h"
+find_path (NODE_ROOT_DIR "node/node.h" "src/node.h"
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
if (NODE_ROOT_DIR)
- add_include_dir(${NODE_ROOT_DIR}/include/src)
- add_include_dir(${NODE_ROOT_DIR}/include/node)
- add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
- add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
+ add_include_dir(${NODE_ROOT_DIR}/src)
+ add_include_dir(${NODE_ROOT_DIR}/node)
+ add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
+ add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
else()
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - node.h not found")
diff --git a/peripheral/libmraa/cmake/modules/FindUDEV.cmake b/peripheral/libmraa/cmake/modules/FindUDEV.cmake
deleted file mode 100644
index b169671..0000000
--- a/peripheral/libmraa/cmake/modules/FindUDEV.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-# UDEV_FOUND - true if library and headers were found
-# UDEV_INCLUDE_DIRS - include directories
-# UDEV_LIBRARIES - library directories
-
-find_package (PkgConfig)
-pkg_check_modules (PC_UDEV QUIET udev)
-
-find_path (UDEV_INCLUDE_DIR libudev.h HINTS ${PC_UDEV_INCLUDEDIR}
-${PC_UDEV_INCLUDE_DIRS} PATH_SUFFIXES udev)
-
-find_library (UDEV_LIBRARY NAMES udev libudev HINTS ${PC_UDEV_LIBDIR}
-${PC_UDEV_LIBRARY_DIRS})
-
-set (UDEV_LIBRARIES ${UDEV_LIBRARY})
-set (UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR})
-
-include (FindPackageHandleStandardArgs)
-
-find_package_handle_standard_args (UDEV DEFAULT_MSG UDEV_LIBRARY UDEV_INCLUDE_DIR)
-
-mark_as_advanced (UDEV_INCLUDE_DIR UDEV_LIBRARY)
diff --git a/peripheral/libmraa/cmake/modules/OpenCVDetectPython.cmake b/peripheral/libmraa/cmake/modules/OpenCVDetectPython.cmake
deleted file mode 100644
index e3fc3a9..0000000
--- a/peripheral/libmraa/cmake/modules/OpenCVDetectPython.cmake
+++ /dev/null
@@ -1,160 +0,0 @@
-# Find specified Python version
-# Arguments:
-# preferred_version (value): Version to check for first
-# min_version (value): Minimum supported version
-# library_env (value): Name of Python library ENV variable to check
-# include_dir_env (value): Name of Python include directory ENV variable to check
-# found (variable): Set if interpreter found
-# executable (variable): Output of executable found
-# version_string (variable): Output of found version
-# version_major (variable): Output of found major version
-# version_minor (variable): Output of found minor version
-# libs_found (variable): Set if libs found
-# libs_version_string (variable): Output of found libs version
-# libraries (variable): Output of found Python libraries
-# library (variable): Output of found Python library
-# debug_libraries (variable): Output of found Python debug libraries
-# debug_library (variable): Output of found Python debug library
-# include_path (variable): Output of found Python include path
-# include_dir (variable): Output of found Python include dir
-# include_dir2 (variable): Output of found Python include dir2
-# packages_path (variable): Output of found Python packages path
-function(find_python preferred_version min_version library_env include_dir_env
- found executable version_string version_major version_minor
- libs_found libs_version_string libraries library debug_libraries
- debug_library include_path include_dir include_dir2 packages_path)
-if(NOT ${found})
- if(${executable})
- set(PYTHON_EXECUTABLE "${${executable}}")
- endif()
-
- find_package(PythonInterp "${preferred_version}")
- if(NOT PYTHONINTERP_FOUND)
- find_package(PythonInterp "${min_version}")
- endif()
-
- if(PYTHONINTERP_FOUND)
- # Copy outputs
- set(_found ${PYTHONINTERP_FOUND})
- set(_executable ${PYTHON_EXECUTABLE})
- set(_version_string ${PYTHON_VERSION_STRING})
- set(_version_major ${PYTHON_VERSION_MAJOR})
- set(_version_minor ${PYTHON_VERSION_MINOR})
- set(_version_patch ${PYTHON_VERSION_PATCH})
-
- # Clear find_host_package side effects
- unset(PYTHONINTERP_FOUND)
- unset(PYTHON_EXECUTABLE CACHE)
- unset(PYTHON_VERSION_STRING)
- unset(PYTHON_VERSION_MAJOR)
- unset(PYTHON_VERSION_MINOR)
- unset(PYTHON_VERSION_PATCH)
- endif()
-
- if(_found)
- set(_version_major_minor "${_version_major}.${_version_minor}")
-
- if(NOT ANDROID AND NOT APPLE_FRAMEWORK)
- # not using _version_string here, because it might not conform to the CMake version format
- if(CMAKE_CROSSCOMPILING)
- # builder version can differ from target, matching base version (e.g. 2.7)
- find_package(PythonLibs "${_version_major_minor}")
- else()
- find_package(PythonLibs "${_version_major_minor}.${_version_patch}" EXACT)
- endif()
-
- if(PYTHONLIBS_FOUND)
- # Copy outputs
- set(_libs_found ${PYTHONLIBS_FOUND})
- set(_libraries ${PYTHON_LIBRARIES})
- set(_include_path ${PYTHON_INCLUDE_PATH})
- set(_include_dirs ${PYTHON_INCLUDE_DIRS})
- set(_debug_libraries ${PYTHON_DEBUG_LIBRARIES})
- set(_libs_version_string ${PYTHONLIBS_VERSION_STRING})
- set(_debug_library ${PYTHON_DEBUG_LIBRARY})
- set(_library ${PYTHON_LIBRARY})
- set(_library_debug ${PYTHON_LIBRARY_DEBUG})
- set(_library_release ${PYTHON_LIBRARY_RELEASE})
- set(_include_dir ${PYTHON_INCLUDE_DIR})
- set(_include_dir2 ${PYTHON_INCLUDE_DIR2})
-
- # Clear find_package side effects
- unset(PYTHONLIBS_FOUND)
- unset(PYTHON_LIBRARIES)
- unset(PYTHON_INCLUDE_PATH)
- unset(PYTHON_INCLUDE_DIRS)
- unset(PYTHON_DEBUG_LIBRARIES)
- unset(PYTHONLIBS_VERSION_STRING)
- unset(PYTHON_DEBUG_LIBRARY CACHE)
- unset(PYTHON_LIBRARY)
- unset(PYTHON_LIBRARY_DEBUG)
- unset(PYTHON_LIBRARY_RELEASE)
- unset(PYTHON_LIBRARY CACHE)
- unset(PYTHON_LIBRARY_DEBUG CACHE)
- unset(PYTHON_LIBRARY_RELEASE CACHE)
- unset(PYTHON_INCLUDE_DIR CACHE)
- unset(PYTHON_INCLUDE_DIR2 CACHE)
- endif()
- endif()
-
- execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
- RESULT_VARIABLE _cvpy_process
- OUTPUT_VARIABLE _std_packages_path
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if("${_std_packages_path}" MATCHES "site-packages")
- set(_packages_path "python${_version_major_minor}/site-packages")
- else() #debian based assumed, install to the dist-packages.
- set(_packages_path "python${_version_major_minor}/dist-packages")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${${packages_path}}")
- set(_packages_path "lib${LIB_SUFFIX}/${_packages_path}")
- else()
- set(_packages_path "lib/${_packages_path}")
- endif()
- endif()
-
- # Export return values
- set(${found} "${_found}" CACHE INTERNAL "")
- set(${executable} "${_executable}" CACHE FILEPATH "Path to Python interpretor")
- set(${version_string} "${_version_string}" CACHE INTERNAL "")
- set(${version_major} "${_version_major}" CACHE INTERNAL "")
- set(${version_minor} "${_version_minor}" CACHE INTERNAL "")
- set(${libs_found} "${_libs_found}" CACHE INTERNAL "")
- set(${libs_version_string} "${_libs_version_string}" CACHE INTERNAL "")
- set(${libraries} "${_libraries}" CACHE INTERNAL "Python libraries")
- set(${library} "${_library}" CACHE FILEPATH "Path to Python library")
- set(${debug_libraries} "${_debug_libraries}" CACHE INTERNAL "")
- set(${debug_library} "${_debug_library}" CACHE FILEPATH "Path to Python debug")
- set(${include_path} "${_include_path}" CACHE INTERNAL "")
- set(${include_dir} "${_include_dir}" CACHE PATH "Python include dir")
- set(${include_dir2} "${_include_dir2}" CACHE PATH "Python include dir 2")
- set(${packages_path} "${_packages_path}" CACHE PATH "Where to install the python packages.")
-endif()
-endfunction(find_python)
-
-set(MIN_VER_PYTHON2 2.7)
-set(MIN_VER_PYTHON3 3.2)
-
-find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
- PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
- PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
- PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
- PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
- PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH)
-
-find_python(3 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
- PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING
- PYTHON3_VERSION_MAJOR PYTHON3_VERSION_MINOR PYTHON3LIBS_FOUND
- PYTHON3LIBS_VERSION_STRING PYTHON3_LIBRARIES PYTHON3_LIBRARY
- PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH
- PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH)
-
-if(PYTHON_DEFAULT_EXECUTABLE)
- set(PYTHON_DEFAULT_AVAILABLE "TRUE")
-elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter
- set(PYTHON_DEFAULT_AVAILABLE "TRUE")
- set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
-elseif(PYTHON3INTERP_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 2)
- set(PYTHON_DEFAULT_AVAILABLE "TRUE")
- set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
-endif()
diff --git a/peripheral/libmraa/docs/banana_pi.md b/peripheral/libmraa/docs/banana_pi.md
index 45abc95..87e962c 100644
--- a/peripheral/libmraa/docs/banana_pi.md
+++ b/peripheral/libmraa/docs/banana_pi.md
@@ -75,8 +75,6 @@ style numbers.
There is also a second 8-pin connector on the Banana Pi, the pins are as follows:
-| MRAA Number | Physical Pin | Function |
-|-------------|--------------|-----------|
| 27 | P1-19 | 5V VCC |
| 28 | P1-20 | 3V3 VCC |
| 29 | P1-21 | GPIO(PH5) |
diff --git a/peripheral/libmraa/docs/building.md b/peripheral/libmraa/docs/building.md
index 172ccf3..fbd46b8 100644
--- a/peripheral/libmraa/docs/building.md
+++ b/peripheral/libmraa/docs/building.md
@@ -1,10 +1,10 @@
Building libmraa {#building}
===============
+
libmraa uses cmake in order to make compilation relatively painless. CMake runs
build out of tree so the recommended way is to clone from git and make a `build/`
directory inside the clone directory.
-For building imraa check [building imraa](./imraa.md)
## Build dependencies
Not all these are required but if you're unsure of what you're doing this is
what you'll need:
@@ -92,6 +92,10 @@ Building doc, this will require [SPHINX](http://sphinx-doc.org) &
[Doxygen](http://doxygen.org):
`-DBUILDDOC=ON`
+Building with Python 3 (careful you need to clear CMake cache between Python
+version switches!)
+ `-DBUILDPYTHON3=ON`
+
Override build architecture (this is useful because on x86 ARM code is not
compiled so use this flag to force the target arch)
`-DBUILDARCH=arm`
@@ -168,7 +172,7 @@ You can get `cpack` to generate an IPK or RPM package fairly easily if you have
the correct packaging tools
~~~~~~~~~~~~~{.sh}
-cmake -DIPK=ON -DCMAKE_INSTALL_PREFIX=/usr ..
+cmake -DIPK=ON -DCMAKE_INSTAL_PREFIX=/usr ..
make package
~~~~~~~~~~~~~
@@ -176,5 +180,5 @@ To use RPM simply enable the RPM option. You'll need `rpmbuild` installed on you
build machine.
~~~~~~~~~~~~~{.sh}
-cmake -DRPM=ON -DCMAKE_INSTALL_PREFIX=/usr ..
+cmake -DRPM=ON -DCMAKE_INSTAL_PREFIX=/usr ..
~~~~~~~~~~~~~
diff --git a/peripheral/libmraa/docs/changelog.md b/peripheral/libmraa/docs/changelog.md
index 4be19b3..828d8ff 100644
--- a/peripheral/libmraa/docs/changelog.md
+++ b/peripheral/libmraa/docs/changelog.md
@@ -5,49 +5,6 @@ This changelog is meant as a quick & rough guide to what has changed between
versions. The API is now fairly stable but when new calls/features are added
they are listed here. Anything pre 0.2.x is ignored.
-**1.1.1**
- * IIO 4.6 kernel matrix support
- * Intel Grosse Tete radio led support
- * mraa_init_io() examples
- * MRAAPLATFORMFORCE fixes
- * fix python documentation
-
-**1.1.0**
- * build python2 & python3 bindings
- * Intel Grosse Tete support
- * mraa_init_io() generic funtion
- * mraa-gpio fixes
- * edison PWM 0% improvements
- * iio location maping fix
-
-**1.0.0**
- * Change API to enhance error checking in C. Changes include:
- - mraa_aio_read
- - mraa_i2c_read_byte
- - mraa_i2c_read
- - mraa_i2c_read_byte_data
- - mraa_i2c_read_word_data
- - mraa_spi_write_word
- - mraa::Spi:write_word becomes mraa::Spi::writeWord
- * Remove MRAA_ERROR_PLATFORM_ALREADY_INITIALISED which was deprecated for C89 compatibility
- * Remove pwm config_* apis as unused
- * Add mraa_remove_subplatform
- * Support NPM for android
- * Fix AIO always returning channel 0 with firmata support
-
-**0.10.1**
- * Remove imraa from node package
-
-**0.10.0**
- * Add Firmata support with -DFIRMATA=ON
- * Add imraa with support for pinmuxing and arduino101 flashing
- * Add better support for NVM installed node via NODE_ROOT_DIR.
- * Mraa bindings now link to libmraa.so.x
- * mraa_init() now returns MRAA_SUCCESS if platform is already initialize
- * Mraa java bindings now support JNI 1.6+
- * Added support for a02082 rpi2
- * Mraa has a logo!
-
**0.9.6**
* ftdi ft4222 now dynamically loaded
* FT4222 improved ISR code
@@ -65,7 +22,7 @@ they are listed here. Anything pre 0.2.x is ignored.
**0.9.3**
* Intel edison detection much improved
- * ftdi ft4222 interrupt improvement
+ * ftdi ft4222 interupt improvement
* small fixes to java lib
**0.9.2**
diff --git a/peripheral/libmraa/docs/edison.md b/peripheral/libmraa/docs/edison.md
index 1a39699..e8d6264 100644
--- a/peripheral/libmraa/docs/edison.md
+++ b/peripheral/libmraa/docs/edison.md
@@ -37,10 +37,6 @@ in libmraa:
of the Arduino breakout board, this is not supported officially so asking for
mraa_i2c_init(1) will result in getting i2c bus 6 (the default one). However
using raw mode (mraa_i2c_init_raw(1)) this bus is fully usable
-- If you want to use /dev/ttyMFD2 you have to use the raw uart mode passing a
- std::string or char* argument of "/dev/ttyMFD2" to mraa:Uart() or
- mraa_uart_init_raw. By default there is a getty running on that interface so
- you will need to disable that first
Because of the way IO is setup with the tristate on the Arduino breakout board
IO will be flipped as it is setup. It's recommended to setup IO pins &
diff --git a/peripheral/libmraa/docs/firmata.md b/peripheral/libmraa/docs/firmata.md
deleted file mode 100644
index cb82f98..0000000
--- a/peripheral/libmraa/docs/firmata.md
+++ /dev/null
@@ -1,37 +0,0 @@
-Using Firmata board with mraa {#firmata}
-=============================
-
-Mraa can use a Firmata board as a subplatform. This means one can access the
-native IO as well as the IO on a firmata compatible board
-
-### Supported Firmata boards ###
-
-- Genuino/Arduino 101 running either CustomFirmata or StandardFirmata
-- Other Arduino boards will likely work but are as of yet unsuported
-
-### Using the subplatform API ###
-
-Using the subplatform API is relatively simple, simply add '512', the platform
-offset to any IO calls. I2c 0 becomes I2c 512+0 etc... The API works from UPM
-or mraa in any of the bindings as long as you compiled mraa with -DFIRMATA=ON.
-Currently -DFIRMATA is not compatible with USBPLAT. Multiple subplatforms are
-not yet supported
-
-### Sending custom SYSSEX messages ###
-
-You can use the firmata API to send custom SYSEX messages.
-
-### CurieImu Plugin ###
-
-Using Customisable firmata we're able to use the onboard IMU to get data. This
-uses the public SYSEX firmata API from mraa and there is a UPM module that
-exposes this capability in a simple way. To use it your board needs to use
-CustomFirmata with the CurieIMU plugin
-
-### Limitations ###
-
-Only one instance of mraa (one process linking to mraa) can communicate to an
-firmata subplatform. This is a limitation due to only having one application
-using the Uart at once. In order to get around this a daemon type methodology
-has to be used. Technically you can mirror the TTY port from firmata but this
-is likely going to cause issues
diff --git a/peripheral/libmraa/docs/galileorevd.md b/peripheral/libmraa/docs/galileorevd.md
index 20c07e9..42201a5 100644
--- a/peripheral/libmraa/docs/galileorevd.md
+++ b/peripheral/libmraa/docs/galileorevd.md
@@ -8,7 +8,7 @@ The rev D board has the following limitations in libmraa:
- gpio 13 will not switch the LED as it's a different Gpio, use raw gpio '3' to do this
- gpio register access via /dev/uio is limited to pin2 and 3
-- gpio interrupts will only work on GPIO_EDGE_BOTH
+- gpio interupts will only work on GPIO_EDGE_BOTH
- adc kernel module will return 12bit number. MRAA defaults shift this to 10bits
- AIO pins are treated as 0-5 in mraa_aio_init() but as 14-19 for everything
else. Therefore use mraa_gpio_init(14) to use A0 as a Gpio
diff --git a/peripheral/libmraa/docs/galileorevh.md b/peripheral/libmraa/docs/galileorevh.md
index 53158bc..4afe5fa 100644
--- a/peripheral/libmraa/docs/galileorevh.md
+++ b/peripheral/libmraa/docs/galileorevh.md
@@ -17,16 +17,6 @@ The Gen 2 board has the following limitations in libmraa:
accuracy of 10bits.
- AIO pins are treated as 0-5 in mraa_aio_init() but as 14-19 for everything
else. Therefore use mraa_gpio_init(14) to use A0 as a Gpio
-- To explicitly use GPIO 10 for SPI and allow the kernel to handle the chip select, set
- `intel_qrk_plat_galileo_gen2.gpio_cs=1` on the kernel line in the boot config on the
- galileo, this can be found at `/media/mmcblk0p1/boot/grub/grub.conf`
-- if done correctly it should look similiar to this:
-
-<pre>
- title Quark X1000 kernel-MassStorage iot-devkit on SD IMR-On IO-APIC/HPET NoEMU debug
- root (hd0,0)
- kernel /bzImage root=/dev/mmcblk0p2 <b>intel_qrk_plat_galileo_gen2.gpio_cs=1</b> rootwait console=ttyS1,115200n8 earlycon=uart8250,mmio32,0x8010f000,115200n8 reboot=efi,warm apic=debug rw LABEL=boot debugshell=5
-</pre>
Uart 1 on gen2
--------------
@@ -36,8 +26,8 @@ possible to use it from A2(Rx)/A3(Tx). However mraa does not support this
directly so you need to enable the muxing manually. Here is an example of how
this is done, this was tested using an FTDI 3.3V TTL cable:
-```
$ systemctl stop serial-getty@ttyS1.service
+
$ python
>>> # Configure the Muxes for Uart1 on Aio2/3
>>> import mraa as m
@@ -63,4 +53,4 @@ $ python
>>> x.writeStr('hello')
>>> x.read(5)
bytearray(b'dsds\n')
-```
+
diff --git a/peripheral/libmraa/docs/grossetete.md b/peripheral/libmraa/docs/grossetete.md
deleted file mode 100644
index 47ac0bb..0000000
--- a/peripheral/libmraa/docs/grossetete.md
+++ /dev/null
@@ -1,112 +0,0 @@
-Grosse Tete {#grossetete}
-===========
-
-The Grosse Tete with the Tuchuck board is supported by Mraa
-
-Revision Support
-----------------
-Tuchuck
-
-Interface notes
----------------
-
-**SPI** Currently not working
-
-**UART** Some pins are labelled as UARTs but are not configured in BIOS as UART
-so only available UART is on the FTDI header
-
-Pin Mapping
------------
-
-Tuchuck has two breakouts, breakout #1 is 1-40 whilst breakout2 is 41-80. The
-LEDs are numbered from 100-103.
-
-| MRAA Number | Physical Pin | Function |
-|-------------|--------------|----------|
-| 1 | GPIO | GPIO |
-| 2 | SPP1RX | GPIO |
-| 3 | PMICRST | NONE |
-| 4 | SPP1TX | GPIO |
-| 5 | 19.2mhz | GPIO |
-| 6 | SPP1FS0 | GPIO |
-| 7 | UART0TX | GPIO |
-| 8 | SPP1FS2 | GPIO |
-| 9 | PWRGD | NONE |
-| 10 | SPP1CLK | GPIO |
-| 11 | I2C0SDA | I2C |
-| 12 | I2S1SDI | GPIO |
-| 13 | I2C0SCL | I2C |
-| 14 | I2S1SDO | GPIO |
-| 15 | I2C1SDA | I2C |
-| 16 | I2S1WS | GPIO |
-| 17 | I2C1SCL | I2C |
-| 18 | I2S1CLK | GPIO |
-| 19 | I2C2SDA | I2C |
-| 20 | I2S1MCL | GPIO |
-| 21 | I2C2SCL | I2CO |
-| 22 | UART1TX | UART |
-| 23 | I2S4SDO | NONE |
-| 24 | UART1RX | UART |
-| 25 | I2S4SDI | NONE |
-| 26 | PWM0 | GPIO PWM |
-| 27 | I2S4BLK | GPIO |
-| 28 | PWM1 | GPIO PWM |
-| 29 | I2S4WS | NONE |
-| 30 | PWM2 | GPIO PWM |
-| 31 | I2S3SDO | NONE |
-| 32 | PWM3 | GPIO PWM |
-| 33 | I2S3SDI | NONE |
-| 34 | 1.8V | NONE |
-| 35 | I2S4BLK | GPIO |
-| 36 | GND | NONE |
-| 37 | GND | NONE |
-| 38 | GND | NONE |
-| 39 | GND | NONE |
-| 40 | 3.3V | NONE |
-| 41 | GND | NONE |
-| 42 | 5V | NONE |
-| 43 | GND | NONE |
-| 44 | 5V | NONE |
-| 45 | GND | NONE |
-| 46 | 3.3V | NONE |
-| 47 | GND | NONE |
-| 48 | 3.3V | NONE |
-| 49 | GND | NONE |
-| 50 | 1.8V | NONE |
-| 51 | GPIO | GPIO |
-| 52 | 1.8V | NONE |
-| 53 | PANEL | GPIO |
-| 54 | GND | NONE |
-| 55 | PANEL | GPIO |
-| 56 | CAMERA | NONE |
-| 57 | PANEL | GPIO |
-| 58 | CAMERA | NONE |
-| 59 | SPP0FS0 | GPIO |
-| 60 | CAMERA | NONE |
-| 61 | SPP0FS1 | GPIO |
-| 62 | SPI_DAT | SPI |
-| 63 | SPP0FS2 | GPIO |
-| 64 | SPICLKB | GPIO SPI |
-| 65 | SPP0FS3 | GPIO |
-| 66 | SPICLKA | GPIO SPI |
-| 67 | SPP0TX | GPIO |
-| 68 | UART0RX | GPIO UART|
-| 69 | SPP0RX | GPIO |
-| 70 | UART0RT | GPIO UART|
-| 71 | I2C1SDA | GPIO I2C |
-| 72 | UART0CT | GPIO UART|
-| 73 | I2C1SCL | GPIO I2C |
-| 74 | UART1TX | GPIO UART|
-| 75 | I2C2SDA | GPIO I2C |
-| 76 | UART1RX | GPIO UART|
-| 77 | I2C1SCL | GPIO I2C |
-| 78 | UART1RT | GPIO UART|
-| 79 | RTC_CLK | GPIO |
-| 80 | UART1CT | GPIO UART|
-| 100 | LED100 | GPIO |
-| 101 | LED101 | GPIO |
-| 102 | LED102 | GPIO |
-| 103 | LED103 | GPIO |
-
-To see a live pin mapping use the command:
-$ mraa-gpio list
diff --git a/peripheral/libmraa/docs/imraa.md b/peripheral/libmraa/docs/imraa.md
deleted file mode 100644
index 1bab5de..0000000
--- a/peripheral/libmraa/docs/imraa.md
+++ /dev/null
@@ -1,63 +0,0 @@
-# Building mraa with imraa {#buildingimraa}
-Imraa allows seamless communication between the Arduino101 and your mraa
-projects. Imraa will flash an arduino101 and allow automatic loading of the
-MRAA_GENERIC_FIRMATA subplatform to the first process that calls imraa_init
-(done through mraa_init automatically)
-
-## Build dependencies
-To build imraa, you'll need to build mraa with -DIMRAA=ON and all the normal
-dependencies for build mraa, see [Building mraa](./building.md).
-You'll also need the following:
-* [dfu-utils-cross](https://github.com/arduino/dfu-utils-cross) or dfu 0.8 (0.9
- does not work well with the 101). Precompiled binaries can be found on
- [here](https://github.com/01org/intel-arduino-tools)
-* [json-c](https://github.com/json-c/json-c): likely called libjson-c-dev or
- json-c-devel
-* libudev: likely called libudev-dev or libudev-devel
-
-## Basic build steps
-This will build mraa with imraa for the local default path. To build mraa for
-the system add `-DCMAKE_INSTALL_PREFIX=/usr` to the cmake command before
-running it.
-
-```bash
-mkdir build
-cd build
-cmake -DIMRAA=ON -DFIRMATA=ON ..
-make
-```
-
-After you've built mraa you can install using `make install`.
-
-## Running Imraa
-
-Before being able to use mraa to program the Arduino101 you will need to run
-imraa to flash the sketch file onto the board. The sketch file that imraa will
-look for is located here: [Arduino101 Sketch](http://iotdk.intel.com/misc/ConfigurableFirmataCurieImu.ino.bin).
-Once downloaded the file needs to be renamed and moved to the where mraa was
-installed. This is dependant on whether you installed locally or for the
-system. The example below is for a locally installed copy. Note this sketch is
-using ConfigurableFirmata + the [CurieIMU plugin](https://github.com/intel-iot-devkit/FirmataCurieIMU).
-
-
-```bash
-$ mv ConfigurableFirmataCurieImu.ino.bin firmata101.ino.bin
-$ mv firmata101.ino.bin /usr/local/share/mraa
-```
-
-You will also need to move the imraa config so that imraa can find it.
-```bash
-$ mv mraa/imraa/imraa.conf /etc/
-```
-
-To flash the board run imraa and it will create the lockfile and flash the
-Arduino101. You may need root permissions or to add yourself to the uucp or
-modem group to access the device node (typically /dev/ttyACM0).
-```
-$ imraa
-```
-
-After this is successful you will be able to use mraa like normal, in the
-background mraa will handle talking to the arduino101 by creating
-/tmp/imraa.lock which imraa_init() will parse on startup.
-
diff --git a/peripheral/libmraa/docs/index.java.md b/peripheral/libmraa/docs/index.java.md
index 56154d1..0207414 100644
--- a/peripheral/libmraa/docs/index.java.md
+++ b/peripheral/libmraa/docs/index.java.md
@@ -46,8 +46,6 @@ Specific platform information for supported platforms is documented here:
- @ref bananapi
- @ref beaglebone
- @ref nuc5
-- @ref up
-- @ref grossetete
- @ref ft4222
## DEBUGGING
diff --git a/peripheral/libmraa/docs/index.md b/peripheral/libmraa/docs/index.md
index 3fa106d..ec98f16 100644
--- a/peripheral/libmraa/docs/index.md
+++ b/peripheral/libmraa/docs/index.md
@@ -47,7 +47,6 @@ Specific platform information for supported platforms is documented here:
- @ref beaglebone
- @ref nuc5
- @ref up
-- @ref grossetete
- @ref ft4222
## DEBUGGING
diff --git a/peripheral/libmraa/examples/CMakeLists.txt b/peripheral/libmraa/examples/CMakeLists.txt
index 0cb7756..31d8087 100644
--- a/peripheral/libmraa/examples/CMakeLists.txt
+++ b/peripheral/libmraa/examples/CMakeLists.txt
@@ -35,18 +35,6 @@ target_link_libraries (mraa-i2c mraa)
target_link_libraries (spi_max7219 mraa)
target_link_libraries (iio_driver mraa)
-if (ONEWIRE)
- add_executable (uart_ow uart_ow.c)
- target_link_libraries (uart_ow mraa)
-endif ()
-
-if (FIRMATA)
- add_executable (firmata_curie_imu firmata_curie_imu.c)
- add_executable (i2c_firmata i2c_firmata.c)
- target_link_libraries (firmata_curie_imu mraa)
- target_link_libraries (i2c_firmata mraa)
-endif ()
-
add_subdirectory (c++)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/mraa/examples)
diff --git a/peripheral/libmraa/examples/c++/CMakeLists.txt b/peripheral/libmraa/examples/c++/CMakeLists.txt
index 51a3f3a..d688d48 100644
--- a/peripheral/libmraa/examples/c++/CMakeLists.txt
+++ b/peripheral/libmraa/examples/c++/CMakeLists.txt
@@ -19,8 +19,3 @@ target_link_libraries (Spi-pot mraa stdc++)
target_link_libraries (Uart mraa stdc++)
target_link_libraries (Isr-pin6 mraa stdc++)
target_link_libraries (Iio-dummy mraa stdc++)
-
-if (ONEWIRE)
- add_executable (UartOW UartOW.cpp)
- target_link_libraries (UartOW mraa stdc++)
-endif ()
diff --git a/peripheral/libmraa/examples/c++/UartOW.cpp b/peripheral/libmraa/examples/c++/UartOW.cpp
deleted file mode 100644
index bccc7a2..0000000
--- a/peripheral/libmraa/examples/c++/UartOW.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation
- *
- * 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 "stdio.h"
-#include "iostream"
-//! [Interesting]
-#include "uart_ow.hpp"
-
-using namespace std;
-
-int
-main(int argc, char** argv)
-{
- mraa::UartOW* uart = new mraa::UartOW(0);
-
- // Reset the ow bus and see if anything is present
- mraa::Result rv;
-
- if ((rv = uart->reset()) == mraa::SUCCESS) {
- cout << "Reset succeeded, device(s) detected!" << endl;
- } else {
- cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl;
- return 1;
- }
-
- cout << "Looking for devices..." << endl;
- ;
-
- uint8_t count = 0;
- // start the search from scratch
- string id = uart->search(true);
-
- if (id.empty()) {
- cout << "No devices detected." << endl;
- return 1;
- }
-
- while (!id.empty()) {
- // hack so we don't need to cast each element of the romcode
- // for printf purposes
- uint8_t* ptr = (uint8_t*) id.c_str();
-
- // The first byte (0) is the device type (family) code.
- // The last byte (7) is the rom code CRC value. The
- // intervening bytes are the unique 48 bit device ID.
-
- printf("Device %02d Type 0x%02x ID %02x%02x%02x%02x%02x%02x CRC 0x%02x\n", count, ptr[0],
- ptr[6], ptr[5], ptr[4], ptr[3], ptr[2], ptr[1], ptr[7]);
- count++;
-
- // continue the search with start argument set to false
- id = uart->search(false);
- }
-
- cout << "Exiting..." << endl;
-
- delete uart;
-
- return 0;
-}
-//! [Interesting]
diff --git a/peripheral/libmraa/examples/c++/initio.cpp b/peripheral/libmraa/examples/c++/initio.cpp
deleted file mode 100644
index 17526f1..0000000
--- a/peripheral/libmraa/examples/c++/initio.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Author: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "mraa.hpp"
-
-int main()
-{
- // GPIO-PIN
- mraa::Gpio* gpio = mraa::initIo<mraa::Gpio>("gpio-1");
- // GPIO-RAW-RAWPIN
- mmraa::Gpio* gpioraw = mraa::initIo<mraa::Gpio>initIo("gpio-raw-131");
- // AIO-PIN
- mraa::Aio aio = mraa::initIo<mraa::Aio>("aio-0");
- // PWM-PIN
- mraa::Pwm pwm = mraa::initIo<mraa::Pwm>("pwm-6");
- // PWM-RAW-CHIPID-PIN
- mraa::Pwm pwmraw = mraa::initIo<mraa::Pwm>("pwm-raw-0,1");
- // UART-INDEX: the index is the one represented internally in the uart_dev array
- mraa::Uart uart = mraa::initIo<mraa::Uart>("uart-1");
- // UART-RAW-PATH
- mraa::Uart uartraw = mraa::initIo<mraa::Uart>("uart-raw-/dev/ttyS0");
- // SPI-INDEX: same as UART
- mraa::Spi spi = mraa::initIo<mraa::Spi>("spi-0");
- // SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
- mraa::Spi spiraw = mraa::initIo<mraa::Spi>("spi-raw-0-1");
- // I2C-INDEX: same as UART
- mraa::I2c i2c = mraa::initIo<mraa::I2c>("i2c-0");
- // I2C-RAW-BUS
- mraa::I2c i2craw = mraa::initIo<mraa::I2c>("i2c-raw-0");
-
- // FREE STUFF
- delete gpio;
- delete gpioraw;
- delete aio;
- delete pwm;
- delete pwmraw;
- delete uart;
- delete uartraw;
- delete spi;
- delete spiraw;
- delete i2c;
- delete i2craw;
-}
diff --git a/peripheral/libmraa/examples/firmata_curie_imu.c b/peripheral/libmraa/examples/firmata_curie_imu.c
deleted file mode 100644
index 1564d11..0000000
--- a/peripheral/libmraa/examples/firmata_curie_imu.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Author: Brendan Le Foll
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 "mraa.h"
-#include "mraa/firmata.h"
-
-#define FIRMATA_START_SYSEX 0xF0
-#define FIRMATA_END_SYSEX 0xF7
-#define FIRMATA_CURIE_IMU 0x11
-#define FIRMATA_CURIE_IMU_READ_ACCEL 0x00
-
-void
-interrupt(uint8_t* buf, int length)
-{
- printf("reg read returned: %d, with buffer size %d\n", ((buf[6] & 0x7f) | ((buf[7] & 0x7f) << 7)), length);
-}
-
-int
-main()
-{
- mraa_init();
- //! [Interesting]
-
- /**
- * This example reads from the FirmataCurieIMU plugin
- */
-
- mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
- mraa_firmata_context firm = mraa_firmata_init(FIRMATA_CURIE_IMU);
- if (firm == NULL) {
- return EXIT_FAILURE;
- }
-
- mraa_firmata_response(firm, interrupt);
-
- uint8_t* buffer = calloc(4, 0);
- if (buffer == NULL) {
- free(firm);
- return EXIT_FAILURE;
- }
- buffer[0] = FIRMATA_START_SYSEX;
- buffer[1] = FIRMATA_CURIE_IMU;
- buffer[2] = FIRMATA_CURIE_IMU_READ_ACCEL;
- buffer[3] = FIRMATA_END_SYSEX;
-
- mraa_firmata_write_sysex(firm, buffer, 4);
-
- sleep(1);
-
- // stop the isr and set it again
- mraa_firmata_response_stop(firm);
- mraa_firmata_response(firm, interrupt);
- mraa_firmata_write_sysex(firm, buffer, 4);
-
- sleep(1);
-
- // close everything and try again
- mraa_firmata_close(firm);
- firm = mraa_firmata_init(FIRMATA_CURIE_IMU);
- mraa_firmata_response(firm, interrupt);
- mraa_firmata_write_sysex(firm, buffer, 4);
-
- sleep(10);
-
- mraa_firmata_close(firm);
- //! [Interesting]
-
- return EXIT_SUCCESS;
-}
diff --git a/peripheral/libmraa/examples/hellomraa.c b/peripheral/libmraa/examples/hellomraa.c
index f8fd440..62a1ea1 100644
--- a/peripheral/libmraa/examples/hellomraa.c
+++ b/peripheral/libmraa/examples/hellomraa.c
@@ -32,6 +32,8 @@ int
main(int argc, char** argv)
{
const char* board_name = mraa_get_platform_name();
+ int i2c_bus, i, i2c_adapter;
+
fprintf(stdout, "hello mraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
mraa_deinit();
diff --git a/peripheral/libmraa/examples/i2c_firmata.c b/peripheral/libmraa/examples/i2c_firmata.c
deleted file mode 100644
index e072ad1..0000000
--- a/peripheral/libmraa/examples/i2c_firmata.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 "mraa.h"
-
-int
-main(int argc, char** argv)
-{
- mraa_init();
- mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
-
- mraa_i2c_context i2c;
- i2c = mraa_i2c_init(0 + 512);
-#if 0
- mraa_i2c_address(i2c, 0x62);
-
-#if 1
- uint8_t rx_tx_buf[2];
- rx_tx_buf[0] = 0x0;
- rx_tx_buf[1] = 0x0;
- mraa_i2c_write(i2c, rx_tx_buf, 2);
-#endif
- //mraa_i2c_write_byte_data(i2c, 0x0, 0x0);
- mraa_i2c_write_byte_data(i2c, 0x0, 0x1);
-
- mraa_i2c_write_byte_data(i2c, 0xFF, 0x08);
- mraa_i2c_write_byte_data(i2c, 0x00, 0x04);
- mraa_i2c_write_byte_data(i2c, 0xA0, 0x02);
-#else
- mraa_i2c_address(i2c, 0x77);
- int res = mraa_i2c_read_byte_data(i2c, 0xd0);
- printf("res is 0x%x\n", res);
-
- uint8_t data[2];
- mraa_i2c_write_byte(i2c, 0x77);
- mraa_i2c_read(i2c, data, 1);
-
- res = mraa_i2c_read_word_data(i2c, 0xAA); // BMP085_CAL_AC1
- printf("res is %d\n", res);
-#endif
- sleep(10);
-
-}
diff --git a/peripheral/libmraa/examples/initio.c b/peripheral/libmraa/examples/initio.c
deleted file mode 100644
index da0ca13..0000000
--- a/peripheral/libmraa/examples/initio.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Author: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "mraa.h"
-
-int main()
-{
- // GPIO-PIN
- mraa_gpio_context gpio = (mraa_gpio_context) init_io("gpio-1");
- // GPIO-RAW-RAWPIN
- mraa_gpio_context gpioraw = (mraa_gpio_context) init_io("gpio-raw-131");
- // AIO-PIN
- mraa_aio_context aio = (mraa_aio_context) init_io("aio-0");
- // PWM-PIN
- mraa_pwm_context pwm = (mraa_pwm_context) init_io("pwm-6");
- // PWM-RAW-CHIPID-PIN
- mraa_pwm_context pwmraw= (mraa_pwm_context) init_io("pwm-raw-0,1");
- // UART-INDEX: the index is the one represented internally in the uart_dev array
- mraa_uart_context uart = (mraa_uart_context) init_io("uart-1");
- // UART-RAW-PATH
- mraa_uart_context uartraw = (mraa_uart_context) init_io("uart-raw-/dev/ttyS0");
- // SPI-INDEX: same as UART
- mraa_spi_context spi = (mraa_spi_context) init_io("spi-0");
- // SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
- mraa_spi_context spiraw = (mraa_spi_context) init_io("spi-raw-0-1");
- // I2C-INDEX: same as UART
- mraa_i2c_context i2c = (mraa_i2c_context) init_io("i2c-0");
- // I2C-RAW-BUS
- mraa_i2c_context i2craw = (mraa_i2c_context) init_io("i2c-raw-0");
-
-
- // FREE STUFF
- mraa_gpio_close(gpio);
- mraa_gpio_close(gpioraw);
- mraa_aio_close(aio);
- mraa_pwm_close(pwm);
- mraa_pwm_close(pwmraw);
- mraa_uart_close(uart);
- mraa_uart_close(uartraw);
- mraa_spi_close(spi);
- mraa_spi_close(spiraw);
- mraa_i2c_close(i2c);
- mraa_i2c_close(i2craw);
-}
diff --git a/peripheral/libmraa/examples/java/BlinkIO.java b/peripheral/libmraa/examples/java/BlinkIO.java
index 307a649..0e9209d 100644
--- a/peripheral/libmraa/examples/java/BlinkIO.java
+++ b/peripheral/libmraa/examples/java/BlinkIO.java
@@ -50,7 +50,7 @@ public class BlinkIO {
if (argv.length == 0) {
System.out.println("Provide an int arg if you want to flash on something other than " + DEFAULT_IOPIN);
} else {
- iopin = Integer.valueOf(argv[0]);
+ iopin = Integer.valueOf(argv[0], DEFAULT_IOPIN);
}
//! [Interesting]
diff --git a/peripheral/libmraa/examples/java/Isr.java b/peripheral/libmraa/examples/java/Isr.java
index a20b1b7..a43dcc7 100644
--- a/peripheral/libmraa/examples/java/Isr.java
+++ b/peripheral/libmraa/examples/java/Isr.java
@@ -22,9 +22,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
import mraa.Dir;
import mraa.Edge;
import mraa.Gpio;
@@ -40,7 +37,6 @@ public class Isr {
System.exit(1);
}
}
-
public static void main(String argv[]) throws InterruptedException {
int pin = 6;
if (argv.length == 1) {
@@ -49,37 +45,21 @@ public class Isr {
} catch (Exception e) {
}
}
- BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
- Gpio gpio = null;
- try {
- gpio = new Gpio(pin);
- } catch (Exception e) {
- System.out.println(e.getMessage());
- return;
- }
- System.out.println("Starting ISR for pin " + Integer.toString(pin) + ". Press ENTER to stop");
- Runnable callback = new JavaCallback(gpio);
+ System.out.println("Starting ISR for pin " + Integer.toString(pin));
+ Gpio gpio = new Gpio(pin);
+
+ Runnable callback = new JavaCallback();
+
gpio.isr(Edge.EDGE_RISING, callback);
- try {
- String input = console.readLine();
- } catch (IOException e) {
- }
- gpio.isrExit();
- }
+ while (true)
+ Thread.sleep(999999);
+ };
}
class JavaCallback implements Runnable {
- private Gpio gpio;
-
- public JavaCallback(Gpio gpio) {
- this.gpio = gpio;
- }
-
@Override
public void run() {
- String pin = Integer.toString(gpio.getPin(true));
- String level = Integer.toString(gpio.read());
- System.out.println("Pin " + pin + " = " + level);
+ System.out.println("Gpio level changed");
}
}
diff --git a/peripheral/libmraa/examples/javascript/firmata.js b/peripheral/libmraa/examples/javascript/firmata.js
deleted file mode 100644
index c2b8d31..0000000
--- a/peripheral/libmraa/examples/javascript/firmata.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Author: Ron Evans (@deadprogram)
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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.
- */
-
-var mraa = require('mraa');
-console.log('MRAA Version: ' + mraa.getVersion());
-
-// open connection to firmata
-mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");
diff --git a/peripheral/libmraa/examples/javascript/gpio-tool.js b/peripheral/libmraa/examples/javascript/gpio-tool.js
index c5fb792..f254bf6 100644
--- a/peripheral/libmraa/examples/javascript/gpio-tool.js
+++ b/peripheral/libmraa/examples/javascript/gpio-tool.js
@@ -31,10 +31,8 @@ const rl = readline.createInterface({
});
function printUsage() {
- console.log("version Print version");
- console.log("get pin Get pin level");
- console.log("set pin level Set pin level");
- console.log("monitor pin Monitor pin level changes");
+ console.log("version Print version");
+ console.log("get pin Get pin value");
}
function getVersion() {
@@ -57,22 +55,17 @@ function getPin() {
}
function onPinLevelChange() {
- console.log('gpio level change');
+ console.log('gpio change');
}
function monitorPin() {
var pinNumber = arguments[0];
- try {
- var pin = new mraa.Gpio(pinNumber);
- pin.dir(mraa.DIR_IN);
- pin.isr(mraa.EDGE_BOTH, onPinLevelChange);
- rl.question('Press ENTER to stop', function(answer) {
- rl.close();
- pin.isrExit();
- });
- } catch (err) {
- console.log(err.message);
- }
+ var pin = new mraa.Gpio(pinNumber);
+ pin.dir(mraa.DIR_IN);
+ pin.isr(mraa.EDGE_BOTH, onPinLevelChange);
+ rl.question('Press ENTER to stop', function(answer) {
+ rl.close();
+ });
}
const args = process.argv;
diff --git a/peripheral/libmraa/examples/javascript/initio.js b/peripheral/libmraa/examples/javascript/initio.js
deleted file mode 100644
index c5fc58b..0000000
--- a/peripheral/libmraa/examples/javascript/initio.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Author: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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.
- */
-
-var m = require('mraa');
-
-// GPIO-PIN
-m.gpioFromDesc("gpio-1");
-// GPIO-RAW-RAWPIN
-m.gpioFromDesc("gpio-raw-131");
-// AIO-PIN
-m.aioFromDesc("aio-1");
-//PWM-PIN
-m.pwmFromDesc("pwm-6");
-// PWM-RAW-CHIPID-PIN
-m.pwmFromDesc("pwm-raw-0-1")
-// UART-INDEX: the index is the one represented internally in the uart_dev array
-m.uartFromDesc("uart-0");
-// UART-RAW-PATH
-m.uartFromDesc("uart-raw-/dev/ttyS0");
-// SPI-INDEX: same as UART
-m.spiFromDesc("spi-0");
-// SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
-m.spiFromDesc("spi-raw-0-1");
-// I2C-INDEX: same as UART
-m.i2cFromDesc("i2c-0");
-// I2C-RAW-BUS
-m.i2cFromDesc("i2c-raw-0");
diff --git a/peripheral/libmraa/examples/javascript/isr.js b/peripheral/libmraa/examples/javascript/isr.js
index 9abcb1f..d400c0d 100644
--- a/peripheral/libmraa/examples/javascript/isr.js
+++ b/peripheral/libmraa/examples/javascript/isr.js
@@ -8,9 +8,3 @@ function h() {
x = new m.Gpio(14)
x.isr(m.EDGE_BOTH, h)
-
-setInterval(function() {
- // It's important to refer to our GPIO context here,
- // otherwise it will be garbage-collected
- console.log("Waiting for an interrupt at GPIO pin " + x.getPin() + "...")
-}, 10000)
diff --git a/peripheral/libmraa/examples/mraa-gpio.c b/peripheral/libmraa/examples/mraa-gpio.c
index 8c15217..e94d48f 100644
--- a/peripheral/libmraa/examples/mraa-gpio.c
+++ b/peripheral/libmraa/examples/mraa-gpio.c
@@ -67,7 +67,7 @@ list_platform_pins(uint8_t platform_offset)
for (i = 0; i < pin_count; ++i) {
int pin_id = platform_offset > 0 ? mraa_get_sub_platform_id(i) : i;
char* pin_name = mraa_get_pin_name(pin_id);
- if (strcmp(pin_name, "INVALID") != 0 && mraa_pin_mode_test(pin_id, MRAA_PIN_VALID)) {
+ if (strcmp(pin_name, "INVALID") != 0) {
fprintf(stdout, "%02d ", pin_id);
fprintf(stdout, "%*s: ", (MRAA_PIN_NAME_SIZE - 1), pin_name);
if (mraa_pin_mode_test(pin_id, MRAA_PIN_GPIO))
@@ -97,19 +97,13 @@ list_pins()
if (pin_count == 0) {
fprintf(stdout, "No Pins\n");
}
- return pin_count;
}
+
mraa_result_t
gpio_set(int pin, int level, mraa_boolean_t raw)
{
- mraa_gpio_context gpio;
- if (raw) {
- gpio = mraa_gpio_init_raw(pin);
- }
- else {
- gpio = mraa_gpio_init(pin);
- }
+ mraa_gpio_context gpio = mraa_gpio_init(pin);
if (gpio != NULL) {
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
if (raw != 0) {
diff --git a/peripheral/libmraa/examples/python/firmata.py b/peripheral/libmraa/examples/python/firmata.py
deleted file mode 100644
index c88a492..0000000
--- a/peripheral/libmraa/examples/python/firmata.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-
-# Author: Ron Evans (@deadprogram)
-# Copyright (c) 2016 Intel Corporation.
-#
-# 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.
-
-import mraa
-
-print (mraa.getVersion())
-
-mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");
diff --git a/peripheral/libmraa/examples/python/hello_isr.py b/peripheral/libmraa/examples/python/hello_isr.py
index 7cdd276..cb02488 100644
--- a/peripheral/libmraa/examples/python/hello_isr.py
+++ b/peripheral/libmraa/examples/python/hello_isr.py
@@ -24,31 +24,20 @@
import mraa
import time
-import sys
class Counter:
count = 0
c = Counter()
-# inside a python interrupt you cannot use 'basic' types so you'll need to use
+# inside a python interupt you cannot use 'basic' types so you'll need to use
# objects
-def test(gpio):
- print("pin " + repr(gpio.getPin(True)) + " = " + repr(gpio.read()))
+def test(args):
+ print("wooo")
c.count+=1
-pin = 6;
-if (len(sys.argv) == 2):
- try:
- pin = int(sys.argv[1], 10)
- except ValueError:
- printf("Invalid pin " + sys.argv[1])
-try:
- x = mraa.Gpio(pin)
- print("Starting ISR for pin " + repr(pin))
- x.dir(mraa.DIR_IN)
- x.isr(mraa.EDGE_BOTH, test, x)
- var = raw_input("Press ENTER to stop")
- x.isrExit()
-except ValueError as e:
- print(e)
+x = mraa.Gpio(6)
+x.dir(mraa.DIR_IN)
+x.isr(mraa.EDGE_BOTH, test, test)
+
+time.sleep(500)
diff --git a/peripheral/libmraa/examples/python/initio.py b/peripheral/libmraa/examples/python/initio.py
deleted file mode 100644
index b5c3548..0000000
--- a/peripheral/libmraa/examples/python/initio.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/usr/env python
-
-# Author: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# 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
-
-import mraa as m
-
-# GPIO-PIN
-m.gpioFromDesc("gpio-1");
-# GPIO-RAW-RAWPIN
-m.gpioFromDesc("gpio-raw-131");
-# AIO-PIN
-m.aioFromDesc("aio-1");
-# PWM-PIN
-m.pwmFromDesc("pwm-6");
-# PWM-RAW-CHIPID-PIN
-m.pwmFromDesc("pwm-raw-0-1")
-# UART-INDEX: the index is the one represented internally in the uart_dev array
-m.uartFromDesc("uart-0");
-# UART-RAW-PATH
-m.uartFromDesc("uart-raw-/dev/ttyS0");
-# SPI-INDEX: same as UART
-m.spiFromDesc("spi-0");
-# SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
-m.spiFromDesc("spi-raw-0-1");
-# I2C-INDEX: same as UART
-m.i2cFromDesc("i2c-0");
-# I2C-RAW-BUS
-m.i2cFromDesc("i2c-raw-0");
diff --git a/peripheral/libmraa/examples/uart_ow.c b/peripheral/libmraa/examples/uart_ow.c
deleted file mode 100644
index 63ed410..0000000
--- a/peripheral/libmraa/examples/uart_ow.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation
- *
- * 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 "stdio.h"
-//! [Interesting]
-#include "mraa.h"
-
-int
-main(int argc, char** argv)
-{
- mraa_uart_ow_context uart;
- uart = mraa_uart_ow_init(0);
-
- if (!uart) {
- printf("mraa_uart_ow_init() failed\n");
- return 1;
- }
-
- // Reset the ow bus and see if anything is present
- mraa_result_t rv;
-
- if ((rv = mraa_uart_ow_reset(uart)) == MRAA_SUCCESS) {
- printf("Reset succeeded, device(s) detected!\n");
- } else {
- printf("Reset failed, returned %d. No devices on bus?\n", rv);
- return 1;
- }
-
- printf("Looking for devices...\n");
- uint8_t id[MRAA_UART_OW_ROMCODE_SIZE];
-
- /* we are essentially doing a binary tree search through the 64
- * bit address space. id is modified during this search, and will
- * be set to the valid rom code for each device found.
- */
-
- uint8_t count = 0;
-
- // start the search from scratch
- mraa_result_t result = mraa_uart_ow_rom_search(uart, 1, id);
- if (result == MRAA_ERROR_UART_OW_NO_DEVICES) {
- printf("No devices detected.\n");
- return 1;
- }
-
- if (result == MRAA_ERROR_UART_OW_DATA_ERROR) {
- printf("Bus/Data error.\n");
- return 1;
- }
-
- while (result == MRAA_SUCCESS) {
- /* The first byte (id[0]]) is the device type (family) code.
- * The last byte (id[7]) is the rom code CRC value. The
- * intervening bytes (id[1]-id[6]) are the unique 48 bit
- * device ID.
- */
- printf("Device %02d Type 0x%02x ID %02x%02x%02x%02x%02x%02x CRC 0x%02x\n", count, id[0],
- id[6], id[5], id[4], id[3], id[2], id[1], id[7]);
- count++;
-
- // continue the search with start argument set to 0
- result = mraa_uart_ow_rom_search(uart, 0, id);
- }
-
- printf("Exiting...\n");
-
- mraa_uart_ow_stop(uart);
-
- return 0;
-}
-//! [Interesting]
diff --git a/peripheral/libmraa/imraa/CMakeLists.txt b/peripheral/libmraa/imraa/CMakeLists.txt
deleted file mode 100644
index a5c9156..0000000
--- a/peripheral/libmraa/imraa/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-add_executable (imraa imraa.c)
-
-include_directories (${PROJECT_SOURCE_DIR}/api)
-include_directories (${PROJECT_SOURCE_DIR}/include)
-include_directories (${PROJECT_SOURCE_DIR}/api/mraa)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
-
-find_package (JSON-C REQUIRED)
-include_directories (${JSON-C_INCLUDE_DIR})
-find_package (UDEV REQUIRED)
-include_directories (${UDEV_INCLUDE_DIR})
-target_link_libraries (imraa mraa ${JSON-C_LIBRARIES} ${UDEV_LIBRARIES})
-
-set_property (TARGET imraa PROPERTY C_STANDARD 99)
-
-install (TARGETS imraa DESTINATION bin)
diff --git a/peripheral/libmraa/imraa/imraa.c b/peripheral/libmraa/imraa/imraa.c
deleted file mode 100644
index 8fd8c50..0000000
--- a/peripheral/libmraa/imraa/imraa.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Author: Longwei Su <lsu@ics.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <json-c/json.h>
-#include <libudev.h>
-
-#include <mraa/uart.h>
-#include <mraa/gpio.h>
-#include <mraa/i2c.h>
-#include <mraa/pwm.h>
-
-#include <mraa_internal.h>
-
-#define IMRAA_CONF_FILE "/etc/imraa.conf"
-
-typedef struct mraa_io_objects_t {
- const char* type;
- int index;
- bool raw;
- const char* label;
-} mraa_io_objects_t;
-
-const char*
-imraa_list_serialport()
-{
- struct udev* udev;
- struct udev_enumerate* enumerate;
- struct udev_list_entry *devices, *dev_list_entry;
- struct udev_device* dev;
- const char* ret = NULL;
- udev = udev_new();
- if (!udev) {
- printf("Can't create udev, check libudev\n");
- exit(1);
- }
- enumerate = udev_enumerate_new(udev);
- udev_enumerate_add_match_subsystem(enumerate, "tty");
- udev_enumerate_add_match_property(enumerate, "ID_VENDOR_ID", "8087");
- udev_enumerate_add_match_property(enumerate, "ID_MODEL_ID", "0ab6");
- // udev_enumerate_add_match_property(enumerate, "ID_SERIAL",
- // "Intel_ARDUINO_101_AE6642SQ55000RS");
- udev_enumerate_scan_devices(enumerate);
- devices = udev_enumerate_get_list_entry(enumerate);
-
- udev_list_entry_foreach(dev_list_entry, devices)
- {
- const char* path;
- path = udev_list_entry_get_name(dev_list_entry);
- dev = udev_device_new_from_syspath(udev, path);
- ret = udev_device_get_devnode(dev);
- }
- udev_enumerate_unref(enumerate);
- udev_unref(udev);
-
- if (ret) {
- printf("Ardunio 101 Device Node Path: %s\n", ret);
- } else {
- printf("Can't detect any Ardunio 101 Device on tty\n");
- }
- return ret;
-}
-
-mraa_result_t
-imraa_reset_arduino(const char* modem)
-{
- mraa_uart_context uart;
- uart = mraa_uart_init_raw(modem);
- mraa_uart_set_baudrate(uart, 1200);
-
- if (uart == NULL) {
- fprintf(stderr, "UART failed to setup\n");
- return MRAA_ERROR_UNSPECIFIED;
- }
- mraa_uart_stop(uart);
- mraa_deinit();
- return MRAA_SUCCESS;
-}
-
-int
-imraa_flash_101(const char* bin_path, const char* bin_file_name, const char* tty)
-{
- if (imraa_reset_arduino(tty) != MRAA_SUCCESS) {
- fprintf(stderr, "Failed to reset arduino on %s for unknown reason, carrying on...\n", tty);
- }
-
- char* ln = NULL;
- size_t len = 0;
- bool board_found = false;
- const char* dfu_list = "/dfu-util -d ,8087:0ABA -l";
- size_t bin_path_len = strlen(bin_path);
-
- char* full_dfu_list = (char*) calloc((bin_path_len + strlen(dfu_list) + 1), sizeof(char));
- if (!full_dfu_list) {
- printf("imraa_flash_101 can't allocate string buffer for dfu list\n");
- exit(1);
- }
- strncat(full_dfu_list, bin_path, strlen(bin_path));
- strncat(full_dfu_list, dfu_list, strlen(dfu_list));
-
- int i;
- // dfu list is still needed, as the time for reset and recognized is varies from platform to
- // platform.
- // once dfu able to query available devices, then it is ready to flash
- for (i = 0; i < 10 && board_found == false; i++) {
- printf("Waiting for device...\n");
- // dfu-util -d,8087:0ABA -l
- FILE* dfu_result = popen(full_dfu_list, "r");
- if (dfu_result == NULL) {
- printf("Failed to run command\n");
- exit(1);
- }
-
- if (i == 4) {
- printf("Flashing is taking longer than expected\n");
- printf("Try pressing MASTER_RESET button\n");
- }
-
- while (getline(&ln, &len, dfu_result) != -1) {
- if (strstr(ln, "sensor_core")) {
- board_found = true;
- printf("Device found!\n");
- break;
- }
- }
- sleep(1);
- if (pclose(dfu_result) != 0) {
- printf("Failed to close command\n");
- exit(1);
- }
- }
- free(ln);
-
- if (board_found == false) {
- printf("ERROR: Device is not responding.\n");
- exit(1);
- }
-
- const char* dfu_upload = "/dfu-util -d ,8087:0ABA -D ";
- const char* dfu_option = " -v -a 7 -R";
- int buffersize = bin_path_len + strlen(dfu_upload) + strlen(bin_file_name) + strlen(dfu_option) + 1;
- char* full_dfu_upload = calloc(buffersize, sizeof(char));
- if (!full_dfu_upload) {
- printf("imraa_flash_101 can't allocate string buffer for dfu flash\n");
- exit(1);
- }
- strncat(full_dfu_upload, bin_path, strlen(bin_path));
- strncat(full_dfu_upload, dfu_upload, strlen(dfu_upload));
- strncat(full_dfu_upload, bin_file_name, strlen(bin_file_name));
- strncat(full_dfu_upload, dfu_option, strlen(dfu_option));
- printf("flash cmd: %s\n", full_dfu_upload);
- int status = system(full_dfu_upload);
- if (status != 0) {
- printf("ERROR: Upload failed on %s\n", tty);
- exit(1);
- }
- printf("SUCCESS: Sketch will execute in about 5 seconds.\n");
- free(full_dfu_list);
- free(full_dfu_upload);
- sleep(5);
- return 0;
-}
-
-void
-imraa_write_lockfile(const char* lock_file_location, const char* serialport)
-{
- FILE* fh;
- char str[10];
- json_object* platform1 = json_object_new_object();
- snprintf(str, 10, "%d", MRAA_NULL_PLATFORM);
- json_object_object_add(platform1, "id", json_object_new_string(str));
-
- json_object* platform2 = json_object_new_object();
- snprintf(str, 10, "%d", MRAA_GENERIC_FIRMATA);
- json_object_object_add(platform2, "id", json_object_new_string(str));
- json_object_object_add(platform2, "uart", json_object_new_string(serialport));
-
- json_object* platfroms = json_object_new_array();
- json_object_array_add(platfroms, platform1);
- json_object_array_add(platfroms, platform2);
- json_object* lock_file = json_object_new_object();
- json_object_object_add(lock_file, "Platform", platfroms);
- fh = fopen(lock_file_location, "w");
- if (fh != NULL) {
- fputs(json_object_to_json_string_ext(lock_file, JSON_C_TO_STRING_PRETTY), fh);
- fclose(fh);
- } else {
- fprintf(stderr, "can't write to lock file\n");
- }
- json_object_put(lock_file);
-}
-
-void
-imraa_handle_subplatform(struct json_object* jobj, bool force_update)
-{
- struct json_object* platform;
- int i, ionum;
- const char* dfu_loc = NULL;
- const char* lockfile_loc = NULL;
- const char* flash_loc = NULL;
- const char* usbserial = NULL;
-
- struct json_object* dfu_location;
- if (json_object_object_get_ex(jobj, "dfu-utils-location", &dfu_location) == true) {
- if (json_object_is_type(dfu_location, json_type_string)) {
- printf("dfu location: %s\n", json_object_get_string(dfu_location));
- dfu_loc = json_object_get_string(dfu_location);
- } else {
- fprintf(stderr, "dfu location string incorrectly parsed\n");
- }
- }
-
- struct json_object* lockfile_location;
- if (json_object_object_get_ex(jobj, "lockfile-location", &lockfile_location) == true) {
- if (json_object_is_type(lockfile_location, json_type_string)) {
- printf("lock file location: %s\n", json_object_get_string(lockfile_location));
- lockfile_loc = json_object_get_string(lockfile_location);
- } else {
- fprintf(stderr, "lock file string incorrectly parsed\n");
- }
- }
-
- if (json_object_object_get_ex(jobj, "Platform", &platform) == true) {
- if (json_object_is_type(platform, json_type_array)) {
- ionum = json_object_array_length(platform);
- for (i = 0; i < ionum; i++) {
- struct json_object* ioobj = json_object_array_get_idx(platform, i);
- json_object_object_foreach(ioobj, key, val)
- {
- if (strcmp(key, "flash") == 0) {
- flash_loc = json_object_get_string(val);
- }
- if (strcmp(key, "usbserial") == 0) {
- usbserial = json_object_get_string(val);
- }
- }
- }
- } else {
- fprintf(stderr, "platform string incorrectly parsed\n");
- }
- }
- if (flash_loc == NULL || usbserial == NULL ) {
- printf("conf didn't give image location or usb serial, skip flashing\n");
- return;
- }
- if (!dfu_loc) {
- dfu_loc = "/usr/bin";
- printf("No dfu path found, using default path /usr/bin instead");
- }
- if (!lockfile_loc) {
- lockfile_loc = "/tmp/imraa.lock";
- printf("No lock path found, using default lock file /tmp/imraa.lock instead");
- }
-
- // got flash? do flash
- if (access(lockfile_loc, F_OK) != -1 && force_update == false) {
- printf("already exist a lock file, skip flashing\n");
- printf("force upgrade? remove the lockfile or run with force\n", lockfile_loc);
- return;
- } else {
- fprintf(stdout, "Starting to flash board\n");
- if (force_update) {
- fprintf(stdout, "**Caution: force update mode**\n");
- }
-
- // TODO flash img checksum, and serialport validation?
- const char* detected_serialport = imraa_list_serialport();
- if (detected_serialport == NULL) {
- printf("No subplatform detected, check USB connection, skip flashing\n");
- return;
- }
- if (strcmp(usbserial, "auto") != 0 && strcmp(usbserial, detected_serialport) != 0) {
- printf("given serial port didn't match detected serial port, skip flashing\n");
- return;
- }
- if (imraa_flash_101(dfu_loc, flash_loc, detected_serialport) == 0) {
- imraa_write_lockfile(lockfile_loc, detected_serialport);
- } else {
- fprintf(stderr, "invalid flashing paramenters, please check agian\n");
- fprintf(stderr, "DFU Util location: %s\n", dfu_loc);
- fprintf(stderr, "Flash Img location: %s\n", dfu_loc);
- fprintf(stderr, "USB Serial: %s\n", usbserial);
- fprintf(stderr, "Flash failed, push master reset and try again\n");
- }
- }
-}
-
-void
-imraa_handle_IO(struct json_object* jobj)
-{
- struct mraa_io_objects_t* mraa_io_obj;
- struct json_object* ioarray;
- int ionum = 0;
- int i;
- if (json_object_object_get_ex(jobj, "IO", &ioarray) == true) {
- ionum = json_object_array_length(ioarray);
- printf("Length of IO array is %d\n", ionum);
- mraa_io_obj = (mraa_io_objects_t*) malloc(ionum * sizeof(mraa_io_objects_t));
- if (!mraa_io_obj) {
- printf("imraa_handle_IO malloc failed\n");
- exit(1);
- }
- int index2 = -1;
- ; // optional index for io configuration;
- if (json_object_is_type(ioarray, json_type_array)) {
- for (i = 0; i < ionum; i++) {
- struct json_object* ioobj = json_object_array_get_idx(ioarray, i);
- struct json_object* x;
- if (json_object_object_get_ex(ioobj, "type", &x) == true) {
- mraa_io_obj[i].type = json_object_get_string(x);
- }
- if (json_object_object_get_ex(ioobj, "index", &x) == true) {
- mraa_io_obj[i].index = json_object_get_int(x);
- }
- if (json_object_object_get_ex(ioobj, "raw", &x) == true) {
- mraa_io_obj[i].raw = json_object_get_boolean(x);
- }
- if (json_object_object_get_ex(ioobj, "label", &x) == true) {
- mraa_io_obj[i].label = json_object_get_string(x);
- }
- if (json_object_object_get_ex(ioobj, "index2", &x) == true) {
- index2 = json_object_get_int(x);
- }
- // starting io configuration
- if (strcmp(mraa_io_obj[i].type, "gpio") == 0) {
- mraa_gpio_context gpio = NULL;
- if (mraa_io_obj[i].raw) {
- gpio = mraa_gpio_init_raw(mraa_io_obj[i].index);
- } else {
- gpio = mraa_gpio_init(mraa_io_obj[i].index);
- }
- if (gpio != NULL) {
- mraa_result_t r = mraa_gpio_owner(gpio, 0);
- if (r != MRAA_SUCCESS) {
- mraa_result_print(r);
- }
- mraa_gpio_close(gpio);
- }
- } else if (strcmp(mraa_io_obj[i].type, "i2c") == 0) {
- mraa_i2c_context i2c = NULL;
- if (mraa_io_obj[i].raw) {
- i2c = mraa_i2c_init_raw(mraa_io_obj[i].index);
- } else {
- i2c = mraa_i2c_init(mraa_io_obj[i].index);
- }
- if (i2c != NULL) {
- mraa_i2c_stop(i2c);
- }
- } else if (strcmp(mraa_io_obj[i].type, "pwm") == 0) {
- mraa_pwm_context pwm = NULL;
- if (mraa_io_obj[i].raw) {
- pwm = mraa_pwm_init_raw(index2, mraa_io_obj[i].index);
- } else {
- pwm = mraa_pwm_init(mraa_io_obj[i].index);
- }
- if (pwm != NULL) {
- mraa_result_t r = mraa_pwm_owner(pwm, 0);
- if (r != MRAA_SUCCESS) {
- mraa_result_print(r);
- }
- mraa_pwm_close(pwm);
- }
- } else if (strcmp(mraa_io_obj[i].type, "spi") == 0) {
- mraa_spi_context spi = NULL;
- if (mraa_io_obj[i].raw) {
- spi = mraa_spi_init_raw(mraa_io_obj[i].index, index2);
- } else {
- spi = mraa_spi_init(mraa_io_obj[i].index);
- }
- if (spi != NULL) {
- mraa_spi_stop(spi);
- }
- } else if (strcmp(mraa_io_obj[i].type, "uart") == 0) {
- mraa_uart_context uart = NULL;
- if (mraa_io_obj[i].raw) {
- uart = mraa_uart_init_raw(mraa_io_obj[i].label);
- } else {
- uart = mraa_uart_init(mraa_io_obj[i].index);
- }
- if (uart != NULL) {
- mraa_uart_stop(uart);
- }
- }
- }
- } else {
- fprintf(stderr, "IO array incorrectly parsed\n");
- }
- free(mraa_io_obj);
- }
-}
-
-int
-check_version(struct json_object* jobj)
-{
- struct json_object* imraa_version;
- if (json_object_object_get_ex(jobj, "version", &imraa_version) == true) {
- if (json_object_is_type(imraa_version, json_type_string)) {
- printf("imraa version is %s good\n", json_object_get_string(imraa_version));
- // TODO check version?
- } else {
- fprintf(stderr, "version string incorrectly parsed\n");
- return -1;
- }
- } else {
- fprintf(stderr, "no version specified\n");
- }
- return 0;
-}
-
-void
-print_version()
-{
- fprintf(stdout, "Version %s on %s\n", mraa_get_version(), mraa_get_platform_name());
-}
-
-void
-print_help()
-{
- fprintf(stdout, "version Get mraa version and board name\n");
- fprintf(stdout, "force Force update subplatform\n");
- fprintf(stdout, "conf_path Force update with override configuration\n");
-}
-
-void
-print_command_error()
-{
- fprintf(stdout, "Invalid command, options are:\n");
- print_help();
- exit(EXIT_FAILURE);
-}
-
-int
-main(int argc, char** argv)
-{
- char* buffer = NULL;
- char* imraa_conf_file = IMRAA_CONF_FILE;
- long fsize;
- bool force_update = false;
- int i = 0;
- uint32_t ionum = 0;
-
- if (argc > 2) {
- print_command_error();
- }
-
- if (argc > 1) {
- if (strcmp(argv[1], "help") == 0) {
- print_help();
- return EXIT_SUCCESS;
- } else if (strcmp(argv[1], "version") == 0) {
- print_version();
- return EXIT_SUCCESS;
- } else if (strcmp(argv[1], "force") == 0) {
- force_update = true;
- } else {
- imraa_conf_file = argv[1];
- force_update = true;
- }
- }
-
- FILE* fh = fopen(imraa_conf_file, "r");
- if (fh == NULL) {
- fprintf(stderr, "Failed to open configuration file\n");
- return EXIT_FAILURE;
- }
-
- fseek(fh, 0, SEEK_END);
- fsize = ftell(fh) + 1;
- fseek(fh, 0, SEEK_SET);
- buffer = calloc(fsize, sizeof(char));
- if (buffer != NULL) {
- int result = fread(buffer, sizeof(char), fsize, fh);
- if (result != fsize) {
- printf("imraa conf reading error");
- }
- } else {
- printf("imraa read_conf buffer can't allocated\n");
- exit(1);
- }
-
- imraa_init();
-
- json_object* jobj = json_tokener_parse(buffer);
- if (check_version(jobj) != 0) {
- printf("version of configuration file is not compatible, please check again\n");
- } else {
- mraa_platform_t type = mraa_get_platform_type();
- imraa_handle_subplatform(jobj, force_update);
- if (type == MRAA_NULL_PLATFORM || type == MRAA_UNKNOWN_PLATFORM) {
- printf("imraa: Failed to do IO pinmuxing on null/unkown platform\n");
- } else {
- imraa_handle_IO(jobj);
- }
- }
- fclose(fh);
- json_object_put(jobj);
- free(buffer);
- return EXIT_SUCCESS;
-}
diff --git a/peripheral/libmraa/imraa/imraa.conf b/peripheral/libmraa/imraa/imraa.conf
deleted file mode 100644
index 4316642..0000000
--- a/peripheral/libmraa/imraa/imraa.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "version": "0.9.6",
- "lockfile-location": "/tmp/imraa.lock",
- "dfu-utils-location": "/usr/bin",
- "Platform" :[
- {"id":"1280", "flash":"/usr/share/mraa/firmata101.ino.bin", "usbserial": "auto"}
- ],
- "IO": [
- {"type":"gpio", "index":0, "raw": false, "label": "none"},
- {"type":"i2c", "index":0, "raw": false, "label": "i2c-0"}
- ]
-}
diff --git a/peripheral/libmraa/imraa/imraa.service b/peripheral/libmraa/imraa/imraa.service
deleted file mode 100644
index 0b705c4..0000000
--- a/peripheral/libmraa/imraa/imraa.service
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=imraa
-
-[Service]
-Type=oneshot
-ExecStart=/usr/bin/imraa
-
-[Install]
-WantedBy = multi-user.target
diff --git a/peripheral/libmraa/include/firmata/firmata.h b/peripheral/libmraa/include/firmata/firmata.h
deleted file mode 100644
index 72961cb..0000000
--- a/peripheral/libmraa/include/firmata/firmata.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- * Copyright (c) 2015 Jules Dourlens (jdourlens@gmail.com)
- *
- * 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 "uart.h"
-
-#define MODE_INPUT 0x00
-#define MODE_OUTPUT 0x01
-#define MODE_ANALOG 0x02
-#define MODE_PWM 0x03
-#define MODE_SERVO 0x04
-#define MODE_SHIFT 0x05
-#define MODE_I2C 0x06
-
-#define LOW 0
-#define HIGH 1
-
-#define FIRMATA_START_SYSEX 0xF0 // start a MIDI Sysex message
-#define FIRMATA_END_SYSEX 0xF7 // end a MIDI Sysex message
-#define FIRMATA_PIN_MODE_QUERY 0x72 // ask for current and supported pin modes
-#define FIRMATA_PIN_MODE_RESPONSE 0x73 // reply with current and supported pin modes
-#define FIRMATA_PIN_STATE_QUERY 0x6D
-#define FIRMATA_PIN_STATE_RESPONSE 0x6E
-#define FIRMATA_CAPABILITY_QUERY 0x6B
-#define FIRMATA_CAPABILITY_RESPONSE 0x6C
-#define FIRMATA_ANALOG_MAPPING_QUERY 0x69
-#define FIRMATA_ANALOG_MAPPING_RESPONSE 0x6A
-
-#define FIRMATA_DIGITAL_MESSAGE 0x90 // send data for a digital pin
-#define FIRMATA_ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM)
-#define FIRMATA_ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM)
-#define FIRMATA_REPORT_ANALOG 0xC0 // enable analog input by pin #
-#define FIRMATA_REPORT_DIGITAL 0xD0 // enable digital input by port pair
-
-#define FIRMATA_I2C_CONFIG 0x78
-#define FIRMATA_I2C_REPLY 0x77
-#define FIRMATA_I2C_REQUEST 0x76
-
-#define I2C_MODE_WRITE 0x00
-#define I2C_MODE_READ 0x01
-#define I2C_CONTINUOUSREAD 0x02
-#define I2C_STOP_READING 0x03
-
-#define FIRMATA_SET_PIN_MODE 0xF4 // set a pin to INPUT/OUTPUT/PWM/etc
-
-#define FIRMATA_REPORT_VERSION 0xF9 // report protocol version
-#define FIRMATA_SYSTEM_RESET 0xFF // reset from MIDI
-
-#define FIRMATA_START_SYSEX 0xF0 // start a MIDI Sysex message
-#define FIRMATA_END_SYSEX 0xF7 // end a MIDI Sysex message
-
-// extended command set using sysex (0-127/0x00-0x7F)
-/* 0x00-0x0F reserved for custom commands */
-#define FIRMATA_SERVO_CONFIG 0x70 // set max angle, minPulse, maxPulse, freq
-#define FIRMATA_STRING 0x71 // a string message with 14-bits per char
-#define FIRMATA_REPORT_FIRMWARE 0x79 // report name and version of the firmware
-#define FIRMATA_SYSEX_NON_REALTIME 0x7E // MIDI Reserved for non-realtime messages
-#define FIRMATA_SYSEX_REALTIME 0x7F // MIDI Reserved for realtime messages
-
-#define FIRMATA_MSG_LEN 1024
-
-typedef struct s_pin {
- uint8_t mode;
- uint8_t analog_channel;
- uint64_t supported_modes;
- uint32_t value;
-} t_pin;
-
-typedef struct s_firmata {
- mraa_uart_context uart;
- t_pin pins[128];
- int i2cmsg[256][256];
- int parse_command_len;
- int parse_count;
- uint8_t parse_buff[FIRMATA_MSG_LEN];
- int isReady;
- char firmware[140];
- uint8_t dev_count;
- struct _firmata** devs;
-} t_firmata;
-
-t_firmata* firmata_new(const char* name);
-void firmata_initPins(t_firmata* firmata);
-int firmata_askFirmware(t_firmata* firmata);
-int firmata_pinMode(t_firmata* firmata, int pin, int mode);
-int firmata_digitalWrite(t_firmata* firmata, int pin, int value);
-int firmata_analogWrite(t_firmata* firmata, int pin, int value);
-int firmata_analogRead(t_firmata* firmata, int pin);
-int firmata_pull(t_firmata* firmata);
-void firmata_parse(t_firmata* firmata, const uint8_t* buf, int len);
-void firmata_endParse(t_firmata* firmata);
-void firmata_close(t_firmata* firmata);
diff --git a/peripheral/libmraa/include/firmata/firmata_mraa.h b/peripheral/libmraa/include/firmata/firmata_mraa.h
deleted file mode 100644
index a80d73a..0000000
--- a/peripheral/libmraa/include/firmata/firmata_mraa.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mraa_internal.h"
-
-mraa_platform_t mraa_firmata_platform(mraa_board_t* board, const char* uart_dev);
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/peripheral/libmraa/include/java/mraajni.h b/peripheral/libmraa/include/java/mraajni.h
deleted file mode 100644
index 887b9c5..0000000
--- a/peripheral/libmraa/include/java/mraajni.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014-2016 Intel Corporation.
- *
- * 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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <jni.h>
-#include "mraa/types.h"
-
-// location for defining JNI version to use
-#define JNI_REQUIRED_VERSION JNI_VERSION_1_6
-
-void mraa_java_set_jvm(JavaVM* vm);
-void mraa_java_isr_callback(void* args);
-mraa_result_t mraa_java_attach_thread();
-void mraa_java_detach_thread();
-void* mraa_java_create_global_ref(void* args);
-void mraa_java_delete_global_ref(void* ref);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/peripheral/libmraa/include/mraa_adv_func.h b/peripheral/libmraa/include/mraa_adv_func.h
index ea7fe98..b33fc36 100644
--- a/peripheral/libmraa/include/mraa_adv_func.h
+++ b/peripheral/libmraa/include/mraa_adv_func.h
@@ -37,7 +37,6 @@ typedef struct {
mraa_result_t (*gpio_init_post) (mraa_gpio_context dev);
mraa_result_t (*gpio_close_pre) (mraa_gpio_context dev);
- mraa_result_t (*gpio_close_replace) (mraa_gpio_context dev);
mraa_result_t (*gpio_mode_replace) (mraa_gpio_context dev, mraa_gpio_mode_t mode);
mraa_result_t (*gpio_mode_pre) (mraa_gpio_context dev, mraa_gpio_mode_t mode);
@@ -64,9 +63,9 @@ typedef struct {
mraa_result_t (*i2c_set_frequency_replace) (mraa_i2c_context dev, mraa_i2c_mode_t mode);
mraa_result_t (*i2c_address_replace) (mraa_i2c_context dev, uint8_t addr);
int (*i2c_read_replace) (mraa_i2c_context dev, uint8_t* data, int length);
- int (*i2c_read_byte_replace) (mraa_i2c_context dev);
- int (*i2c_read_byte_data_replace) (mraa_i2c_context dev, const uint8_t command);
- int (*i2c_read_word_data_replace) (mraa_i2c_context dev, const uint8_t command);
+ uint8_t (*i2c_read_byte_replace) (mraa_i2c_context dev);
+ uint8_t (*i2c_read_byte_data_replace) (mraa_i2c_context dev, const uint8_t command);
+ uint16_t (*i2c_read_word_data_replace) (mraa_i2c_context dev, const uint8_t command);
int (*i2c_read_bytes_data_replace) (mraa_i2c_context dev, uint8_t command, uint8_t* data, int length);
mraa_result_t (*i2c_write_replace) (mraa_i2c_context dev, const uint8_t* data, int length);
mraa_result_t (*i2c_write_byte_replace) (mraa_i2c_context dev, uint8_t data);
@@ -74,22 +73,14 @@ typedef struct {
mraa_result_t (*i2c_write_word_data_replace) (mraa_i2c_context dev, const uint16_t data, const uint8_t command);
mraa_result_t (*i2c_stop_replace) (mraa_i2c_context dev);
- mraa_result_t (*aio_init_internal_replace) (mraa_aio_context dev, int pin);
- int (*aio_read_replace) (mraa_aio_context dev);
mraa_result_t (*aio_get_valid_fp) (mraa_aio_context dev);
mraa_result_t (*aio_init_pre) (unsigned int aio);
mraa_result_t (*aio_init_post) (mraa_aio_context dev);
mraa_pwm_context (*pwm_init_replace) (int pin);
- mraa_pwm_context (*pwm_init_internal_replace) (void* func_table, int pin);
mraa_result_t (*pwm_init_pre) (int pin);
mraa_result_t (*pwm_init_post) (mraa_pwm_context pwm);
mraa_result_t (*pwm_period_replace) (mraa_pwm_context dev, int period);
- float (*pwm_read_replace) (mraa_pwm_context dev);
- mraa_result_t (*pwm_write_replace) (mraa_pwm_context dev, float duty);
- mraa_result_t (*pwm_write_pre) (mraa_pwm_context dev, float percentage);
- mraa_result_t (*pwm_enable_replace) (mraa_pwm_context dev, int enable);
- mraa_result_t (*pwm_enable_pre) (mraa_pwm_context dev, int enable);
mraa_result_t (*spi_init_pre) (int bus);
mraa_result_t (*spi_init_post) (mraa_spi_context spi);
diff --git a/peripheral/libmraa/include/mraa_internal.h b/peripheral/libmraa/include/mraa_internal.h
index edd65d8..428876d 100644
--- a/peripheral/libmraa/include/mraa_internal.h
+++ b/peripheral/libmraa/include/mraa_internal.h
@@ -34,11 +34,9 @@ extern "C" {
#include "common.h"
#include "mraa_internal_types.h"
#include "mraa_adv_func.h"
-#include "mraa_lang_func.h"
extern mraa_board_t* plat;
extern mraa_iio_info_t* plat_iio;
-extern mraa_lang_func_t* lang_func;
/**
* Takes in pin information and sets up the multiplexors.
@@ -132,24 +130,6 @@ mraa_boolean_t mraa_link_targets(const char* filename, const char* targetname);
*/
int mraa_find_i2c_bus(const char* devname, int startfrom);
-#if defined(IMRAA)
-/**
- * read Imraa subplatform lock file, caller is responsible to free return
- * struct array
- *
- * @param imraa lockfile location
- * @return the number of subplatforms added
- */
-uint32_t mraa_add_from_lockfile(const char* imraa_lock_file);
-
-/**
- * Internal imraa init function
- *
- * @return mraa_result_t indicating success
- */
-mraa_result_t imraa_init();
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/peripheral/libmraa/include/mraa_internal_types.h b/peripheral/libmraa/include/mraa_internal_types.h
index 2873d4a..de91e7c 100644
--- a/peripheral/libmraa/include/mraa_internal_types.h
+++ b/peripheral/libmraa/include/mraa_internal_types.h
@@ -1,7 +1,7 @@
/*
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2014-2016 Intel Corporation.
+ * Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -40,17 +40,6 @@
#define MRAA_IO_SETUP_FAILURE -2
#define MRAA_NO_SUCH_IO -1
-#ifdef FIRMATA
-struct _firmata {
- /*@*/
- uint8_t feature; /**< the feature */
- uint8_t index;
- void (* isr)(uint8_t*, int); /**< the feature response request */
- mraa_boolean_t added; /**< boolean to set if responses already set in devs array */
- /*@}*/
-};
-#endif
-
/**
* A structure representing a gpio pin.
*/
@@ -59,8 +48,8 @@ struct _gpio {
int pin; /**< the pin number, as known to the os. */
int phy_pin; /**< pin passed to clean init. -1 none and raw*/
int value_fp; /**< the file pointer to the value of the gpio */
- void (* isr)(void *); /**< the interrupt service request */
- void *isr_args; /**< args return when interrupt service request triggered */
+ void (* isr)(void *); /**< the interupt service request */
+ void *isr_args; /**< args return when interupt service request triggered */
pthread_t thread_id; /**< the isr handler thread id */
int isr_value_fp; /**< the isr file pointer on the value */
#ifndef HAVE_PTHREAD_CANCEL
@@ -148,9 +137,9 @@ struct _iio {
char* name; /**< IIO device name */
int fp; /**< IIO device in /dev */
int fp_event; /**< event file descriptor for IIO device */
- void (* isr)(char* data); /**< the interrupt service request */
- void *isr_args; /**< args return when interrupt service request triggered */
- void (* isr_event)(struct iio_event_data* data, void* args); /**< the event interrupt service request */
+ void (* isr)(char* data); /**< the interupt service request */
+ void *isr_args; /**< args return when interupt service request triggered */
+ void (* isr_event)(struct iio_event_data* data, void* args); /**< the event interupt service request */
int chan_num;
pthread_t thread_id; /**< the isr handler thread id */
mraa_iio_channel* channels;
@@ -175,31 +164,13 @@ typedef struct {
/*@}*/
} mraa_pincapabilities_t;
-
-/**
- * Pin commands definition for mraa_mux_t struc
- */
-
-typedef enum {
- PINCMD_UNDEFINED = 0, // do not modify, default command for zero value, used for backward compatibility with boards where pincmd is not defined (it will be deleted later)
- PINCMD_SET_VALUE = 1, // set a pin's value
- PINCMD_SET_DIRECTION = 2, // set a pin's direction (value like MRAA_GPIO_OUT, MRAA_GPIO_OUT_HIGH...)
- PINCMD_SET_IN_VALUE = 3, // set input direction and value
- PINCMD_SET_OUT_VALUE = 4, // set output direction and value
- PINCMD_SET_MODE = 5, // set pin's mode
- PINCMD_SKIP = 6 // just skip this command, do not apply pin and value
-} pincmd_t;
-
-
/**
* A Structure representing a multiplexer and the required value
*/
typedef struct {
/*@{*/
- unsigned int pincmd; /**< Pin command pincmd_xxxx */
- /**< At this time not all boards will support it -> TO DO */
- unsigned int pin; /**< Raw GPIO pin id */
- unsigned int value; /**< Raw GPIO value */
+ unsigned int pin; /**< Raw GPIO pin id */
+ unsigned int value; /**< Raw GPIO value */
/*@}*/
} mraa_mux_t;
@@ -218,6 +189,7 @@ typedef struct {
unsigned int mux_total; /** Numfer of muxes needed for operation of pin */
mraa_mux_t mux[6]; /** Array holding information about mux */
unsigned int output_enable; /** Output Enable GPIO, for level shifting */
+ unsigned int pullup_enable; /** Pull-Up enable GPIO, inputs */
mraa_pin_cap_complex_t complex_cap;
/*@}*/
} mraa_pin_t;
@@ -253,9 +225,9 @@ typedef struct {
*/
typedef struct {
/*@{*/
- int bus_id; /**< ID as exposed in the system */
- int scl; /**< i2c SCL */
- int sda; /**< i2c SDA */
+ unsigned int bus_id; /**< ID as exposed in the system */
+ unsigned int scl; /**< i2c SCL */
+ unsigned int sda; /**< i2c SDA */
// mraa_drv_api_t drv_type; /**< Driver type */
/*@}*/
} mraa_i2c_bus_t;
@@ -268,10 +240,10 @@ typedef struct {
unsigned int bus_id; /**< The Bus ID as exposed to the system. */
unsigned int slave_s; /**< Slave select */
mraa_boolean_t three_wire; /**< Is the bus only a three wire system */
- int sclk; /**< Serial Clock */
- int mosi; /**< Master Out, Slave In. */
- int miso; /**< Master In, Slave Out. */
- int cs; /**< Chip Select, used when the board is a spi slave */
+ unsigned int sclk; /**< Serial Clock */
+ unsigned int mosi; /**< Master Out, Slave In. */
+ unsigned int miso; /**< Master In, Slave Out. */
+ unsigned int cs; /**< Chip Select, used when the board is a spi slave */
/*@}*/
} mraa_spi_bus_t;
@@ -293,19 +265,19 @@ typedef struct {
typedef struct _board_t {
/*@{*/
- int phy_pin_count; /**< The Total IO pins on board */
+ unsigned int phy_pin_count; /**< The Total IO pins on board */
unsigned int gpio_count; /**< GPIO Count */
unsigned int aio_count; /**< Analog side Count */
- int i2c_bus_count; /**< Usable i2c Count */
+ unsigned int i2c_bus_count; /**< Usable i2c Count */
mraa_i2c_bus_t i2c_bus[12]; /**< Array of i2c */
unsigned int def_i2c_bus; /**< Position in array of default i2c bus */
- int spi_bus_count; /**< Usable spi Count */
+ unsigned int spi_bus_count; /**< Usable spi Count */
mraa_spi_bus_t spi_bus[12]; /**< Array of spi */
unsigned int def_spi_bus; /**< Position in array of defult spi bus */
unsigned int adc_raw; /**< ADC raw bit value */
unsigned int adc_supported; /**< ADC supported bit value */
unsigned int def_uart_dev; /**< Position in array of defult uart */
- int uart_dev_count; /**< Usable spi Count */
+ unsigned int uart_dev_count; /**< Usable spi Count */
mraa_uart_dev_t uart_dev[6]; /**< Array of UARTs */
mraa_boolean_t no_bus_mux; /**< i2c/spi/adc/pwm/uart bus muxing setup not required */
int pwm_default_period; /**< The default PWM period is US */
diff --git a/peripheral/libmraa/include/mraa_lang_func.h b/peripheral/libmraa/include/mraa_lang_func.h
deleted file mode 100644
index 9c11710..0000000
--- a/peripheral/libmraa/include/mraa_lang_func.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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
-
-typedef struct {
- void (*python_isr)(void (*isr)(void*), void* isr_args);
- void (*java_isr_callback)(void *args);
- mraa_result_t (*java_attach_thread)();
- void (*java_detach_thread)();
- void* (*java_create_global_ref)(void* args);
- void (*java_delete_global_ref)(void* ref);
-
-} mraa_lang_func_t;
diff --git a/peripheral/libmraa/include/python/mraapy.h b/peripheral/libmraa/include/python/mraapy.h
deleted file mode 100644
index d48fc4e..0000000
--- a/peripheral/libmraa/include/python/mraapy.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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
-
-void mraa_python_isr(void (*isr)(void*), void* isr_args);
diff --git a/peripheral/libmraa/include/x86/intel_gt_tuchuck.h b/peripheral/libmraa/include/x86/intel_gt_tuchuck.h
deleted file mode 100644
index 0e187ab..0000000
--- a/peripheral/libmraa/include/x86/intel_gt_tuchuck.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mraa_internal.h"
-
-// +1 as pins are "1 indexed"
-// we have 20 useless pins then the 4 LEDS and the 2 LEDs on the module.
-#define MRAA_INTEL_GT_TUCHUCK_PINCOUNT (40*2 + 23 +1 +2)
-
-mraa_board_t*
-mraa_gt_tuchuck_board();
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/peripheral/libmraa/jsstub/Gruntfile.js b/peripheral/libmraa/jsstub/Gruntfile.js
deleted file mode 100644
index acd3276..0000000
--- a/peripheral/libmraa/jsstub/Gruntfile.js
+++ /dev/null
@@ -1,17 +0,0 @@
-module.exports = function(grunt) {
- grunt.loadNpmTasks('grunt-mocha-test');
- // Project configuration.
- grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
- mochaTest: {
- test: {
- options: {
- reporter: 'spec'
- },
- src: ['test/*.js']
- }
- }
- });
-
- grunt.registerTask('test', ['mochaTest:test']);
-};
diff --git a/peripheral/libmraa/jsstub/README.md b/peripheral/libmraa/jsstub/README.md
deleted file mode 100644
index 05ac833..0000000
--- a/peripheral/libmraa/jsstub/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-mraaStub - JavaScript simulation and stubs for mraa
-====================
-
-This project enables simulation of a device which might be accessed via mraa.
-Currently this library supports I2c, SPI, and GPIO. This project provides
-several benefits:
-
-1. Prevent crashes in nodejs applications using mraa on unsuported or
- misconfigured hardware.
-2. Enable basic simulation of mraa-accessible devices for unit testing.
-
-## Examples
-
-The following example is based on an imaginary 'light bulb' device abstraction,
-which exposes a value of brightness over a mraa-provided interface. Please see
-the `test/index.js` file for an example.
-
-## Installation
-
-You may install `mraaStub` from npm like this:
-
-```
-npm install mraaStub
-```
-
-Since we often switch between a mraaStub and the real mraa library, we
-suggest creating an `index.js` file inside a `lib/mraaSwitcher` folder.
-
-```js
-/* index.js - file for switching between mraa and mraaStub
- */
-
-// Define the conditions under which the mraaStub should be loaded
-var platform = require('os').platform();
-var m;
-
-if (platform === 'win32') {
- m = require('mraaStub');
-} else {
- m = require('mraa');
-}
-
-module.exports = m;
-```
-
-You can add this to your project in its own `lib/mraaSwitcher/index.js` file
-and use `require('../mraaSwitcher')` everywhere!
-
-## License
-
-See [COPYING file](../COPYING) in the root of this repository.
diff --git a/peripheral/libmraa/jsstub/index.js b/peripheral/libmraa/jsstub/index.js
deleted file mode 100644
index ccf8520..0000000
--- a/peripheral/libmraa/jsstub/index.js
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- * @fileoverview This file implements a fake mraa stub which enables testing
- * as well as the ability to run on Windows.
- */
-
-var m;
-var winston = require('winston');
-var logger = new winston.Logger({
- transports: [
- new winston.transports.Console({
- level: 'error',
- handleExceptions: false,
- json: false,
- colorize: true})
- ],
- exitOnError: false
- });
-
-/**
- * @class mraaStub
- * @classdesc This class is designed to stub out libmraa so we can run
- * test code on unsupported platforms (specifically Windows).
- */
-var mraaStub = function() {
- var verison = '0.0.1';
- var self = this;
- self.EDGE_BOTH = 1;
- self.EDGE_NONE = 2;
- self.EDGE_RISING = 3;
- self.EDGE_FALLING = 4;
- self.DIR_IN = 1;
- self.DIR_OUT = 2;
-
- self.getVersion = function() {
- return "mraaStub " + version;
- };
-
- // Stub out GPIO
- function Gpio(num) {
- this.num = num;
- this._callback = null;
- this._dir = null;
- this._isr_mode = self.EDGE_NONE;
- }
-
- var logGpio = false;
- Gpio.prototype._callIsr = function() {
- if(this.isr_mode === self.EDGE_NONE) {
- logger.log('info',"Could not call ISR. Not set up for triggering");
- }
- this._callback();
- };
-
- Gpio.prototype.isr = function(mode, handler){
- if(logGpio) {
- logger.log('info',"GPIO " + this.num + " isr stub invoked.");
- }
- this._isr_mode = self.EDGE_NONE;
- this._callback = handler;
- };
-
- Gpio.prototype.dir = function(d) {
- if(logGpio) {
- logger.log('info',"GPIO " + this.num + " dir stub invoked.");
- }
- this._dir = d;
- };
- Gpio.prototype.write = function(z) {
- if(logGpio) {
- logger.log('logger',"GPIO " + this.num + " write stub invoked.");
- }
- if(this._dir !== self.DIR_OUT) {
- logger.log('info',"GPIO " + this.num + " write called without DIR_OUT set.");
- }
- };
- Gpio.prototype.read = function() {
- if(logGpio) {
- logger.log('info',"GPIO " + this.num + " read stub invoked.");
- }
- return 0;
- };
-
- // Stub out SPI
- function Spi(num) {
- var self = this;
- this.num = num;
- this._buffer = new Buffer(29);
- this._buffer.fill(0);
- this._loopback = false;
- }
-
- Spi.prototype._setOutput = function(buf) {
- this._buffer = buf;
- };
-
- Spi.prototype._enableLoopback = function(x) {
- if(x === true) {
- this._loopback = true;
- } else {
- this._loopback = false;
- }
- };
-
- Spi.prototype.write = function(b) {
- logger.log('info',"SPI write stub invoked.");
- if(this._loopback === true) {
- return b;
- }
- return new Buffer(this._buffer);
- };
-
- Spi.prototype.frequency = function(f) {
- logger.log('info',"SPI frequency stub invoked.");
- return f;
- };
-
- Spi.prototype.lsbmode = function(t) {
- logger.log('info',"SPI lsbmode stub invoked.");
- };
-
- Spi.prototype.mode = function(x) {
- logger.log('info',"SPI mode stub invoked.");
- };
-
- function I2c(num) {
- this._num = num;
- this._regMapInitialized = false;
- }
-
- /* This function sets an internal register map for the I2c device.
- */
- I2c.prototype._setRegisterMapInternal = function(buffer) {
- this._regMapInitialized = true;
- this._buffer = buffer;
- };
-
- I2c.prototype.frequency = function(freq) {
- // Do nothing. We don't care.
- };
-
- I2c.prototype.address = function(address) {
- var self = this;
- self.address = address;
- };
-
- I2c.prototype.readReg = function(regAddr) {
- if(!this._regMapInitialized) {
- logger.log('error', "Need to set reg map");
- }
- if(!this.address) {
- logger.log('error', "Need to set address");
- }
-
- return this._buffer.readUInt8(regAddr);
- };
-
- I2c.prototype.readWordReg = function(regAddr) {
- if(!this._regMapInitialized) {
- logger.log('error', "Need to set reg map");
- }
- if(!this.address) {
- logger.log('error', "Need to set address");
- }
-
- return this._buffer.readUInt16LE(regAddr);
- };
-
- I2c.prototype.readBytesReg = function(regAddr, len) {
- if(!this._regMapInitialized) {
- logger.log('error', "Need to set reg map");
- }
- if(!this.address) {
- logger.log('error', "Need to set address");
- }
-
- return this._buffer.slice(regAddr,regAddr+len);
- };
-
- I2c.prototype.write = function(buf) {
- if(!this._regMapInitialized) {
- logger.log('error', "Need to set reg map");
- }
- if(!this.address) {
- logger.log('error', "Need to set address");
- }
-
- var regAddr = buf[0];
- var newBuf = buf.slice(1);
- newBuf.copy(this._buffer, regAddr);
- };
-
- I2c.prototype.writeReg = function(regAddr, data) {
- if(!this._regMapInitialized) {
- logger.log('error', "Need to set reg map");
- }
- if(!this.address) {
- logger.log('error', "Need to set address");
- }
-
- this._buffer.writeUInt8(regAddr,data);
- };
-
- I2c.prototype.writeWordReg = function(regAddr, dataWord) {
- if(!this._regMapInitialized) {
- logger.log('error', "Need to set reg map");
- }
- if(!this.address) {
- logger.log('error', "Need to set address");
- }
-
- this._buffer.writeUInt16LE(regAddr,data);
- };
-
- // Export our stubs
- self.Gpio = Gpio;
- self.Spi = Spi;
- self.I2c = I2c;
-
-};
-
-m = new mraaStub();
-
-module.exports = m;
diff --git a/peripheral/libmraa/jsstub/package.json b/peripheral/libmraa/jsstub/package.json
deleted file mode 100644
index 121261b..0000000
--- a/peripheral/libmraa/jsstub/package.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "name": "mraaStub",
- "version": "0.0.1",
- "description": "Enables simulation of mraa interfaces for testing purposes",
- "main": "index.js",
- "scripts": {
- "test": "grunt test"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/intel-iot-devkit/mraa.git"
- },
- "keywords": [
- "mraa",
- "iot",
- "intel",
- "libmraa",
- "test",
- "galileo",
- "edison"
- ],
- "author": "David A Antler <david.a.antler@intel.com>",
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/intel-iot-devkit/mraa/issues"
- },
- "homepage": "https://github.com/intel-iot-devkit/mraa#readme",
- "devDependencies": {
- "expect.js": "^0.3.1",
- "grunt": "^1.0.1",
- "grunt-mocha-test": "^0.12.7",
- "mocha": "^2.4.5"
- }
-}
diff --git a/peripheral/libmraa/jsstub/test/index.js b/peripheral/libmraa/jsstub/test/index.js
deleted file mode 100644
index 47d7657..0000000
--- a/peripheral/libmraa/jsstub/test/index.js
+++ /dev/null
@@ -1,32 +0,0 @@
-var expect = require('expect.js');
-var m = require('../index');
-var LightBulb = require('./lightbulb');
-
-describe('LightBulb', function() {
-
- /** Model the internal data of LightBulb as a buffer */
- var bufferFullBrightness = new Buffer(
- [ 'N', // Four bytes allocated for name
- 'a',
- 'm',
- 'e',
- 95 // One byte allocated for brightness. Stuff in '95' value!
- ]);
-
- it('getBrightness() function should return 95', function() {
-
- // Create a fake I2c bus based on the 'full brightness' data model
- var testI2cBus = new m.I2c(0);
- testI2cBus._setRegisterMapInternal(bufferFullBrightness);
-
- // Create a new LightBulb that opens the testI2cBus, instead of a real
- // mraa I2c bus.
- var lightBulbI2c = new LightBulb(testI2cBus);
-
- // presumably getBrightness will gather data from I2C and get '95'
- var brightness = lightBulbI2c.getBrightness();
-
- expect(brightness).to.be(95);
- })
-});
-
diff --git a/peripheral/libmraa/jsstub/test/lightbulb.js b/peripheral/libmraa/jsstub/test/lightbulb.js
deleted file mode 100644
index f05ba57..0000000
--- a/peripheral/libmraa/jsstub/test/lightbulb.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* @fileoverview Implementation of a LightBulb class abstraction
-*
-*/
-
-module.exports = (function() {
- "use strict";
- var m = require('../index');
-
- /**
- * Constructor for a new LightBulb
- * @class LightBulb
- *
- * @classdesc This class abstracts access to the control and data registers
- * on an imaginary lightbulb.
- * @param {Object} A libmraa I2c object, initialized
- */
- function LightBulb (i2cInterface) {
- var self = this;
- self._i2cInterface = i2cInterface;
-
- self.getBrightness = function() {
- // Presume our brightness data is one byte at offset 4
- return self._i2cInterface.readReg(4);
- }
-
- return self;
- }
-
- return LightBulb;
-})();
-
diff --git a/peripheral/libmraa/src/CMakeLists.txt b/peripheral/libmraa/src/CMakeLists.txt
index 0f5adb2..a37b7f0 100644
--- a/peripheral/libmraa/src/CMakeLists.txt
+++ b/peripheral/libmraa/src/CMakeLists.txt
@@ -4,16 +4,6 @@ set (mraa_LIB_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/include
)
-if (FIRMATA)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFIRMATA=1")
- add_subdirectory (firmata)
-endif ()
-
-if (ONEWIRE)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DONEWIRE=1")
- add_subdirectory (uart_ow)
-endif ()
-
include_directories(
${mraa_LIB_INCLUDE_DIRS}
)
@@ -27,7 +17,6 @@ set (mraa_LIB_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/aio/aio.c
${PROJECT_SOURCE_DIR}/src/uart/uart.c
${PROJECT_SOURCE_DIR}/src/iio/iio.c
- ${mraa_LIB_SRCS_NOAUTO}
)
set (mraa_LIB_X86_SRCS_NOAUTO
@@ -41,10 +30,9 @@ set (mraa_LIB_X86_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/x86/intel_sofia_3gr.c
${PROJECT_SOURCE_DIR}/src/x86/intel_cherryhills.c
${PROJECT_SOURCE_DIR}/src/x86/up.c
- ${PROJECT_SOURCE_DIR}/src/x86/intel_gt_tuchuck.c
)
-message (STATUS "INFO - Adding support for platform ${MRAAPLATFORMFORCE}")
+message (INFO " - Adding support for platform ${MRAAPLATFORMFORCE}")
#keywords in if statements are case sensitive
if (NOT ${MRAAPLATFORMFORCE} STREQUAL "ALL")
@@ -67,13 +55,11 @@ if (NOT ${MRAAPLATFORMFORCE} STREQUAL "ALL")
set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_cherryhills.c)
elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_UP")
set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/up.c)
- elseif( ${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_GT_TUCHUCK")
- set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_gt_tuchuck.c)
else ()
- message (FATAL_ERROR "Unknown x86 platform enabled!")
+ message (ERROR " - Unknown x86 platform enabled!")
endif ()
else ()
- message (STATUS "INFO - Adding support for all platforms")
+ message (INFO " - Adding support for all platforms")
endif ()
set (mraa_LIB_ARM_SRCS_NOAUTO
@@ -97,7 +83,7 @@ if (ARMPLAT)
endif()
if (USBPLAT)
- message (STATUS "INFO - Adding USB platforms")
+ message (INFO " - Adding USB platforms")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
if (FTDID2xx)
find_package (Ftd2xx)
@@ -105,7 +91,7 @@ if (USBPLAT)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDID2XX=1")
set (mraa_LIBS ${mraa_LIBS} ${LIBFTD2XX_LIBRARIES})
else ()
- message (SEND_ERROR "Enabled FTDID2xx support but library not found")
+ message (WARNING " - Enabled FTDID2xx support but library not found")
endif ()
endif ()
if (FTDI4222)
@@ -114,19 +100,12 @@ if (USBPLAT)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTDI4222=1")
set (mraa_LIBS ${mraa_LIBS} dl)
else ()
- message (SEND_ERROR "Enabled FTDI4222 support but library not found")
+ message (WARNING " - Enabled FTDI4222 support but library not found")
endif ()
endif ()
add_subdirectory(usb)
endif ()
-if (IMRAA)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
- find_package (JSON-C REQUIRED)
- include_directories (${JSON-C_INCLUDE_DIR})
- set (mraa_LIBS ${mraa_LIBS} ${JSON-C_LIBRARIES})
-endif ()
-
set (mraa_LIB_SRCS
${mraa_LIB_PLAT_SRCS_NOAUTO}
# autogenerated version file
@@ -138,6 +117,17 @@ set (mraa_LIB_GLOB_HEADERS
${PROJECT_SOURCE_DIR}/api/mraa.hpp
)
+add_library (mraa ${mraa_LIB_SRCS})
+
+
+target_link_libraries (mraa ${mraa_LIBS})
+
+set_target_properties(
+ mraa
+ PROPERTIES
+ SOVERSION ${mraa_VERSION_MAJOR}
+ VERSION ${mraa_VERSION_STRING}
+)
install (FILES ${mraa_LIB_GLOB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/mraa/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mraa)
@@ -145,8 +135,9 @@ macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro (mraa_CREATE_INSTALL_PKGCONFIG)
-mraa_create_install_pkgconfig (mraa.pc ${LIB_INSTALL_DIR}/pkgconfig)
+mraa_create_install_pkgconfig (mraa.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR})
if (DOXYGEN_FOUND)
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
@@ -196,26 +187,14 @@ if (BUILDSWIG)
add_subdirectory (python)
endif ()
if (BUILDSWIGJAVA)
- configure_file (${CMAKE_CURRENT_SOURCE_DIR}/java/manifest.txt.in
- ${CMAKE_CURRENT_BINARY_DIR}/java/manifest.txt)
add_subdirectory (java)
endif ()
if (BUILDSWIGNODE)
if (SWIG_VERSION VERSION_GREATER 3.0.4)
add_subdirectory (javascript)
else ()
- message (SEND_ERROR "SWIG is ${SWIG_VERSION}. Please upgrade to 3.0.5+ to build nodejs addon")
+ message ("WARN - SWIG is ${SWIG_VERSION}. Please upgrade to 3.0.5+ to build nodejs addon")
endif ()
endif ()
endif ()
endif ()
-
-add_library (mraa ${mraa_LIB_SRCS})
-target_link_libraries (mraa ${mraa_LIBS})
-set_target_properties(
- mraa
- PROPERTIES
- SOVERSION ${mraa_VERSION_MAJOR}
- VERSION ${mraa_VERSION_STRING}
-)
-install(TARGETS mraa DESTINATION ${LIB_INSTALL_DIR})
diff --git a/peripheral/libmraa/src/aio/aio.c b/peripheral/libmraa/src/aio/aio.c
index 29594fd..13119a7 100644
--- a/peripheral/libmraa/src/aio/aio.c
+++ b/peripheral/libmraa/src/aio/aio.c
@@ -1,7 +1,7 @@
/*
* Author: Nandkishor Sonar
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2014-2016 Intel Corporation.
+ * Copyright (c) 2014, 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -56,7 +56,7 @@ aio_get_valid_fp(mraa_aio_context dev)
}
static mraa_aio_context
-mraa_aio_init_internal(mraa_adv_func_t* func_table, int aio, unsigned int channel)
+mraa_aio_init_internal(mraa_adv_func_t* func_table)
{
mraa_aio_context dev = calloc(1, sizeof(struct _aio));
if (dev == NULL) {
@@ -64,72 +64,29 @@ mraa_aio_init_internal(mraa_adv_func_t* func_table, int aio, unsigned int channe
}
dev->advance_func = func_table;
- if (IS_FUNC_DEFINED(dev, aio_init_internal_replace)) {
- if (dev->advance_func->aio_init_internal_replace(dev, aio) == MRAA_SUCCESS) {
- return dev;
- }
- free(dev);
- return NULL;
- }
-
- dev->channel = channel;
-
- // Open valid analog input file and get the pointer.
- if (MRAA_SUCCESS != aio_get_valid_fp(dev)) {
- free(dev);
- return NULL;
- }
-
return dev;
}
mraa_aio_context
mraa_aio_init(unsigned int aio)
{
- mraa_board_t* board = plat;
- int pin;
- if (board == NULL) {
+ if (plat == NULL) {
syslog(LOG_ERR, "aio: Platform not initialised");
return NULL;
}
if (mraa_is_sub_platform_id(aio)) {
- syslog(LOG_NOTICE, "aio: Using sub platform");
- board = board->sub_platform;
- if (board == NULL) {
- syslog(LOG_ERR, "aio: Sub platform Not Initialised");
- return NULL;
- }
- aio = mraa_get_sub_platform_index(aio);
- }
-
- // aio are always past the gpio_count in the pin array
- pin = aio + board->gpio_count;
-
- if (pin < 0 || pin >= board->phy_pin_count) {
- syslog(LOG_ERR, "aio: pin %i beyond platform definition", pin);
- return NULL;
- }
- if (aio >= board->aio_count) {
- syslog(LOG_ERR, "aio: requested channel out of range");
+ syslog(LOG_NOTICE, "aio: Using sub platform is not supported");
return NULL;
}
- if (board->pins[pin].capabilites.aio != 1) {
- syslog(LOG_ERR, "aio: pin %i not capable of aio", pin);
- return NULL;
- }
- if (board->pins[pin].aio.mux_total > 0) {
- if (mraa_setup_mux_mapped(board->pins[pin].aio) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "aio: unable to setup multiplexers for pin");
- return NULL;
- }
- }
// Create ADC device connected to specified channel
- mraa_aio_context dev = mraa_aio_init_internal(board->adv_func, aio, board->pins[pin].aio.pinmap);
+ mraa_aio_context dev = mraa_aio_init_internal(plat->adv_func);
if (dev == NULL) {
syslog(LOG_ERR, "aio: Insufficient memory for specified input channel %d", aio);
return NULL;
}
+ int pin = aio + plat->gpio_count;
+ dev->channel = plat->pins[pin].aio.pinmap;
dev->value_bit = DEFAULT_BITS;
if (IS_FUNC_DEFINED(dev, aio_init_pre)) {
@@ -139,6 +96,32 @@ mraa_aio_init(unsigned int aio)
return NULL;
}
}
+ if (aio > plat->aio_count) {
+ syslog(LOG_ERR, "aio: requested channel out of range");
+ free(dev);
+ return NULL;
+ }
+
+ if (plat->pins[pin].capabilites.aio != 1) {
+ syslog(LOG_ERR, "aio: pin uncapable of aio");
+ free(dev);
+ return NULL;
+ }
+
+ if (plat->pins[pin].aio.mux_total > 0) {
+ if (mraa_setup_mux_mapped(plat->pins[pin].aio) != MRAA_SUCCESS) {
+ free(dev);
+ syslog(LOG_ERR, "aio: unable to setup multiplexers for pin");
+ return NULL;
+ }
+ }
+
+ // Open valid analog input file and get the pointer.
+ if (MRAA_SUCCESS != aio_get_valid_fp(dev)) {
+ free(dev);
+ return NULL;
+ }
+ raw_bits = mraa_adc_raw_bits();
if (IS_FUNC_DEFINED(dev, aio_init_post)) {
mraa_result_t ret = dev->advance_func->aio_init_post(dev);
@@ -148,25 +131,19 @@ mraa_aio_init(unsigned int aio)
}
}
- raw_bits = mraa_adc_raw_bits();
-
return dev;
}
-int
+unsigned int
mraa_aio_read(mraa_aio_context dev)
{
- if (IS_FUNC_DEFINED(dev, aio_read_replace)) {
- return dev->advance_func->aio_read_replace(dev);
- }
-
char buffer[17];
unsigned int shifter_value = 0;
if (dev->adc_in_fp == -1) {
if (aio_get_valid_fp(dev) != MRAA_SUCCESS) {
syslog(LOG_ERR, "aio: Failed to get to the device");
- return -1;
+ return 0;
}
}
@@ -183,10 +160,8 @@ mraa_aio_read(mraa_aio_context dev)
unsigned int analog_value = (unsigned int) strtoul(buffer, &end, 10);
if (end == &buffer[0]) {
syslog(LOG_ERR, "aio: Value is not a decimal number");
- return -1;
} else if (errno != 0) {
syslog(LOG_ERR, "aio: Errno was set");
- return -1;
}
if (dev->value_bit != raw_bits) {
@@ -208,7 +183,7 @@ mraa_aio_read_float(mraa_aio_context dev)
{
if (dev == NULL) {
syslog(LOG_ERR, "aio: Device not valid");
- return -1.0;
+ return 0.0;
}
float max_analog_value = (1 << dev->value_bit) - 1;
diff --git a/peripheral/libmraa/src/arm/beaglebone.c b/peripheral/libmraa/src/arm/beaglebone.c
index 5dc6ad2..34652d8 100644
--- a/peripheral/libmraa/src/arm/beaglebone.c
+++ b/peripheral/libmraa/src/arm/beaglebone.c
@@ -64,6 +64,7 @@ static unsigned int mmap_count = 0;
mraa_result_t
mraa_beaglebone_mmap_write(mraa_gpio_context dev, int value)
{
+ volatile uint32_t* addr;
if (value) {
*(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_SET) = (uint32_t)(1 << (dev->pin % 32));
} else {
@@ -184,6 +185,7 @@ mraa_beaglebone_uart_init_pre(int index)
{
mraa_result_t ret = MRAA_ERROR_NO_RESOURCES;
char devpath[MAX_SIZE];
+ char overlay[MAX_SIZE];
char* capepath = NULL;
sprintf(devpath, "/dev/ttyO%u", index + 1);
if (!mraa_file_exist(devpath)) {
@@ -216,6 +218,7 @@ mraa_beaglebone_spi_init_pre(int index)
{
mraa_result_t ret = MRAA_ERROR_NO_RESOURCES;
char devpath[MAX_SIZE];
+ char overlay[MAX_SIZE];
char* capepath = NULL;
int deviceindex = 0;
@@ -270,10 +273,10 @@ mraa_beaglebone_i2c_init_pre(unsigned int bus)
{
mraa_result_t ret = MRAA_ERROR_NO_RESOURCES;
char devpath[MAX_SIZE];
+ char overlay[MAX_SIZE];
char* capepath = NULL;
sprintf(devpath, "/dev/i2c-%u", plat->i2c_bus[bus].bus_id);
if (!mraa_file_exist(devpath)) {
- syslog(LOG_INFO, "i2c: %s doesn't exist ", devpath);
capepath = mraa_file_unglob(SYSFS_DEVICES_CAPEMGR_SLOTS);
if (capepath == NULL) {
syslog(LOG_ERR, "i2c: Could not find CapeManager");
@@ -307,6 +310,7 @@ mraa_pwm_context
mraa_beaglebone_pwm_init_replace(int pin)
{
char devpath[MAX_SIZE];
+ char overlay[MAX_SIZE];
char* capepath = NULL;
if (plat == NULL) {
syslog(LOG_ERR, "pwm: Platform Not Initialised");
@@ -414,7 +418,7 @@ mraa_beaglebone()
else
i2c0_enabled = 0;
- if (mraa_file_exist("/sys/class/i2c-dev/i2c-2"))
+ if (mraa_file_exist("/sys/class/i2c-dev/i2c-1"))
i2c1_enabled = 1;
else
i2c1_enabled = 0;
@@ -1123,7 +1127,7 @@ mraa_beaglebone()
b->pins[64].i2c.mux_total = 0;
b->pins[64].spi.mux_total = 0;
- if (i2c1_enabled == 1) {
+ if (i2c0_enabled == 1) {
strncpy(b->pins[65].name, "I2C2SCL", MRAA_PIN_NAME_SIZE);
b->pins[65].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[65].i2c.mux_total = 0;
@@ -1136,7 +1140,7 @@ mraa_beaglebone()
b->pins[65].gpio.mux_total = 0;
b->pins[65].i2c.mux_total = 0;
- if (i2c1_enabled == 1) {
+ if (i2c0_enabled == 1) {
strncpy(b->pins[66].name, "I2C2SDA", MRAA_PIN_NAME_SIZE);
b->pins[66].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[66].i2c.mux_total = 0;
@@ -1376,7 +1380,7 @@ mraa_beaglebone()
b->i2c_bus[0].sda = 46 + 18;
b->i2c_bus[0].scl = 46 + 17;
- b->i2c_bus[1].bus_id = 2;
+ b->i2c_bus[1].bus_id = 1;
b->i2c_bus[1].sda = 46 + 20;
b->i2c_bus[1].scl = 46 + 19;
diff --git a/peripheral/libmraa/src/arm/raspberry_pi.c b/peripheral/libmraa/src/arm/raspberry_pi.c
index 50a7268..ad8b6ed 100644
--- a/peripheral/libmraa/src/arm/raspberry_pi.c
+++ b/peripheral/libmraa/src/arm/raspberry_pi.c
@@ -246,7 +246,7 @@ mraa_raspberry_pi()
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
- } else if (strstr(line, "a01041") || strstr(line, "a21041") || strstr(line, "a02082")) {
+ } else if (strstr(line, "a01041") || strstr(line, "a21041")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
diff --git a/peripheral/libmraa/src/firmata/CMakeLists.txt b/peripheral/libmraa/src/firmata/CMakeLists.txt
deleted file mode 100644
index 8ebc433..0000000
--- a/peripheral/libmraa/src/firmata/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-if (FIRMATA)
- message (STATUS "INFO - Adding firmata backend support")
- set (mraa_LIB_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO}
- ${PROJECT_SOURCE_DIR}/src/firmata/firmata.c
- ${PROJECT_SOURCE_DIR}/src/firmata/firmata_mraa.c
- PARENT_SCOPE
- )
-endif ()
diff --git a/peripheral/libmraa/src/firmata/firmata.c b/peripheral/libmraa/src/firmata/firmata.c
deleted file mode 100644
index 7da490f..0000000
--- a/peripheral/libmraa/src/firmata/firmata.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- * Copyright (c) 2015 Jules Dourlens (jdourlens@gmail.com)
- *
- * 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 "firmata/firmata.h"
-#include "mraa_internal.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-t_firmata*
-firmata_new(const char* name)
-{
- t_firmata* res;
- mraa_result_t uart_res = MRAA_ERROR_UNSPECIFIED;
-
- res = calloc(1, sizeof(t_firmata));
- if (!res) {
- return NULL;
- }
-
- res->uart = mraa_uart_init_raw(name);
- if (res->uart == NULL) {
- syslog(LOG_ERR, "firmata: UART failed to setup");
- free(res);
- return NULL;
- }
-
- firmata_initPins(res);
-
- if (mraa_uart_set_baudrate(res->uart, 57600) != MRAA_SUCCESS) {
- syslog(LOG_WARNING, "firmata: Failed to set correct baud rate on %s", name);
- }
-
- firmata_askFirmware(res);
- syslog(LOG_INFO, "firmata: Device opened at: %s", name);
-
- return res;
-}
-
-void
-firmata_close(t_firmata* firmata)
-{
- mraa_uart_stop(firmata->uart);
- free(firmata);
-}
-
-int
-firmata_pull(t_firmata* firmata)
-{
- uint8_t buff[FIRMATA_MSG_LEN];
- int r;
-
- r = mraa_uart_data_available(firmata->uart, 40);
- if (r > 0) {
- r = mraa_uart_read(firmata->uart, buff, sizeof(buff));
- if (r < 0) {
- return 0;
- }
- if (r > 0) {
- firmata_parse(firmata, buff, r);
- return r;
- }
- }
- return r;
-}
-
-void
-firmata_parse(t_firmata* firmata, const uint8_t* buf, int len)
-{
- const uint8_t* p;
- const uint8_t* end;
-
- p = buf;
- end = p + len;
- for (p = buf; p < end; p++) {
- uint8_t msn = *p & 0xF0;
- if (msn == 0xE0 || msn == 0x90 || *p == 0xF9) {
- firmata->parse_command_len = 3;
- firmata->parse_count = 0;
- } else if (msn == 0xC0 || msn == 0xD0) {
- firmata->parse_command_len = 2;
- firmata->parse_count = 0;
- } else if (*p == FIRMATA_START_SYSEX) {
- firmata->parse_count = 0;
- firmata->parse_command_len = sizeof(firmata->parse_buff);
- } else if (*p == FIRMATA_END_SYSEX) {
- firmata->parse_command_len = firmata->parse_count + 1;
- } else if (*p & 0x80) {
- firmata->parse_command_len = 1;
- firmata->parse_count = 0;
- }
- if (firmata->parse_count < (int) sizeof(firmata->parse_buff)) {
- firmata->parse_buff[firmata->parse_count] = (uint8_t)(*p);
- firmata->parse_count++;
- }
- if (firmata->parse_count == firmata->parse_command_len) {
- firmata_endParse(firmata);
- firmata->parse_count = 0;
- firmata->parse_command_len = 0;
- }
- }
-}
-
-void
-firmata_endParse(t_firmata* firmata)
-{
- uint8_t cmd = (firmata->parse_buff[0] & 0xF0);
- int pin;
-
- if (cmd == 0xE0 && firmata->parse_count == 3) {
- int analog_ch = (firmata->parse_buff[0] & 0x0F);
- int analog_val = firmata->parse_buff[1] | (firmata->parse_buff[2] << 7);
- for (pin = 0; pin < 128; pin++) {
- if (firmata->pins[pin].analog_channel == analog_ch) {
- firmata->pins[pin].value = analog_val;
- return;
- }
- }
- return;
- }
- if (cmd == 0x90 && firmata->parse_count == 3) {
- int port_num = (firmata->parse_buff[0] & 0x0F);
- int port_val = firmata->parse_buff[1] | (firmata->parse_buff[2] << 7);
- int pin = port_num * 8;
- int mask;
- for (mask = 1; mask & 0xFF; mask <<= 1, pin++) {
- if (firmata->pins[pin].mode == MODE_INPUT) {
- uint32_t val = (port_val & mask) ? 1 : 0;
- firmata->pins[pin].value = val;
- }
- }
- return;
- }
- if (firmata->parse_buff[0] == FIRMATA_START_SYSEX &&
- firmata->parse_buff[firmata->parse_count - 1] == FIRMATA_END_SYSEX) {
- if (firmata->parse_buff[1] == FIRMATA_REPORT_FIRMWARE) {
- int len = 0;
- int i;
- for (i = 4; i < firmata->parse_count - 2; i += 2) {
- firmata->firmware[len++] =
- (firmata->parse_buff[i] & 0x7F) | ((firmata->parse_buff[i + 1] & 0x7F) << 7);
- }
- firmata->firmware[len++] = '-';
- firmata->firmware[len++] = firmata->parse_buff[2] + '0';
- firmata->firmware[len++] = '.';
- firmata->firmware[len++] = firmata->parse_buff[3] + '0';
- firmata->firmware[len++] = 0;
- syslog(LOG_INFO, "firmata: sketch name:: %s", firmata->firmware);
- // query the board's capabilities only after hearing the
- // REPORT_FIRMWARE message. For boards that reset when
- // the port open (eg, Arduino with reset=DTR), they are
- // not ready to communicate for some time, so the only
- // way to reliably query their capabilities is to wait
- // until the REPORT_FIRMWARE message is heard.
- uint8_t buf[80];
- len = 0;
- buf[len++] = FIRMATA_START_SYSEX;
- buf[len++] = FIRMATA_ANALOG_MAPPING_QUERY; // read analog to pin # info
- buf[len++] = FIRMATA_END_SYSEX;
- buf[len++] = FIRMATA_START_SYSEX;
- buf[len++] = FIRMATA_CAPABILITY_QUERY; // read capabilities
- buf[len++] = FIRMATA_END_SYSEX;
- for (i = 0; i < 16; i++) {
- buf[len++] = 0xC0 | i; // report analog
- buf[len++] = 1;
- buf[len++] = 0xD0 | i; // report digital
- buf[len++] = 1;
- }
- firmata->isReady = 1;
- mraa_uart_write(firmata->uart, buf, len);
- } else if (firmata->parse_buff[1] == FIRMATA_CAPABILITY_RESPONSE) {
- int pin, i, n;
- for (pin = 0; pin < 128; pin++) {
- firmata->pins[pin].supported_modes = 0;
- }
- for (i = 2, n = 0, pin = 0; i < firmata->parse_count; i++) {
- if (firmata->parse_buff[i] == 127) {
- pin++;
- n = 0;
- continue;
- }
- if (n == 0) {
- // first byte is supported mode
- firmata->pins[pin].supported_modes |= (1 << firmata->parse_buff[i]);
- }
- n = n ^ 1;
- }
- // send a state query for for every pin with any modes
- for (pin = 0; pin < 128; pin++) {
- uint8_t buf[512];
- int len = 0;
- if (firmata->pins[pin].supported_modes) {
- buf[len++] = FIRMATA_START_SYSEX;
- buf[len++] = FIRMATA_PIN_STATE_QUERY;
- buf[len++] = pin;
- buf[len++] = FIRMATA_END_SYSEX;
- }
- mraa_uart_write(firmata->uart, buf, len);
- }
- } else if (firmata->parse_buff[1] == FIRMATA_ANALOG_MAPPING_RESPONSE) {
- int pin = 0;
- int i;
- for (i = 2; i < firmata->parse_count - 1; i++) {
- firmata->pins[pin].analog_channel = firmata->parse_buff[i];
- pin++;
- }
- return;
- } else if (firmata->parse_buff[1] == FIRMATA_PIN_STATE_RESPONSE && firmata->parse_count >= 6) {
- int pin = firmata->parse_buff[2];
- firmata->pins[pin].mode = firmata->parse_buff[3];
- firmata->pins[pin].value = firmata->parse_buff[4];
- if (firmata->parse_count > 6)
- firmata->pins[pin].value |= (firmata->parse_buff[5] << 7);
- if (firmata->parse_count > 7)
- firmata->pins[pin].value |= (firmata->parse_buff[6] << 14);
- // disable this to check the firmata_devs responses
- } else if (firmata->parse_buff[1] == FIRMATA_I2C_REPLY) {
- int addr = (firmata->parse_buff[2] & 0x7f) | ((firmata->parse_buff[3] & 0x7f) << 7);
- int reg = (firmata->parse_buff[4] & 0x7f) | ((firmata->parse_buff[5] & 0x7f) << 7);
- int i = 6;
- int ii = 0;
- for (ii; ii < (firmata->parse_count - 7) / 2; ii++) {
- firmata->i2cmsg[addr][reg+ii] = (firmata->parse_buff[i] & 0x7f) | ((firmata->parse_buff[i+1] & 0x7f) << 7);
- i = i+2;
- }
- } else {
- if (firmata->devs != NULL) {
- struct _firmata* devs = firmata->devs[0];
- int i = 0;
- for (i; i < firmata->dev_count; i++, devs++) {
- if (devs != NULL) {
- if (firmata->parse_buff[1] == devs->feature) {
- // call func
- if (devs->isr) {
- devs->isr(firmata->parse_buff, firmata->parse_count);
- }
- }
- }
- }
- }
- }
- return;
- }
-}
-
-void
-firmata_initPins(t_firmata* firmata)
-{
- int i;
-
- firmata->parse_count = 0;
- firmata->parse_command_len = 0;
- firmata->isReady = 0;
- for (i = 0; i < 128; i++) {
- firmata->pins[i].mode = 255;
- firmata->pins[i].analog_channel = 127;
- firmata->pins[i].supported_modes = 0;
- firmata->pins[i].value = 0;
- }
-}
-
-int
-firmata_askFirmware(t_firmata* firmata)
-{
- uint8_t buf[3];
- int res;
-
- buf[0] = FIRMATA_START_SYSEX;
- buf[1] = FIRMATA_REPORT_FIRMWARE; // read firmata name & version
- buf[2] = FIRMATA_END_SYSEX;
- res = mraa_uart_write(firmata->uart, buf, 3);
- return (res);
-}
-
-int
-firmata_pinMode(t_firmata* firmata, int pin, int mode)
-{
- int res;
- uint8_t buff[4];
-
- firmata->pins[pin].mode = mode;
- buff[0] = FIRMATA_SET_PIN_MODE;
- buff[1] = pin;
- buff[2] = mode;
- res = mraa_uart_write(firmata->uart, buff, 3);
- return (res);
-}
-
-int
-firmata_analogWrite(t_firmata* firmata, int pin, int value)
-{
- int res;
-
- uint8_t buff[3];
- buff[0] = 0xE0 | pin;
- buff[1] = value & 0x7F;
- buff[2] = (value >> 7) & 0x7F;
- res = mraa_uart_write(firmata->uart, buff, 3);
- return (res);
-}
-
-int
-firmata_analogRead(t_firmata *firmata, int pin)
-{
- int res;
- int value = 1;
- uint8_t buff[2];
- buff[0] = FIRMATA_REPORT_ANALOG | pin;
- buff[1] = value;
- res = mraa_uart_write(firmata->uart, buff, 2);
- return res;
-}
-
-int
-firmata_digitalWrite(t_firmata* firmata, int pin, int value)
-{
- int i;
- int res;
- uint8_t buff[4];
-
- if (pin < 0 || pin > 127)
- return (0);
- firmata->pins[pin].value = value;
- int port_num = pin / 8;
- int port_val = 0;
- for (i = 0; i < 8; i++) {
- int p = port_num * 8 + i;
- if (firmata->pins[p].mode == MODE_OUTPUT || firmata->pins[p].mode == MODE_INPUT) {
- if (firmata->pins[p].value) {
- port_val |= (1 << i);
- }
- }
- }
- buff[0] = FIRMATA_DIGITAL_MESSAGE | port_num;
- buff[1] = port_val & 0x7F;
- buff[2] = (port_val >> 7) & 0x7F;
- res = mraa_uart_write(firmata->uart, buff, 3);
- return (res);
-}
diff --git a/peripheral/libmraa/src/firmata/firmata_mraa.c b/peripheral/libmraa/src/firmata/firmata_mraa.c
deleted file mode 100644
index 25dd9f5..0000000
--- a/peripheral/libmraa/src/firmata/firmata_mraa.c
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-
-#include "firmata.h"
-#include "mraa_internal.h"
-#include "firmata/firmata_mraa.h"
-#include "firmata/firmata.h"
-
-static t_firmata* firmata_dev;
-static pthread_t thread_id;
-static volatile int isr_detected;
-
-mraa_firmata_context
-mraa_firmata_init(int feature)
-{
- mraa_firmata_context dev = (mraa_firmata_context) calloc(1, sizeof(struct _firmata));
- if (dev == NULL) {
- return NULL;
- }
- dev->feature = (uint8_t) feature;
- dev->added = 0;
-
- return dev;
-}
-
-mraa_result_t
-mraa_firmata_write_sysex(mraa_firmata_context dev, char* msg, int length)
-{
- return mraa_uart_write(firmata_dev->uart, msg, length);
-}
-
-mraa_result_t
-mraa_firmata_response(mraa_firmata_context dev, void (*fptr)(uint8_t*, int))
-{
- if (dev->added == 0) {
- struct _firmata** ptr;
- ptr = realloc(firmata_dev->devs, (firmata_dev->dev_count+1) * sizeof(struct _firmata*));
- if (ptr == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
- firmata_dev->devs = ptr;
- dev->index = firmata_dev->dev_count;
- firmata_dev->dev_count++;
- firmata_dev->devs[dev->index] = dev;
- dev->added = 1;
- }
- dev->isr = fptr;
- return MRAA_SUCCESS;
-}
-
-mraa_result_t
-mraa_firmata_response_stop(mraa_firmata_context dev)
-{
- dev->isr = NULL;
- return MRAA_SUCCESS;
-}
-
-mraa_result_t
-mraa_firmata_close(mraa_firmata_context dev)
-{
- mraa_firmata_response_stop(dev);
- free(dev);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_init_bus_replace(mraa_i2c_context dev)
-{
- int delay = 1; // this should be either 1 or 0, I don't know :)
- uint8_t buff[4];
- buff[0] = FIRMATA_START_SYSEX;
- buff[1] = FIRMATA_I2C_CONFIG;
- buff[2] = delay & 0xFF, (delay >> 8) & 0xFF;
- buff[3] = FIRMATA_END_SYSEX;
- mraa_uart_write(firmata_dev->uart, buff, 4);
-
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_address(mraa_i2c_context dev, uint8_t addr)
-{
- // only thing needed and it's already done
- //dev->addr = (int) addr;
-
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode)
-{
- return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-static mraa_result_t
-mraa_firmata_send_i2c_read_req(mraa_i2c_context dev, int length)
-{
- uint8_t* buffer = calloc(7, 0);
- if (buffer == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
- buffer[0] = FIRMATA_START_SYSEX;
- buffer[1] = FIRMATA_I2C_REQUEST;
- buffer[2] = dev->addr;
- buffer[3] = I2C_MODE_READ << 3;
-
- // number of bytes
- buffer[4] = length & 0x7f;
- buffer[5] = (length >> 7) & 0x7f;
- buffer[6] = FIRMATA_END_SYSEX;
-
- if (mraa_uart_write(firmata_dev->uart, buffer, 7) != 7) {
- free(buffer);
- return MRAA_ERROR_UNSPECIFIED;
- }
-
- // this needs a lock :)
- memset(&firmata_dev->i2cmsg[dev->addr][0], -1, sizeof(int)*length);
-
- free(buffer);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_send_i2c_read_reg_req(mraa_i2c_context dev, uint8_t command, int length)
-{
- uint8_t* buffer = calloc(9, 0);
- if (buffer == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
- buffer[0] = FIRMATA_START_SYSEX;
- buffer[1] = FIRMATA_I2C_REQUEST;
- buffer[2] = dev->addr;
- buffer[3] = I2C_MODE_READ << 3;
-
- // register to read from
- buffer[4] = command & 0x7f;
- buffer[5] = (command >> 7) & 0x7f;
- // number of bytes
- buffer[6] = length & 0x7f;
- buffer[7] = (length >> 7) & 0x7f;
- buffer[8] = FIRMATA_END_SYSEX;
-
- if (mraa_uart_write(firmata_dev->uart, buffer, 9) != 9) {
- free(buffer);
- return MRAA_ERROR_UNSPECIFIED;
- }
-
- // this needs a lock :)
- memset(&firmata_dev->i2cmsg[dev->addr][command], -1, sizeof(int)*length);
-
- free(buffer);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_wait(int addr, int reg)
-{
- int i = 0;
- for (i = 0; firmata_dev->i2cmsg[addr][reg] == -1; i++) {
- if (i > 50) {
- return MRAA_ERROR_UNSPECIFIED;
- }
- usleep(500);
- }
- return MRAA_SUCCESS;
-}
-
-static int
-mraa_firmata_i2c_read_byte(mraa_i2c_context dev)
-{
- if (mraa_firmata_send_i2c_read_req(dev, 1) == MRAA_SUCCESS) {
- if (mraa_firmata_i2c_wait(dev->addr, 0) == MRAA_SUCCESS) {
- return firmata_dev->i2cmsg[dev->addr][0];
- }
- }
- return -1;
-}
-
-static int
-mraa_firmata_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
-{
- if (mraa_firmata_send_i2c_read_reg_req(dev, command, 2) == MRAA_SUCCESS) {
- if (mraa_firmata_i2c_wait(dev->addr, command) == MRAA_SUCCESS) {
- uint8_t rawdata[2];
- rawdata[0] = firmata_dev->i2cmsg[dev->addr][command];
- rawdata[1] = firmata_dev->i2cmsg[dev->addr][command+1];
- uint16_t data = (uint16_t) rawdata;
- uint8_t high = (data & 0xFF00) >> 8;
- data = (data << 8) & 0xFF00;
- data |= high;
-
- return (int) data;
- }
- }
- return -1;
-}
-
-static int
-mraa_firmata_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length)
-{
- if (mraa_firmata_send_i2c_read_reg_req(dev, command, length) == MRAA_SUCCESS) {
- if (mraa_firmata_i2c_wait(dev->addr, command) == MRAA_SUCCESS) {
- memcpy(data, &firmata_dev->i2cmsg[dev->addr][command], sizeof(int)*length);
- return length;
- }
- }
- return 0;
-}
-
-static int
-mraa_firmata_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
-{
- if (mraa_firmata_send_i2c_read_req(dev, length) == MRAA_SUCCESS) {
- if (mraa_firmata_i2c_wait(dev->addr, 0) == MRAA_SUCCESS) {
- int i = 0;
- for (i = 0; i < length; i++) {
- data[i] = firmata_dev->i2cmsg[dev->addr][i];
- }
- return length;
- }
- }
-
- return 0;
-}
-
-static int
-mraa_firmata_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
-{
- if (mraa_firmata_send_i2c_read_reg_req(dev, command, 1) == MRAA_SUCCESS) {
- if (mraa_firmata_i2c_wait(dev->addr, command) == MRAA_SUCCESS) {
- return (int) firmata_dev->i2cmsg[dev->addr][command];
- }
- }
-
- return -1;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWrite)
-{
- // buffer needs 5 bytes for firmata, and 2 bytes for every byte of data
- int buffer_size = (bytesToWrite*2) + 5;
- uint8_t* buffer = calloc(buffer_size, 0);
- if (buffer == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
- int i = 0;
- int ii = 4;
- buffer[0] = FIRMATA_START_SYSEX;
- buffer[1] = FIRMATA_I2C_REQUEST;
- buffer[2] = dev->addr;
- buffer[3] = I2C_MODE_WRITE << 3;
- // we need to write until FIRMATA_END_SYSEX
- for (i; i < (buffer_size-1); i++) {
- buffer[ii] = data[i] & 0x7F;
- buffer[ii+1] = (data[i] >> 7) & 0x7f;
- ii = ii+2;
- }
- buffer[buffer_size-1] = FIRMATA_END_SYSEX;
- mraa_uart_write(firmata_dev->uart, buffer, buffer_size);
- free(buffer);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_write_byte(mraa_i2c_context dev, uint8_t data)
-{
- uint8_t* buffer = calloc(7, 0);
- if (buffer == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
- buffer[0] = FIRMATA_START_SYSEX;
- buffer[1] = FIRMATA_I2C_REQUEST;
- buffer[2] = dev->addr;
- buffer[3] = I2C_MODE_WRITE << 3;
- buffer[4] = data & 0x7F;
- buffer[5] = (data >> 7) & 0x7F;
- buffer[6] = FIRMATA_END_SYSEX;
- mraa_uart_write(firmata_dev->uart, buffer, 7);
- free(buffer);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
-{
- uint8_t* buffer = calloc(9, 0);
- if (buffer == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
- buffer[0] = FIRMATA_START_SYSEX;
- buffer[1] = FIRMATA_I2C_REQUEST;
- buffer[2] = dev->addr;
- buffer[3] = I2C_MODE_WRITE << 3;
- buffer[4] = command & 0x7F;
- buffer[5] = (command >> 7) & 0x7F;
- buffer[6] = data & 0x7F;
- buffer[7] = (data >> 7) & 0x7F;
- buffer[8] = FIRMATA_END_SYSEX;
- mraa_uart_write(firmata_dev->uart, buffer, 9);
- free(buffer);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command)
-{
- return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-static mraa_result_t
-mraa_firmata_i2c_stop(mraa_i2c_context dev)
-{
- return MRAA_SUCCESS;
-}
-
-static int
-mraa_firmata_aio_read(mraa_aio_context dev)
-{
- // careful, whilst you need to enable '0' for A0 you then need to read 14
- // in t_firmata because well that makes sense doesn't it...
- return (int) firmata_dev->pins[dev->channel].value;
-}
-
-static mraa_result_t
-mraa_firmata_aio_init_internal_replace(mraa_aio_context dev, int aio)
-{
- // firmata considers A0 pin0 as well as actual pin0 :/
- firmata_pinMode(firmata_dev, aio, MODE_ANALOG);
- // register for updates on that ADC channel
- firmata_analogRead(firmata_dev, aio);
-
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_init_internal_replace(mraa_gpio_context dev, int pin)
-{
- dev->pin = pin;
- dev->phy_pin = pin;
-
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_t mode)
-{
- return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-static int
-mraa_firmata_gpio_read_replace(mraa_gpio_context dev)
-{
- return firmata_dev->pins[dev->pin].value;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_write_replace(mraa_gpio_context dev, int write_value)
-{
- if (write_value == 0) {
- firmata_digitalWrite(firmata_dev, dev->phy_pin, LOW);
- } else {
- firmata_digitalWrite(firmata_dev, dev->phy_pin, HIGH);
- }
-
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_dir_replace(mraa_gpio_context dev, mraa_gpio_dir_t dir)
-{
- switch (dir) {
- case MRAA_GPIO_IN:
- firmata_pinMode(firmata_dev, dev->phy_pin, MODE_INPUT);
- break;
- case MRAA_GPIO_OUT:
- firmata_pinMode(firmata_dev, dev->phy_pin, MODE_OUTPUT);
- break;
- case MRAA_GPIO_OUT_LOW:
- firmata_pinMode(firmata_dev, dev->phy_pin, MODE_OUTPUT);
- firmata_digitalWrite(firmata_dev, dev->phy_pin, LOW);
- break;
- case MRAA_GPIO_OUT_HIGH:
- firmata_pinMode(firmata_dev, dev->phy_pin, MODE_OUTPUT);
- firmata_digitalWrite(firmata_dev, dev->phy_pin, HIGH);
- break;
- default:
- return MRAA_ERROR_INVALID_PARAMETER;
- }
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_edge_mode_replace(mraa_gpio_context dev, mraa_gpio_edge_t mode)
-{
- switch (mode) {
- case MRAA_GPIO_EDGE_BOTH:
- return MRAA_SUCCESS;
- default:
- return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
- }
-}
-
-static mraa_result_t
-mraa_firmata_gpio_interrupt_handler_init_replace(mraa_gpio_context dev)
-{
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_wait_interrupt_replace(mraa_gpio_context dev)
-{
- while (!((isr_detected >> dev->pin) & 1)) {
- usleep(100);
- }
- // might want to lock here?
- isr_detected &= ~(1 << dev->pin);
- return MRAA_SUCCESS;
-}
-
-static mraa_result_t
-mraa_firmata_gpio_close_replace(mraa_gpio_context dev)
-{
- free(dev);
- return MRAA_SUCCESS;
-}
-
-static mraa_pwm_context
-mraa_firmata_pwm_init_internal_replace(void* func_table, int pin)
-{
- mraa_pwm_context dev = (mraa_pwm_context) calloc(1, sizeof(struct _pwm));
- if (dev == NULL) {
- return NULL;
- }
- dev->pin = pin;
- dev->chipid = 512;
- dev->period = 2048000; // Locked, in ns
- dev->advance_func = (mraa_adv_func_t*) func_table;
-
- return dev;
-}
-
-static mraa_result_t
-mraa_firmata_pwm_write_replace(mraa_pwm_context dev, float percentage)
-{
- int value = (int)((percentage - 1) / 8000);
- firmata_analogWrite(firmata_dev, dev->pin, value);
- firmata_dev->pins[dev->pin].value = value;
- return MRAA_SUCCESS;
-}
-
-static float
-mraa_firmata_pwm_read_replace(mraa_pwm_context dev)
-{
- int value = firmata_dev->pins[dev->pin].value;
- if (value) {
- return (value + 1) * 8000;
- }
- return 0;
-}
-
-static mraa_result_t
-mraa_firmata_pwm_enable_replace(mraa_pwm_context dev, int enable)
-{
- if (enable) {
- firmata_pinMode(firmata_dev, dev->pin, MODE_PWM);
- firmata_dev->pins[dev->pin].value = 0;
- } else {
- firmata_pinMode(firmata_dev, dev->pin, MODE_INPUT);
- }
- return MRAA_SUCCESS;
-}
-
-static void*
-mraa_firmata_pull_handler(void* vp)
-{
- int i, isr_now, isr_prev;
- isr_prev = 0;
- while(1) {
- isr_now = 0;
- firmata_pull(firmata_dev);
- // would prefer to send board pointer as argument
- for(i = 0; i < 14; i++) {
- isr_now |= (firmata_dev->pins[i].value & 1) << i;
- }
- // might want to lock here?
- isr_detected = isr_prev ^ isr_now; //both edges for now
- isr_prev = isr_now;
- usleep(100);
- }
-}
-
-mraa_board_t*
-mraa_firmata_plat_init(const char* uart_dev)
-{
- mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
- if (b == NULL) {
- return NULL;
- }
-
- firmata_dev = firmata_new(uart_dev);
- if (firmata_dev == NULL) {
- syslog(LOG_WARNING, "firmata: Failed to open uart to Firmata dev on %s", uart_dev);
- fprintf(stderr, "Mraa expected to find a Firmata device on %s, is the port in use?\n", uart_dev);
- free(b);
- return NULL;
- }
-
- // if this isn't working then we have an issue with our uart
- int retry = 20;
- while (!firmata_dev->isReady && retry--) {
- firmata_pull(firmata_dev);
- }
-
- if (!retry) {
- syslog(LOG_ERR, "firmata: Failed to find a valid Firmata board on %s", uart_dev);
- firmata_close(firmata_dev);
- free(b);
- return NULL;
- }
-
- pthread_create(&thread_id, NULL, mraa_firmata_pull_handler, NULL);
-
- b->platform_name = "firmata";
- // do we support 2.5? Or are we more 2.3?
- // or should we return the flashed sketch name?
- b->platform_version = firmata_dev->firmware;
- b->gpio_count = 14;
- b->aio_count = 6;
- b->adc_supported = 10;
- b->phy_pin_count = 20;
- b->i2c_bus_count = 1;
- b->def_i2c_bus = 0;
- b->i2c_bus[0].bus_id = 0;
- b->pwm_min_period = 2048;
- b->pwm_max_period = 2048;
-
- b->pins = (mraa_pininfo_t*) calloc(b->phy_pin_count, sizeof(mraa_pininfo_t));
- if (b->pins == NULL) {
- free(b);
- return NULL;
- }
-
- strncpy(b->pins[0].name, "IO0", 8);
- b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[0].gpio.pinmap = 0;
- strncpy(b->pins[1].name, "IO1", 8);
- b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[1].gpio.pinmap = 1;
- strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[2].gpio.pinmap = 2;
- strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[3].gpio.pinmap = 3;
- strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[4].gpio.pinmap = 4;
- strncpy(b->pins[5].name, "IO5", 8);
- b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[5].gpio.pinmap = 5;
- strncpy(b->pins[6].name, "IO6", 8);
- b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[6].gpio.pinmap = 6;
- strncpy(b->pins[7].name, "IO7", 8);
- b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[7].gpio.pinmap = 7;
- strncpy(b->pins[8].name, "IO8", 8);
- b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[8].gpio.pinmap = 8;
- strncpy(b->pins[9].name, "IO9", 8);
- b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[9].gpio.pinmap = 9;
- strncpy(b->pins[10].name, "IO10", 8);
- b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[10].gpio.pinmap = 10;
- strncpy(b->pins[11].name, "IO11", 8);
- b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[11].gpio.pinmap = 11;
- strncpy(b->pins[12].name, "IO12", 8);
- b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[12].gpio.pinmap = 12;
- strncpy(b->pins[13].name, "IO13", 8);
- b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[13].gpio.pinmap = 13;
- strncpy(b->pins[10].name, "A0", 8);
- b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
- b->pins[14].gpio.pinmap = 14;
- b->pins[14].aio.pinmap = 14;
- strncpy(b->pins[11].name, "A1", 8);
- b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
- b->pins[15].gpio.pinmap = 15;
- b->pins[15].aio.pinmap = 15;
- strncpy(b->pins[12].name, "A2", 8);
- b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
- b->pins[16].gpio.pinmap = 16;
- b->pins[16].aio.pinmap = 16;
- strncpy(b->pins[13].name, "A3", 8);
- b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
- b->pins[17].gpio.pinmap = 17;
- b->pins[17].aio.pinmap = 17;
- strncpy(b->pins[13].name, "A4", 8);
- b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
- b->pins[18].gpio.pinmap = 18;
- b->pins[18].aio.pinmap = 18;
- strncpy(b->pins[13].name, "A5", 8);
- b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
- b->pins[19].gpio.pinmap = 19;
- b->pins[19].aio.pinmap = 19;
-
- b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
- if (b->adv_func == NULL) {
- free(b->pins);
- free(b);
- return NULL;
- }
-
- b->adv_func->gpio_init_internal_replace = &mraa_firmata_gpio_init_internal_replace;
- b->adv_func->gpio_mode_replace = &mraa_firmata_gpio_mode_replace;
- b->adv_func->gpio_dir_replace = &mraa_firmata_gpio_dir_replace;
- b->adv_func->gpio_edge_mode_replace = &mraa_firmata_gpio_edge_mode_replace;
- b->adv_func->gpio_interrupt_handler_init_replace = &mraa_firmata_gpio_interrupt_handler_init_replace;
- b->adv_func->gpio_wait_interrupt_replace = &mraa_firmata_gpio_wait_interrupt_replace;
- b->adv_func->gpio_read_replace = &mraa_firmata_gpio_read_replace;
- b->adv_func->gpio_write_replace = &mraa_firmata_gpio_write_replace;
- b->adv_func->gpio_close_replace = &mraa_firmata_gpio_close_replace;
-
- b->adv_func->aio_init_internal_replace = &mraa_firmata_aio_init_internal_replace;
- b->adv_func->aio_read_replace = &mraa_firmata_aio_read;
-
- b->adv_func->pwm_init_internal_replace = &mraa_firmata_pwm_init_internal_replace;
- b->adv_func->pwm_write_replace = &mraa_firmata_pwm_write_replace;
- b->adv_func->pwm_read_replace = &mraa_firmata_pwm_read_replace;
- b->adv_func->pwm_enable_replace = &mraa_firmata_pwm_enable_replace;
-
- b->adv_func->i2c_init_bus_replace = &mraa_firmata_i2c_init_bus_replace;
- b->adv_func->i2c_set_frequency_replace = &mraa_firmata_i2c_frequency;
- b->adv_func->i2c_address_replace = &mraa_firmata_i2c_address;
- b->adv_func->i2c_read_replace = &mraa_firmata_i2c_read;
- b->adv_func->i2c_read_byte_replace = &mraa_firmata_i2c_read_byte;
- b->adv_func->i2c_read_byte_data_replace = &mraa_firmata_i2c_read_byte_data;
- b->adv_func->i2c_read_word_data_replace = &mraa_firmata_i2c_read_word_data;
- b->adv_func->i2c_read_bytes_data_replace = &mraa_firmata_i2c_read_bytes_data;
- b->adv_func->i2c_write_replace = &mraa_firmata_i2c_write;
- b->adv_func->i2c_write_byte_replace = &mraa_firmata_i2c_write_byte;
- b->adv_func->i2c_write_byte_data_replace = &mraa_firmata_i2c_write_byte_data;
- b->adv_func->i2c_write_word_data_replace = &mraa_firmata_i2c_write_word_data;
- b->adv_func->i2c_stop_replace = &mraa_firmata_i2c_stop;
-
- return b;
-}
-
-mraa_platform_t
-mraa_firmata_platform(mraa_board_t* board, const char* uart_dev)
-{
- /**
- * Firmata boards are not something we can detect so we just trust the user
- * to initialise them themselves and is the only platform type not to be
- * initialised from mraa_init(). Good luck!
- */
- mraa_board_t* sub_plat = NULL;
-
- sub_plat = mraa_firmata_plat_init(uart_dev);
- if (sub_plat != NULL) {
- sub_plat->platform_type = MRAA_GENERIC_FIRMATA;
- board->sub_platform = sub_plat;
- return sub_plat->platform_type;
- }
-
- return MRAA_NULL_PLATFORM;
-}
diff --git a/peripheral/libmraa/src/gpio/gpio.c b/peripheral/libmraa/src/gpio/gpio.c
index 6488fd5..3b41612 100644
--- a/peripheral/libmraa/src/gpio/gpio.c
+++ b/peripheral/libmraa/src/gpio/gpio.c
@@ -34,7 +34,6 @@
#include <signal.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include <errno.h>
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
#define MAX_SIZE 64
@@ -47,7 +46,6 @@ mraa_gpio_get_valfp(mraa_gpio_context dev)
sprintf(bu, SYSFS_CLASS_GPIO "/gpio%d/value", dev->pin);
dev->value_fp = open(bu, O_RDWR);
if (dev->value_fp == -1) {
- syslog(LOG_ERR, "gpio%i: Failed to open 'value': %s", dev->pin, strerror(errno));
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -66,7 +64,7 @@ mraa_gpio_init_internal(mraa_adv_func_t* func_table, int pin)
mraa_gpio_context dev = (mraa_gpio_context) calloc(1, sizeof(struct _gpio));
if (dev == NULL) {
- syslog(LOG_CRIT, "gpio%i: Failed to allocate memory for context", pin);
+ syslog(LOG_CRIT, "gpio: Failed to allocate memory for context");
return NULL;
}
@@ -104,15 +102,15 @@ mraa_gpio_init_internal(mraa_adv_func_t* func_table, int pin)
} else {
int export = open(SYSFS_CLASS_GPIO "/export", O_WRONLY);
if (export == -1) {
- syslog(LOG_ERR, "gpio%i: init: Failed to open 'export' for writing: %s", pin, strerror(errno));
- status = MRAA_ERROR_INVALID_RESOURCE;
+ syslog(LOG_ERR, "gpio: Failed to open export for writing");
+ status = MRAA_ERROR_NO_RESOURCES;
goto init_internal_cleanup;
}
length = snprintf(bu, sizeof(bu), "%d", dev->pin);
if (write(export, bu, length * sizeof(char)) == -1) {
- syslog(LOG_ERR, "gpio%i: init: Failed to write to 'export': %s", pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to write %d to export", dev->pin);
close(export);
- status = MRAA_ERROR_INVALID_RESOURCE;
+ status = MRAA_ERROR_NO_RESOURCES;
goto init_internal_cleanup;
}
dev->owner = 1;
@@ -133,37 +131,38 @@ mraa_gpio_init(int pin)
{
mraa_board_t* board = plat;
if (board == NULL) {
- syslog(LOG_ERR, "gpio%i: init: platform not initialised", pin);
+ syslog(LOG_ERR, "gpio: platform not initialised");
return NULL;
}
if (mraa_is_sub_platform_id(pin)) {
- syslog(LOG_NOTICE, "gpio%i: init: Using sub platform", pin);
+ syslog(LOG_NOTICE, "gpio: Using sub platform");
board = board->sub_platform;
if (board == NULL) {
- syslog(LOG_ERR, "gpio%i: init: Sub platform not initialised", pin);
+ syslog(LOG_ERR, "gpio: Sub platform Not Initialised");
return NULL;
}
pin = mraa_get_sub_platform_index(pin);
}
- if (pin < 0 || pin >= board->phy_pin_count) {
- syslog(LOG_ERR, "gpio: init: pin %i beyond platform pin count (%i)", pin, board->phy_pin_count);
+ if (pin < 0 || pin > board->phy_pin_count) {
+ syslog(LOG_ERR, "gpio: pin %i beyond platform definition", pin);
return NULL;
}
if (board->pins[pin].capabilites.gpio != 1) {
- syslog(LOG_ERR, "gpio: init: pin %i not capable of gpio", pin);
+ syslog(LOG_ERR, "gpio: pin %i not capable of gpio", pin);
return NULL;
}
if (board->pins[pin].gpio.mux_total > 0) {
if (mraa_setup_mux_mapped(board->pins[pin].gpio) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "gpio%i: init: unable to setup muxes", pin);
+ syslog(LOG_ERR, "gpio: unable to setup muxes");
return NULL;
}
}
mraa_gpio_context r = mraa_gpio_init_internal(board->adv_func, board->pins[pin].gpio.pinmap);
if (r == NULL) {
+ syslog(LOG_CRIT, "gpio: mraa_gpio_init_raw(%d) returned error", pin);
return NULL;
}
if (r->phy_pin == -1)
@@ -200,12 +199,12 @@ mraa_gpio_wait_interrupt(int fd
struct pollfd pfd[2];
if (control_fd < 0) {
- return MRAA_ERROR_INVALID_PARAMETER;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
#endif
if (fd < 0) {
- return MRAA_ERROR_INVALID_PARAMETER;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
// setup poll on POLLPRI
@@ -219,14 +218,14 @@ mraa_gpio_wait_interrupt(int fd
#ifdef HAVE_PTHREAD_CANCEL
// Wait for it forever or until pthread_cancel
// poll is a cancelable point like sleep()
- poll(pfd, 1, -1);
+ int x = poll(pfd, 1, -1);
#else
// setup poll on the controling fd
pfd[1].fd = control_fd;
pfd[1].events = 0; // POLLHUP, POLLERR, and POLLNVAL
// Wait for it forever or until control fd is closed
- poll(pfd, 2, -1);
+ int x = poll(pfd, 2, -1);
#endif
// do a final read to clear interrupt
@@ -235,6 +234,36 @@ mraa_gpio_wait_interrupt(int fd
return MRAA_SUCCESS;
}
+#if defined(SWIGJAVA) || defined(JAVACALLBACK)
+pthread_key_t env_key;
+
+extern JavaVM *globVM;
+static pthread_once_t env_key_init = PTHREAD_ONCE_INIT;
+
+jmethodID runGlobal;
+
+static void make_env_key(void)
+{
+
+ JNIEnv *jenv;
+ (*globVM)->GetEnv(globVM, (void **)&jenv, JNI_VERSION_1_6);
+
+ jclass rcls = (*jenv)->FindClass(jenv, "java/lang/Runnable");
+ jmethodID runm = (*jenv)->GetMethodID(jenv, rcls, "run", "()V");
+
+ runGlobal = (jmethodID)(*jenv)->NewGlobalRef(jenv, (jobject)runm);
+
+ pthread_key_create(&env_key, NULL);
+}
+
+void mraa_java_isr_callback(void* data)
+{
+ JNIEnv *jenv = (JNIEnv *) pthread_getspecific(env_key);
+ (*jenv)->CallVoidMethod(jenv, (jobject)data, runGlobal);
+}
+
+#endif
+
static void*
mraa_gpio_interrupt_handler(void* arg)
{
@@ -251,14 +280,14 @@ mraa_gpio_interrupt_handler(void* arg)
sprintf(bu, SYSFS_CLASS_GPIO "/gpio%d/value", dev->pin);
fp = open(bu, O_RDONLY);
if (fp < 0) {
- syslog(LOG_ERR, "gpio%i: interrupt_handler: failed to open 'value' : %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: failed to open gpio%d/value", dev->pin);
return NULL;
}
}
#ifndef HAVE_PTHREAD_CANCEL
if (pipe(dev->isr_control_pipe)) {
- syslog(LOG_ERR, "gpio%i: interrupt_handler: failed to create isr control pipe: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: failed to create isr control pipe");
close(fp);
return NULL;
}
@@ -266,15 +295,21 @@ mraa_gpio_interrupt_handler(void* arg)
dev->isr_value_fp = fp;
- if (lang_func->java_attach_thread != NULL) {
- if (dev->isr == lang_func->java_isr_callback) {
- if (lang_func->java_attach_thread() != MRAA_SUCCESS) {
+#if defined(SWIGJAVA) || defined(JAVACALLBACK)
+ JNIEnv *jenv;
+ if(dev->isr == mraa_java_isr_callback) {
+ jint err = (*globVM)->AttachCurrentThreadAsDaemon(globVM, (void **)&jenv, NULL);
+
+ if (err != JNI_OK) {
close(dev->isr_value_fp);
dev->isr_value_fp = -1;
return NULL;
- }
}
+
+ pthread_once(&env_key_init, make_env_key);
+ pthread_setspecific(env_key, jenv);
}
+#endif
for (;;) {
if (IS_FUNC_DEFINED(dev, gpio_wait_interrupt_replace)) {
@@ -290,11 +325,71 @@ mraa_gpio_interrupt_handler(void* arg)
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#endif
- if (lang_func->python_isr != NULL) {
- lang_func->python_isr(dev->isr, dev->isr_args);
+#ifdef SWIGPYTHON
+ // In order to call a python object (all python functions are objects) we
+ // need to aquire the GIL (Global Interpreter Lock). This may not always be
+ // necessary but especially if doing IO (like print()) python will segfault
+ // if we do not hold a lock on the GIL
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyObject* arglist;
+ PyObject* ret;
+ arglist = Py_BuildValue("(O)", dev->isr_args);
+ if (arglist == NULL) {
+ syslog(LOG_ERR, "gpio: Py_BuildValue NULL");
} else {
- dev->isr(dev->isr_args);
+ ret = PyEval_CallObject((PyObject*) dev->isr, arglist);
+ if (ret == NULL) {
+ syslog(LOG_ERR, "gpio: PyEval_CallObject failed");
+ PyObject *pvalue, *ptype, *ptraceback;
+ PyObject *pvalue_pystr, *ptype_pystr, *ptraceback_pystr;
+ char *pvalue_cstr, *ptype_cstr, *ptraceback_cstr;
+ PyErr_Fetch(&pvalue, &ptype, &ptraceback);
+ pvalue_pystr = PyObject_Str(pvalue);
+ ptype_pystr = PyObject_Str(ptype);
+ ptraceback_pystr = PyObject_Str(ptraceback);
+// Python2
+#if PY_VERSION_HEX < 0x03000000
+ pvalue_cstr = PyString_AsString(pvalue_pystr);
+ ptype_cstr = PyString_AsString(ptype_pystr);
+ ptraceback_cstr = PyString_AsString(ptraceback_pystr);
+// Python 3 and up
+#elif PY_VERSION_HEX >= 0x03000000
+ // In Python 3 we need one extra conversion
+ PyObject *pvalue_ustr, *ptype_ustr, *ptraceback_ustr;
+ pvalue_ustr = PyUnicode_AsUTF8String(pvalue_pystr);
+ pvalue_cstr = PyBytes_AsString(pvalue_ustr);
+ ptype_ustr = PyUnicode_AsUTF8String(ptype_pystr);
+ ptype_cstr = PyBytes_AsString(ptype_ustr);
+ ptraceback_ustr = PyUnicode_AsUTF8String(ptraceback_pystr);
+ ptraceback_cstr = PyBytes_AsString(ptraceback_ustr);
+#endif // PY_VERSION_HEX
+ syslog(LOG_ERR, "gpio: the error was %s:%s:%s",
+ pvalue_cstr,
+ ptype_cstr,
+ ptraceback_cstr
+ );
+ Py_XDECREF(pvalue);
+ Py_XDECREF(ptype);
+ Py_XDECREF(ptraceback);
+ Py_XDECREF(pvalue_pystr);
+ Py_XDECREF(ptype_pystr);
+ Py_XDECREF(ptraceback_pystr);
+// Python 3 and up
+#if PY_VERSION_HEX >= 0x03000000
+ Py_XDECREF(pvalue_ustr);
+ Py_XDECREF(ptype_ustr);
+ Py_XDECREF(ptraceback_ustr);
+#endif // PY_VERSION_HEX
+ } else {
+ Py_DECREF(ret);
+ }
+ Py_DECREF(arglist);
}
+
+ PyGILState_Release(gilstate);
+#else
+ dev->isr(dev->isr_args);
+#endif
#ifdef HAVE_PTHREAD_CANCEL
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
#endif
@@ -307,14 +402,13 @@ mraa_gpio_interrupt_handler(void* arg)
close(dev->isr_value_fp);
dev->isr_value_fp = -1;
}
+#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- if (lang_func->java_detach_thread != NULL && lang_func->java_delete_global_ref != NULL) {
- if (dev->isr == lang_func->java_isr_callback) {
- lang_func->java_delete_global_ref(dev->isr_args);
- lang_func->java_detach_thread();
- }
+ if(dev->isr == mraa_java_isr_callback) {
+ (*jenv)->DeleteGlobalRef(jenv, (jobject)dev->isr_args);
+ (*globVM)->DetachCurrentThread(globVM);
}
-
+#endif
return NULL;
}
}
@@ -323,12 +417,7 @@ mraa_gpio_interrupt_handler(void* arg)
mraa_result_t
mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: edge_mode: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, gpio_edge_mode_replace))
+ if (IS_FUNC_DEFINED(dev, gpio_edge_mode_replace))
return dev->advance_func->gpio_edge_mode_replace(dev, mode);
if (dev->value_fp != -1) {
@@ -341,7 +430,7 @@ mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode)
int edge = open(filepath, O_RDWR);
if (edge == -1) {
- syslog(LOG_ERR, "gpio%i: edge_mode: Failed to open 'edge' for writing: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to open edge for writing");
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -365,9 +454,9 @@ mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode)
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
if (write(edge, bu, length * sizeof(char)) == -1) {
- syslog(LOG_ERR, "gpio%i: edge_mode: Failed to write to 'edge': %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to write to edge");
close(edge);
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(edge);
@@ -377,31 +466,26 @@ mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode)
mraa_result_t
mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t mode, void (*fptr)(void*), void* args)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: isr: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
// we only allow one isr per mraa_gpio_context
if (dev->thread_id != 0) {
return MRAA_ERROR_NO_RESOURCES;
}
- mraa_result_t ret = mraa_gpio_edge_mode(dev, mode);
- if (ret != MRAA_SUCCESS) {
- return ret;
+ if (MRAA_SUCCESS != mraa_gpio_edge_mode(dev, mode)) {
+ return MRAA_ERROR_UNSPECIFIED;
}
dev->isr = fptr;
-
- /* Most UPM sensors use the C API, the Java global ref must be created here. */
+#if defined(SWIGJAVA) || defined(JAVACALLBACK)
+ JNIEnv *jenv;
+ /* Most UPM sensors use the C API, the global ref must be created here. */
/* The reason for checking the callback function is internal callbacks. */
- if (lang_func->java_create_global_ref != NULL) {
- if (dev->isr == lang_func->java_isr_callback) {
- args = lang_func->java_create_global_ref(args);
- }
+ if (fptr == mraa_java_isr_callback) {
+ (*globVM)->GetEnv(globVM, (void **)&jenv, JNI_VERSION_1_6);
+ jobject grunnable = (*jenv)->NewGlobalRef(jenv, (jobject) args);
+ args = (void *) grunnable;
}
-
+#endif
dev->isr_args = args;
pthread_create(&dev->thread_id, NULL, mraa_gpio_interrupt_handler, (void*) dev);
@@ -413,10 +497,6 @@ mraa_gpio_isr_exit(mraa_gpio_context dev)
{
mraa_result_t ret = MRAA_SUCCESS;
- if (dev == NULL) {
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
// wasting our time, there is no isr to exit from
if (dev->thread_id == 0 && dev->isr_value_fp == -1) {
return ret;
@@ -430,12 +510,12 @@ mraa_gpio_isr_exit(mraa_gpio_context dev)
if ((dev->thread_id != 0)) {
#ifdef HAVE_PTHREAD_CANCEL
if ((pthread_cancel(dev->thread_id) != 0) || (pthread_join(dev->thread_id, NULL) != 0)) {
- ret = MRAA_ERROR_INVALID_RESOURCE;
+ ret = MRAA_ERROR_INVALID_HANDLE;
}
#else
close(dev->isr_control_pipe[1]);
if (pthread_join(dev->thread_id, NULL) != 0)
- ret = MRAA_ERROR_INVALID_RESOURCE;
+ ret = MRAA_ERROR_INVALID_HANDLE;
close(dev->isr_control_pipe[0]);
dev->isr_control_pipe[0] = dev->isr_control_pipe[1] = -1;
@@ -445,7 +525,7 @@ mraa_gpio_isr_exit(mraa_gpio_context dev)
// close the filehandle in case it's still open
if (dev->isr_value_fp != -1) {
if (close(dev->isr_value_fp) != 0) {
- ret = MRAA_ERROR_INVALID_RESOURCE;
+ ret = MRAA_ERROR_INVALID_PARAMETER;
}
}
@@ -459,11 +539,6 @@ mraa_gpio_isr_exit(mraa_gpio_context dev)
mraa_result_t
mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: mode: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
if (IS_FUNC_DEFINED(dev, gpio_mode_replace))
return dev->advance_func->gpio_mode_replace(dev, mode);
@@ -483,7 +558,7 @@ mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
int drive = open(filepath, O_WRONLY);
if (drive == -1) {
- syslog(LOG_ERR, "gpio%i: mode: Failed to open 'drive' for writing: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to open drive for writing");
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -507,8 +582,8 @@ mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
if (write(drive, bu, length * sizeof(char)) == -1) {
- syslog(LOG_ERR, "gpio%i: mode: Failed to write to 'drive': %s", dev->pin, strerror(errno));
- close(drive);
+ syslog(LOG_ERR, "gpio: Failed to write to drive mode");
+ close(drive);
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -521,11 +596,6 @@ mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
mraa_result_t
mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: dir: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
if (IS_FUNC_DEFINED(dev, gpio_dir_replace)) {
return dev->advance_func->gpio_dir_replace(dev, dir);
}
@@ -537,6 +607,9 @@ mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir)
}
}
+ if (dev == NULL) {
+ return MRAA_ERROR_INVALID_HANDLE;
+ }
if (dev->value_fp != -1) {
close(dev->value_fp);
dev->value_fp = -1;
@@ -555,9 +628,8 @@ mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir)
case MRAA_GPIO_OUT_LOW:
return mraa_gpio_write(dev, 0);
default:
- syslog(LOG_ERR, "gpio%i: dir: Failed to open 'direction' for writing: %s", dev->pin, strerror(errno));
return MRAA_ERROR_INVALID_RESOURCE;
- }
+ }
}
char bu[MAX_SIZE];
@@ -582,8 +654,7 @@ mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir)
if (write(direction, bu, length * sizeof(char)) == -1) {
close(direction);
- syslog(LOG_ERR, "gpio%i: dir: Failed to write to 'direction': %s", dev->pin, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(direction);
@@ -600,20 +671,9 @@ mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
int fd, rc;
mraa_result_t result = MRAA_SUCCESS;
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: read_dir: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (dir == NULL) {
- syslog(LOG_ERR, "gpio: read_dir: output parameter for dir is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
snprintf(filepath, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/direction", dev->pin);
fd = open(filepath, O_RDONLY);
if (fd == -1) {
- syslog(LOG_ERR, "gpio%i: read_dir: Failed to open 'direction' for reading: %s", dev->pin, strerror(errno));
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -621,7 +681,6 @@ mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
rc = read(fd, value, sizeof(value));
close(fd);
if (rc <= 0) {
- syslog(LOG_ERR, "gpio%i: read_dir: Failed to read 'direction': %s", dev->pin, strerror(errno));
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -630,8 +689,7 @@ mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
} else if (strcmp(value, "in\n") == 0) {
*dir = MRAA_GPIO_IN;
} else {
- syslog(LOG_ERR, "gpio%i: read_dir: unknown direction: %s", dev->pin, value);
- result = MRAA_ERROR_UNSPECIFIED;
+ result = MRAA_ERROR_INVALID_RESOURCE;
}
return result;
@@ -640,10 +698,8 @@ mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
int
mraa_gpio_read(mraa_gpio_context dev)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: read: context is invalid");
+ if (dev == NULL)
return -1;
- }
if (IS_FUNC_DEFINED(dev, gpio_read_replace))
return dev->advance_func->gpio_read_replace(dev);
@@ -653,6 +709,7 @@ mraa_gpio_read(mraa_gpio_context dev)
if (dev->value_fp == -1) {
if (mraa_gpio_get_valfp(dev) != MRAA_SUCCESS) {
+ syslog(LOG_ERR, "gpio: Failed to get value file pointer");
return -1;
}
} else {
@@ -661,7 +718,7 @@ mraa_gpio_read(mraa_gpio_context dev)
}
char bu[2];
if (read(dev->value_fp, bu, 2 * sizeof(char)) != 2) {
- syslog(LOG_ERR, "gpio%i: read: Failed to read a sensible value from sysfs: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to read a sensible value from sysfs");
return -1;
}
lseek(dev->value_fp, 0, SEEK_SET);
@@ -672,10 +729,8 @@ mraa_gpio_read(mraa_gpio_context dev)
mraa_result_t
mraa_gpio_write(mraa_gpio_context dev, int value)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: write: context is invalid");
+ if (dev == NULL)
return MRAA_ERROR_INVALID_HANDLE;
- }
if (dev->mmap_write != NULL)
return dev->mmap_write(dev, value);
@@ -697,15 +752,13 @@ mraa_gpio_write(mraa_gpio_context dev, int value)
}
if (lseek(dev->value_fp, 0, SEEK_SET) == -1) {
- syslog(LOG_ERR, "gpio%i: write: Failed to lseek 'value': %s", dev->pin, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
int length = snprintf(bu, sizeof(bu), "%d", value);
if (write(dev->value_fp, bu, length * sizeof(char)) == -1) {
- syslog(LOG_ERR, "gpio%i: write: Failed to write to 'value': %s", dev->pin, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, gpio_write_post))
@@ -718,16 +771,16 @@ mraa_gpio_unexport_force(mraa_gpio_context dev)
{
int unexport = open(SYSFS_CLASS_GPIO "/unexport", O_WRONLY);
if (unexport == -1) {
- syslog(LOG_ERR, "gpio%i: Failed to open 'unexport' for writing: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to open unexport for writing");
return MRAA_ERROR_INVALID_RESOURCE;
}
char bu[MAX_SIZE];
int length = snprintf(bu, sizeof(bu), "%d", dev->pin);
if (write(unexport, bu, length * sizeof(char)) == -1) {
- syslog(LOG_ERR, "gpio%i: Failed to write to 'unexport': %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "gpio: Failed to write to unexport");
close(unexport);
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(unexport);
@@ -737,15 +790,10 @@ mraa_gpio_unexport_force(mraa_gpio_context dev)
static mraa_result_t
mraa_gpio_unexport(mraa_gpio_context dev)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: unexport: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
if (dev->owner) {
return mraa_gpio_unexport_force(dev);
}
- return MRAA_ERROR_INVALID_PARAMETER;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_result_t
@@ -753,16 +801,6 @@ mraa_gpio_close(mraa_gpio_context dev)
{
mraa_result_t result = MRAA_SUCCESS;
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: close: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, gpio_close_replace)) {
- return dev->advance_func->gpio_close_replace(dev);
- }
-
-
if (IS_FUNC_DEFINED(dev, gpio_close_pre)) {
result = dev->advance_func->gpio_close_pre(dev);
}
@@ -779,10 +817,9 @@ mraa_result_t
mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t own)
{
if (dev == NULL) {
- syslog(LOG_ERR, "gpio: owner: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
- syslog(LOG_DEBUG, "gpio%i: owner: Set owner to %d", dev->pin, (int) own);
+ syslog(LOG_DEBUG, "gpio: Set owner to %d", (int) own);
dev->owner = own;
return MRAA_SUCCESS;
}
@@ -790,16 +827,11 @@ mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t own)
mraa_result_t
mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap_en)
{
- if (dev == NULL) {
- syslog(LOG_ERR, "gpio: use_mmaped: context is invalid");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
if (IS_FUNC_DEFINED(dev, gpio_mmap_setup)) {
return dev->advance_func->gpio_mmap_setup(dev, mmap_en);
}
- syslog(LOG_ERR, "gpio%i: use_mmaped: mmap not implemented on this platform", dev->pin);
+ syslog(LOG_ERR, "gpio: mmap not implemented on this platform");
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
@@ -807,7 +839,7 @@ int
mraa_gpio_get_pin(mraa_gpio_context dev)
{
if (dev == NULL) {
- syslog(LOG_ERR, "gpio: get_pin: context is invalid");
+ syslog(LOG_ERR, "gpio: context is invalid");
return -1;
}
return dev->phy_pin;
@@ -817,7 +849,7 @@ int
mraa_gpio_get_pin_raw(mraa_gpio_context dev)
{
if (dev == NULL) {
- syslog(LOG_ERR, "gpio: get_pin: context is invalid");
+ syslog(LOG_ERR, "gpio: context is invalid");
return -1;
}
return dev->pin;
diff --git a/peripheral/libmraa/src/i2c/i2c.c b/peripheral/libmraa/src/i2c/i2c.c
index 85b0172..e196ab7 100644
--- a/peripheral/libmraa/src/i2c/i2c.c
+++ b/peripheral/libmraa/src/i2c/i2c.c
@@ -36,8 +36,7 @@
#include <sys/errno.h>
#include <sys/ioctl.h>
#include "linux/i2c-dev.h"
-#include <errno.h>
-#include <string.h>
+
typedef union i2c_smbus_data_union {
uint8_t byte; ///< data byte
@@ -79,7 +78,7 @@ mraa_i2c_init_internal(mraa_adv_func_t* advance_func, unsigned int bus)
mraa_i2c_context dev = (mraa_i2c_context) calloc(1, sizeof(struct _i2c));
if (dev == NULL) {
- syslog(LOG_CRIT, "i2c%i_init: Failed to allocate memory for context", bus);
+ syslog(LOG_CRIT, "i2c: Failed to allocate memory for context");
return NULL;
}
@@ -100,13 +99,13 @@ mraa_i2c_init_internal(mraa_adv_func_t* advance_func, unsigned int bus)
char filepath[32];
snprintf(filepath, 32, "/dev/i2c-%u", bus);
if ((dev->fh = open(filepath, O_RDWR)) < 1) {
- syslog(LOG_ERR, "i2c%i_init: Failed to open requested i2c port %s: %s", bus, filepath, strerror(errno));
- status = MRAA_ERROR_INVALID_RESOURCE;
+ syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath);
+ status = MRAA_ERROR_NO_RESOURCES;
goto init_internal_cleanup;
}
if (ioctl(dev->fh, I2C_FUNCS, &dev->funcs) < 0) {
- syslog(LOG_CRIT, "i2c%i_init: Failed to get I2C_FUNC map from device: %s", bus, strerror(errno));
+ syslog(LOG_CRIT, "i2c: Failed to get I2C_FUNC map from device");
dev->funcs = 0;
}
}
@@ -134,39 +133,39 @@ mraa_i2c_init(int bus)
{
mraa_board_t* board = plat;
if (board == NULL) {
- syslog(LOG_ERR, "i2c%i_init: Platform Not Initialised", bus);
+ syslog(LOG_ERR, "i2c: Platform Not Initialised");
return NULL;
}
if (mraa_is_sub_platform_id(bus)) {
- syslog(LOG_NOTICE, "i2c%i_init: Using sub platform", bus);
+ syslog(LOG_NOTICE, "i2c: Using sub platform");
board = board->sub_platform;
if (board == NULL) {
- syslog(LOG_ERR, "i2c%i_init: Sub platform Not Initialised", bus);
+ syslog(LOG_ERR, "i2c: Sub platform Not Initialised");
return NULL;
}
bus = mraa_get_sub_platform_index(bus);
}
- syslog(LOG_NOTICE, "i2c_init: Selected bus %d", bus);
+ syslog(LOG_NOTICE, "i2c: Selected bus %d", bus);
if (board->i2c_bus_count == 0) {
- syslog(LOG_ERR, "i2c_init: No i2c buses defined in platform");
+ syslog(LOG_ERR, "No i2c buses defined in platform");
return NULL;
}
if (bus >= board->i2c_bus_count) {
- syslog(LOG_ERR, "i2c_init: i2c%i over i2c bus count", bus);
+ syslog(LOG_ERR, "Above i2c bus count");
return NULL;
}
if (board->i2c_bus[bus].bus_id == -1) {
- syslog(LOG_ERR, "Invalid i2c bus %i, moving to default i2c bus %i", bus, board->def_i2c_bus);
+ syslog(LOG_ERR, "Invalid i2c bus, moving to default i2c bus");
bus = board->def_i2c_bus;
}
if (!board->no_bus_mux) {
int pos = board->i2c_bus[bus].sda;
if (board->pins[pos].i2c.mux_total > 0) {
if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "i2c%i_init: Failed to set-up i2c sda multiplexer", bus);
+ syslog(LOG_ERR, "i2c: Failed to set-up i2c sda multiplexer");
return NULL;
}
}
@@ -174,7 +173,7 @@ mraa_i2c_init(int bus)
pos = board->i2c_bus[bus].scl;
if (board->pins[pos].i2c.mux_total > 0) {
if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "i2c%i_init: Failed to set-up i2c scl multiplexer", bus);
+ syslog(LOG_ERR, "i2c: Failed to set-up i2c scl multiplexer");
return NULL;
}
}
@@ -214,44 +213,44 @@ mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
return length;
}
- return -1;
+ return 0;
}
-int
+uint8_t
mraa_i2c_read_byte(mraa_i2c_context dev)
{
if (IS_FUNC_DEFINED(dev, i2c_read_byte_replace))
return dev->advance_func->i2c_read_byte_replace(dev);
i2c_smbus_data_t d;
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, I2C_NOCMD, I2C_SMBUS_BYTE, &d) < 0) {
- syslog(LOG_ERR, "i2c%i: read_byte: Access error: %s", dev->busnum, strerror(errno));
- return -1;
+ syslog(LOG_ERR, "i2c: Failed to write");
+ return 0;
}
return 0x0FF & d.byte;
}
-int
+uint8_t
mraa_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
{
if (IS_FUNC_DEFINED(dev, i2c_read_byte_data_replace))
return dev->advance_func->i2c_read_byte_data_replace(dev, command);
i2c_smbus_data_t d;
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, command, I2C_SMBUS_BYTE_DATA, &d) < 0) {
- syslog(LOG_ERR, "i2c%i: read_byte_data: Access error: %s", dev->busnum, strerror(errno));
- return -1;
+ syslog(LOG_ERR, "i2c: Failed to write");
+ return 0;
}
return 0x0FF & d.byte;
}
-int
+uint16_t
mraa_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
{
if (IS_FUNC_DEFINED(dev, i2c_read_word_data_replace))
return dev->advance_func->i2c_read_word_data_replace(dev, command);
i2c_smbus_data_t d;
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_READ, command, I2C_SMBUS_WORD_DATA, &d) < 0) {
- syslog(LOG_ERR, "i2c%i: read_word_data: Access error: %s", dev->busnum, strerror(errno));
- return -1;
+ syslog(LOG_ERR, "i2c: Failed to write");
+ return 0;
}
return 0xFFFF & d.word;
}
@@ -267,23 +266,16 @@ mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, i
m[0].addr = dev->addr;
m[0].flags = 0x00;
m[0].len = 1;
- m[0].buf = (char*) &command;
+ m[0].buf = &command;
m[1].addr = dev->addr;
m[1].flags = I2C_M_RD;
m[1].len = length;
- m[1].buf = (char*) data;
+ m[1].buf = data;
d.msgs = m;
d.nmsgs = 2;
- int ret = ioctl(dev->fh, I2C_RDWR, &d);
-
- if (ret < 0)
- {
- syslog(LOG_ERR, "i2c%i: read_bytes_data: Access error: %s", dev->busnum, strerror(errno));
- return -1;
- }
- return length;
+ return ioctl(dev->fh, I2C_RDWR, &d) < 0 ? -1 : length;
}
mraa_result_t
@@ -306,11 +298,7 @@ mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length)
}
d.block[0] = length;
- if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_I2C_BLOCK_DATA, &d) < 0) {
- syslog(LOG_ERR, "i2c%i: write: Access error: %s", dev->busnum, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
- }
- return MRAA_SUCCESS;
+ return mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_I2C_BLOCK_DATA, &d);
}
mraa_result_t
@@ -320,8 +308,8 @@ mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
return dev->advance_func->i2c_write_byte_replace(dev, data);
} else {
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, data, I2C_SMBUS_BYTE, NULL) < 0) {
- syslog(LOG_ERR, "i2c%i: write_byte: Access error: %s", dev->busnum, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ syslog(LOG_ERR, "i2c: Failed to write");
+ return MRAA_ERROR_INVALID_HANDLE;
}
return MRAA_SUCCESS;
}
@@ -335,8 +323,8 @@ mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t
i2c_smbus_data_t d;
d.byte = data;
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_BYTE_DATA, &d) < 0) {
- syslog(LOG_ERR, "i2c%i: write_byte_data: Access error: %s", dev->busnum, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ syslog(LOG_ERR, "i2c: Failed to write");
+ return MRAA_ERROR_INVALID_HANDLE;
}
return MRAA_SUCCESS;
}
@@ -349,8 +337,8 @@ mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_
i2c_smbus_data_t d;
d.word = data;
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_WORD_DATA, &d) < 0) {
- syslog(LOG_ERR, "i2c%i: write_word_data: Access error: %s", dev->busnum, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ syslog(LOG_ERR, "i2c: Failed to write");
+ return MRAA_ERROR_INVALID_HANDLE;
}
return MRAA_SUCCESS;
}
@@ -367,8 +355,8 @@ mraa_i2c_address(mraa_i2c_context dev, uint8_t addr)
return dev->advance_func->i2c_address_replace(dev, addr);
} else {
if (ioctl(dev->fh, I2C_SLAVE_FORCE, addr) < 0) {
- syslog(LOG_ERR, "i2c%i: address: Failed to set slave address %d: %s", dev->busnum, addr, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
+ syslog(LOG_ERR, "i2c: Failed to set slave address %d", addr);
+ return MRAA_ERROR_INVALID_HANDLE;
}
return MRAA_SUCCESS;
}
diff --git a/peripheral/libmraa/src/iio/iio.c b/peripheral/libmraa/src/iio/iio.c
index d4d9842..fd2c7f6 100644
--- a/peripheral/libmraa/src/iio/iio.c
+++ b/peripheral/libmraa/src/iio/iio.c
@@ -33,6 +33,7 @@
#define MAX_SIZE 128
#define IIO_DEVICE "iio:device"
#define IIO_SCAN_ELEM "scan_elements"
+#define IIO_MOUNTING_MATRIX "mounting_matrix"
#define IIO_SLASH_DEV "/dev/" IIO_DEVICE
#define IIO_SYSFS_DEVICE "/sys/bus/iio/devices/" IIO_DEVICE
#define IIO_EVENTS "events"
@@ -82,7 +83,6 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
int padint = 0;
int curr_bytes = 0;
char shortbuf, signchar;
- int i = 0;
dev->datasize = 0;
@@ -129,6 +129,12 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
ret = sscanf(readbuf, "%ce:%c%u/%u>>%u", &shortbuf, &signchar, &chan->bits_used,
&padint, &chan->shift);
chan->bytes = padint / 8;
+ if (curr_bytes % chan->bytes == 0) {
+ chan->location = curr_bytes;
+ } else {
+ chan->location = curr_bytes - curr_bytes % chan->bytes + chan->bytes;
+ }
+ curr_bytes = chan->location + chan->bytes;
// probably should be 5?
if (ret < 0) {
// cleanup
@@ -169,18 +175,6 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
}
closedir(dir);
- // channel location has to be done in channel index order so do it afetr we
- // have grabbed all the correct info
- for (i = 0; i < dev->chan_num; i++) {
- chan = &dev->channels[i];
- if (curr_bytes % chan->bytes == 0) {
- chan->location = curr_bytes;
- } else {
- chan->location = curr_bytes - curr_bytes % chan->bytes + chan->bytes;
- }
- curr_bytes = chan->location + chan->bytes;
- }
-
return MRAA_SUCCESS;
}
@@ -283,7 +277,7 @@ mraa_iio_write_string(mraa_iio_context dev, const char* attr_name, const char* d
snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/%s", dev->num, attr_name);
int fd = open(buf, O_WRONLY);
if (fd != -1) {
- int len = strlen(data);
+ size_t len = strlen(data);
ssize_t status = write(fd, data, len);
if (status == len)
result = MRAA_SUCCESS;
@@ -545,18 +539,18 @@ mraa_iio_event_extract_event(struct iio_event_data* event,
}
mraa_result_t
-mraa_iio_get_mount_matrix(mraa_iio_context dev, const char *sysfs_name, float mm[9])
+mraa_iio_get_mounting_matrix(mraa_iio_context dev, float mm[9])
{
char buf[MAX_SIZE];
FILE* fp;
int ret;
memset(buf, 0, MAX_SIZE);
- snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/%s", dev->num, sysfs_name);
+ snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_MOUNTING_MATRIX, dev->num);
fp = fopen(buf, "r");
if (fp != NULL) {
- ret = fscanf(fp, "%f, %f, %f; %f, %f, %f; %f, %f, %f\n", &mm[0], &mm[1], &mm[2], &mm[3],
- &mm[4], &mm[5],&mm[6], &mm[7], &mm[8]);
+ ret = fscanf(fp, "%f %f %f\n%f %f %f\n%f %f %f\n", &mm[0], &mm[1], &mm[2], &mm[3], &mm[4], &mm[5],
+ &mm[6], &mm[7], &mm[8]);
fclose(fp);
if (ret != 9) {
return MRAA_ERROR_UNSPECIFIED;
diff --git a/peripheral/libmraa/src/java/CMakeLists.txt b/peripheral/libmraa/src/java/CMakeLists.txt
index fbcbe6e..33ec6af 100644
--- a/peripheral/libmraa/src/java/CMakeLists.txt
+++ b/peripheral/libmraa/src/java/CMakeLists.txt
@@ -1,4 +1,5 @@
FIND_PACKAGE (JNI REQUIRED)
+
include_directories (
${JAVA_INCLUDE_PATH}
${JAVA_INCLUDE_PATH2}
@@ -14,7 +15,7 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DJAVACALLBACK")
if (NOT DEFINED ENV{JAVA_HOME_NATIVE})
if (NOT DEFINED ENV{JAVA_HOME})
- message (FATAL_ERROR "Neither JAVA_HOME nor JAVA_HOME_NATIVE are set")
+ message (FATAL_ERROR " - Neither JAVA_HOME nor JAVA_HOME_NATIVE are set")
endif()
set (JAVA_HOME_NATIVE $ENV{JAVA_HOME})
set (JAVAC $ENV{JAVA_HOME}/bin/javac)
@@ -24,8 +25,8 @@ else ()
set (JAR $ENV{JAVA_HOME_NATIVE}/bin/jar)
endif ()
-swig_add_module (mraajava java mraajava.i mraajni.c)
-swig_link_libraries (mraajava ${JAVA_LIBRARIES} mraa)
+swig_add_module (mraajava java mraajava.i ${mraa_LIB_SRCS})
+swig_link_libraries (mraajava ${JAVA_LIBRARIES} ${mraa_LIBS})
add_custom_command (TARGET mraajava
POST_BUILD
@@ -33,7 +34,7 @@ add_custom_command (TARGET mraajava
COMMAND cmake -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/mraa
COMMAND ${JAVAC} *.java -d ${CMAKE_CURRENT_BINARY_DIR}
COMMAND cmake -E echo "Creating jar"
- COMMAND ${JAR} cvmf manifest.txt mraa.jar mraa
+ COMMAND ${JAR} cvf mraa.jar mraa
)
if (DOXYGEN_FOUND)
@@ -42,7 +43,7 @@ if (DOXYGEN_FOUND)
endforeach ()
endif ()
-mraa_create_install_pkgconfig (mraajava.pc ${LIB_INSTALL_DIR}/pkgconfig)
+mraa_create_install_pkgconfig (mraajava.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-install (TARGETS mraajava LIBRARY DESTINATION ${LIB_INSTALL_DIR})
-install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.jar DESTINATION ${LIB_INSTALL_DIR}/../lib/java)
+install (TARGETS mraajava LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.jar DESTINATION ${CMAKE_INSTALL_LIBDIR}/../lib/java)
diff --git a/peripheral/libmraa/src/java/manifest.txt.in b/peripheral/libmraa/src/java/manifest.txt.in
deleted file mode 100644
index a1e98ef..0000000
--- a/peripheral/libmraa/src/java/manifest.txt.in
+++ /dev/null
@@ -1,7 +0,0 @@
-Manifest-version: 1.0
-
-Name: mraa/
-Specification-Title: mraa
-Specification-Version: @VERSION_SHORT@
-Package-Title: mraa
-Package-Version: @VERSION_SHORT@
diff --git a/peripheral/libmraa/src/java/mraajava.i b/peripheral/libmraa/src/java/mraajava.i
index 52d8e5f..9dc7142 100644
--- a/peripheral/libmraa/src/java/mraajava.i
+++ b/peripheral/libmraa/src/java/mraajava.i
@@ -65,26 +65,13 @@ class Spi;
%include ../mraa.i
%wrapper %{
- #include "java/mraajni.h"
- #include "mraa_lang_func.h"
- extern mraa_lang_func_t* lang_func;
+ JavaVM *globVM;
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
- /* initialize mraa and set jni functions */
- mraa_result_t res = mraa_init();
- if (res == MRAA_SUCCESS) {
- mraa_java_set_jvm(vm);
- lang_func->java_isr_callback = &mraa_java_isr_callback;
- lang_func->java_attach_thread = &mraa_java_attach_thread;
- lang_func->java_detach_thread = &mraa_java_detach_thread;
- lang_func->java_create_global_ref = &mraa_java_create_global_ref;
- lang_func->java_delete_global_ref = &mraa_java_delete_global_ref;
- } else {
- JNIEnv* jenv;
- vm->GetEnv((void**)&jenv, JNI_REQUIRED_VERSION);
- SWIG_JavaException(jenv, SWIG_RuntimeError, "mraa_init() failed");
- }
- return JNI_REQUIRED_VERSION;
+ /* initialize mraa */
+ globVM = vm;
+ mraa_init();
+ return JNI_VERSION_1_6;
}
%}
@@ -96,34 +83,5 @@ class Spi;
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
}
-
- String javaAPIVersion = mraa.class.getPackage().getSpecificationVersion();
- String nativeAPIVersion = mraa.getVersion().substring(1);
-
- String javaMajor = javaAPIVersion.substring(0, javaAPIVersion.indexOf('.'));
- String nativeMajor = nativeAPIVersion.substring(0, nativeAPIVersion.indexOf('.'));
-
- if(Integer.parseInt(javaMajor) < Integer.parseInt(nativeMajor)){
- System.err.println("Java library is out of date. Please update the Java library.");
- System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
- System.exit(1);
- }
- if(Integer.parseInt(javaMajor) > Integer.parseInt(nativeMajor)){
- System.err.println("Native library is out of date. Please update the Native library.");
- System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
- System.exit(1);
- }
-
- String javaMinor = javaAPIVersion.substring(javaMajor.length() + 1, javaAPIVersion.indexOf('.', javaMajor.length() + 1));
- String nativeMinor = nativeAPIVersion.substring(nativeMajor.length() + 1, nativeAPIVersion.indexOf('.', nativeMajor.length() + 1));
-
- if(Integer.parseInt(javaMinor) < Integer.parseInt(nativeMinor)){
- System.err.println("Java library is out of date. Please consider updating the Java library.");
- System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
- }
- if(Integer.parseInt(javaMinor) > Integer.parseInt(nativeMinor)){
- System.err.println("Native library is out of date. Please consider updating the Native library.");
- System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
- }
}
%}
diff --git a/peripheral/libmraa/src/java/mraajni.c b/peripheral/libmraa/src/java/mraajni.c
deleted file mode 100644
index e5c6e6f..0000000
--- a/peripheral/libmraa/src/java/mraajni.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 <pthread.h>
-#include "java/mraajni.h"
-
-static pthread_key_t env_key;
-static pthread_once_t env_key_init = PTHREAD_ONCE_INIT;
-static jmethodID runGlobal;
-static JavaVM* globVM = NULL;
-
-
-void
-mraa_java_set_jvm(JavaVM* vm)
-{
- globVM = vm;
-}
-
-static void
-mraa_java_make_env_key(void)
-{
- if (globVM != NULL) {
- JNIEnv* jenv;
- (*globVM)->GetEnv(globVM, (void**) &jenv, JNI_REQUIRED_VERSION);
- jclass rcls = (*jenv)->FindClass(jenv, "java/lang/Runnable");
- jmethodID runm = (*jenv)->GetMethodID(jenv, rcls, "run", "()V");
- runGlobal = (jmethodID)(*jenv)->NewGlobalRef(jenv, (jobject) runm);
- pthread_key_create(&env_key, NULL);
- }
-}
-
-void
-mraa_java_isr_callback(void* data)
-{
- JNIEnv* jenv = (JNIEnv*) pthread_getspecific(env_key);
- (*jenv)->CallVoidMethod(jenv, (jobject) data, runGlobal);
-}
-
-mraa_result_t
-mraa_java_attach_thread()
-{
- if (globVM != NULL) {
- JNIEnv* jenv;
- jint err = (*globVM)->AttachCurrentThreadAsDaemon(globVM, (void**) &jenv, NULL);
- if (err == JNI_OK) {
- pthread_once(&env_key_init, mraa_java_make_env_key);
- pthread_setspecific(env_key, jenv);
- return MRAA_SUCCESS;
- }
- }
- return MRAA_ERROR_UNSPECIFIED;
-}
-
-void
-mraa_java_detach_thread()
-{
- if (globVM != NULL)
- (*globVM)->DetachCurrentThread(globVM);
-}
-
-void*
-mraa_java_create_global_ref(void* args)
-{
- if (globVM != NULL) {
- JNIEnv* jenv;
- (*globVM)->GetEnv(globVM, (void**) &jenv, JNI_REQUIRED_VERSION);
- jobject grunnable = (*jenv)->NewGlobalRef(jenv, (jobject) args);
- return (void*) grunnable;
- } else
- return NULL;
-}
-
-void
-mraa_java_delete_global_ref(void* ref)
-{
- if (globVM != NULL) {
- JNIEnv* jenv;
- (*globVM)->GetEnv(globVM, (void**) &jenv, JNI_REQUIRED_VERSION);
- (*jenv)->DeleteGlobalRef(jenv, (jobject) ref);
- }
-}
diff --git a/peripheral/libmraa/src/javascript/CMakeLists.txt b/peripheral/libmraa/src/javascript/CMakeLists.txt
index d54d77a..7885dad 100644
--- a/peripheral/libmraa/src/javascript/CMakeLists.txt
+++ b/peripheral/libmraa/src/javascript/CMakeLists.txt
@@ -13,7 +13,7 @@ set (V8_VERSION_HEX 0x0${V8_VERSION_MAJOR}${V8_VERSION_MINOR}${V8_VERSION_PATCH}
string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length)
while (V8_VERSION_HEX_length LESS 8)
set (V8_VERSION_HEX "${V8_VERSION_HEX}0")
- message (STATUS "INFO - Padded V8 version to match SWIG format")
+ message (DEBUG " - Padded V8 version to match SWIG format")
string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length)
endwhile ()
@@ -21,8 +21,8 @@ set_property (SOURCE mraajs.i PROPERTY SWIG_FLAGS "-node"
"-I${CMAKE_BINARY_DIR}/src" "-DV8_VERSION=${V8_VERSION_HEX}")
set_source_files_properties (mraajs.i PROPERTIES CPLUSPLUS ON)
-swig_add_module (mraajs javascript mraajs.i)
-swig_link_libraries (mraajs mraa)
+swig_add_module (mraajs javascript mraajs.i ${mraa_LIB_SRCS})
+swig_link_libraries (mraajs ${mraa_LIBS})
set_target_properties (mraajs PROPERTIES
COMPILE_FLAGS " -DBUILDING_NODE_EXTENSION -DSWIGJAVASCRIPT=${SWIG_FOUND}"
@@ -31,45 +31,35 @@ set_target_properties (mraajs PROPERTIES
SUFFIX ".node"
)
-message (STATUS "INFO - swig Version ${SWIG_VERSION}")
-message (STATUS "INFO - CXX compiler Version ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
+message (INFO " - swig Version ${SWIG_VERSION}")
+message (INFO " - CXX compiler Version ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
if (${V8_VERSION_MAJOR} GREATER 3)
- message (STATUS "INFO - Using V8 version > 3 so requiring C++11 compiler")
+ message (INFO " - Using V8 version > 3 so requiring C++11 compiler")
# Node 0.12.x V8 engine major version is '3'.
# Node 2.1.0 V8 engine major version is '4'.
set_property (TARGET mraajs PROPERTY CXX_STANDARD 11)
set_property (TARGET mraajs PROPERTY CXX_STANDARD_REQUIRED ON)
- if (CMAKE_VERSION VERSION_LESS "3.1")
- message (WARNING "Need to use CMAKE version 3.1+, but it is ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}, using a workaround.")
- if (CMAKE_COMPILER_IS_GNUCXX)
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
- message (FATAL_ERROR "GNU gcc compiler is also too old (need 4.7+, but ${CMAKE_CXX_COMPILER_VERSION}) and does not support C++11 standard.")
- endif ()
- set (MRAA_CXX11_WORKAROUND_OPTION "-std=gnu++11")
- else ()
- set (MRAA_CXX11_WORKAROUND_OPTION "-std=c++11")
- endif ()
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CXX11_WORKAROUND_OPTION} ")
- endif ()
+ if(CMAKE_VERSION VERSION_LESS "3.1")
+ message(INFO " - **WARNING** Need to use CMAKE version 3.1+, but it is ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
+ message(INFO " - So a workaround will be used.")
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
+ message(FATAL_ERROR " FATAL ERROR: GNU gcc compiler is also too old (need 4.7+, but ${CMAKE_CXX_COMPILER_VERSION}) and does not support C++11 standard.")
+ endif()
+ set(MRAA_CXX11_WORKAROUND_OPTION "-std=gnu++11")
+ else()
+ set(MRAA_CXX11_WORKAROUND_OPTION "-std=c++11")
+ endif()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CXX11_WORKAROUND_OPTION} ")
+ endif()
endif ()
-# If a CMAKE_INSTALL_PREFIX has NOT been provided, set NODE_MODULE_INSTALL_PATH
-# base on the NODE_ROOT_DIR.
-if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set (NODE_MODULE_INSTALL_PATH ${NODE_ROOT_DIR}/lib/node_modules/mraa/)
-# If a CMAKE_INSTALL_PREFIX has been provided, set NODE_MODULE_INSTALL_PATH
-# relative to the provide install directory.
-else (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set (NODE_MODULE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/node_modules/mraa/)
-endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-message (STATUS "INFO - install NODE modules to ${NODE_MODULE_INSTALL_PATH}")
-
macro (mraa_CREATE_INSTALL_PACKAGE_JSON generated_file install_location)
configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro (mraa_CREATE_INSTALL_PACKAGE_JSON)
-mraa_create_install_package_json (package.json ${NODE_MODULE_INSTALL_PATH})
+mraa_create_install_package_json (package.json lib/node_modules/mraa)
macro (mraa_CREATE_BINDING_GYP generated_file)
set (mraa_LIB_SRCS_GYP "")
@@ -116,9 +106,9 @@ if (BUILDDOC)
COMMENT "Generating API documentation with Yuidoc" VERBATIM
)
else ()
- message (STATUS "INFO - Failed to find Yuidoc. node.js API doc will not be generated")
+ message (INFO " - Failed to find Yuidoc. node.js API doc will not be generated")
endif ()
endif ()
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.node
- DESTINATION ${NODE_MODULE_INSTALL_PATH})
+ DESTINATION lib/node_modules/mraa)
diff --git a/peripheral/libmraa/src/javascript/binding.gyp.cmake b/peripheral/libmraa/src/javascript/binding.gyp.cmake
index 6de4dc3..4675e26 100644
--- a/peripheral/libmraa/src/javascript/binding.gyp.cmake
+++ b/peripheral/libmraa/src/javascript/binding.gyp.cmake
@@ -3,39 +3,34 @@
{
'target_name': 'mraa',
'sources': [
- @mraa_LIB_SRCS_GYP@
- 'src/version.c',
- 'src/mraajsJAVASCRIPT_wrap.cxx'
- ],
+@mraa_LIB_SRCS_GYP@
+'src/version.c',
+'src/mraajsJAVASCRIPT_wrap.cxx' ],
'include_dirs': [
- @mraa_LIB_INCLUDE_DIRS_GYP@
- ],
+@mraa_LIB_INCLUDE_DIRS_GYP@
+ ],
'variables': {
- "v8_version%": "<!(node -e 'console.log(process.versions.v8)' | sed 's/\.//g' | cut -c 1-5)",
- "arch%": "<!(node -e 'console.log(process.arch)')"
+ "v8_version%": "<!(node -e 'console.log(process.versions.v8)' | sed 's/\.//g' | cut -c 1-5)",
+ "arch%": "<!(node -e 'console.log(process.arch)')"
},
'cflags_cc!': [ '-fno-rtti', '-fno-exceptions' ],
'cflags!': [ '-fno-exceptions' ],
'conditions' : [
- ['OS=="android"', {
- 'sources' : [ 'src/glob/glob.c' ],
- 'include_dirs' : [ 'src/glob' ],
- }],
- [ 'arch=="x64" or arch=="ia32"', {
- 'defines' : [ 'X86PLAT=ON' ],
- }],
- [ 'arch=="arm"', {
- 'defines' : [ 'ARMPLAT=ON'],
- }],
+ [ 'arch=="x64"',
+ { 'defines' : [ 'X86PLAT=ON' ], },
+ ],
+ [ 'arch=="ia32"',
+ { 'defines' : [ 'X86PLAT=ON'], },
+ ],
+ [ 'arch=="arm"',
+ { 'defines' : [ 'ARMPLAT=ON'], },
+ ],
],
- 'defines' : [
- 'SWIG',
- 'SWIGJAVASCRIPT',
- 'FIRMATA=ON',
- 'ONEWIRE=ON',
- 'BUILDING_NODE_EXTENSION=1',
- 'SWIG_V8_VERSION=0x0<(v8_version)',
- 'V8_VERSION=0x0<(v8_version)'
+ 'defines' : [ 'SWIG',
+ 'SWIGJAVASCRIPT',
+ 'BUILDING_NODE_EXTENSION=1',
+ 'SWIG_V8_VERSION=0x0<(v8_version)',
+ 'V8_VERSION=0x0<(v8_version)'
]
}
]
diff --git a/peripheral/libmraa/src/javascript/doxygen2jsdoc_custom.json b/peripheral/libmraa/src/javascript/doxygen2jsdoc_custom.json
index c5095e0..e5a2af6 100644
--- a/peripheral/libmraa/src/javascript/doxygen2jsdoc_custom.json
+++ b/peripheral/libmraa/src/javascript/doxygen2jsdoc_custom.json
@@ -65,7 +65,7 @@
},
"func": {
"type": "Function",
- "description": "Function to be called when interrupt is triggered"
+ "description": "Function to be called when interupt is triggered"
}
},
"return": {
diff --git a/peripheral/libmraa/src/javascript/mraajs.i b/peripheral/libmraa/src/javascript/mraajs.i
index 321cc22..7ff07fa 100644
--- a/peripheral/libmraa/src/javascript/mraajs.i
+++ b/peripheral/libmraa/src/javascript/mraajs.i
@@ -135,10 +135,5 @@ class Spi;
%init %{
//Adding mraa_init() to the module initialisation process
- if (mraa_init() != MRAA_SUCCESS) {
- // FIXME: Figure out why SWIG_Error causes seg fault.
- // Warn on stderr for time being
- // SWIG_Error(SWIG_RuntimeError, "mraa_init() failed");
- fprintf(stderr, "Javascript Runtime Error: mraa_init() failed.\n");
- }
+ mraa_init();
%}
diff --git a/peripheral/libmraa/src/javascript/package.json.cmake b/peripheral/libmraa/src/javascript/package.json.cmake
index 8dee7a7..49dd744 100644
--- a/peripheral/libmraa/src/javascript/package.json.cmake
+++ b/peripheral/libmraa/src/javascript/package.json.cmake
@@ -1,7 +1,7 @@
{
"name" : "mraa",
"description": "IO library that helps you use I2c, SPI, gpio, uart, pwm, analog inputs (aio) and more on a number of platforms such as the Intel galileo, the Intel edison and others",
- "keywords":["gpio", "edison","galileo","io", "mraajs", "spi", "i2c", "minnow", "intel", "firmata"],
+ "keywords":["gpio", "edison","galileo","io", "mraajs", "spi", "i2c", "minnow", "intel"],
"homepage": "http://github.com/intel-iot-devkit/mraa",
"main" : "./mraa.node",
"engines": {
diff --git a/peripheral/libmraa/src/mraa.c b/peripheral/libmraa/src/mraa.c
index 62d97ad..b8bc236 100644
--- a/peripheral/libmraa/src/mraa.c
+++ b/peripheral/libmraa/src/mraa.c
@@ -40,32 +40,14 @@
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <ctype.h>
-#include <limits.h>
-
-#if defined(IMRAA)
-#include <json-c/json.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#endif
#include "mraa_internal.h"
-#include "firmata/firmata_mraa.h"
#include "gpio.h"
#include "version.h"
-#include "i2c.h"
-#include "pwm.h"
-#include "aio.h"
-#include "spi.h"
-#include "uart.h"
-
#define IIO_DEVICE_WILDCARD "iio:device*"
mraa_board_t* plat = NULL;
mraa_iio_info_t* plat_iio = NULL;
-mraa_lang_func_t* lang_func = NULL;
static char* platform_name = NULL;
static char* platform_long_name = NULL;
@@ -91,15 +73,16 @@ mraa_set_log_level(int level)
return MRAA_ERROR_INVALID_PARAMETER;
}
-/**
- * Whilst the actual mraa init function is now called imraa_init, it's only
- * callable externally if IMRAA is enabled
- */
+
+#if (defined SWIGPYTHON) || (defined SWIG)
mraa_result_t
-imraa_init()
+#else
+mraa_result_t __attribute__((constructor))
+#endif
+mraa_init()
{
if (plat != NULL) {
- return MRAA_SUCCESS;
+ return MRAA_ERROR_PLATFORM_ALREADY_INITIALISED;
}
uid_t proc_euid = geteuid();
@@ -115,6 +98,13 @@ imraa_init()
syslog(LOG_NOTICE, "libmraa version %s initialised by user '%s' with EUID %d",
mraa_get_version(), (proc_user != NULL) ? proc_user->pw_name : "<unknown>", proc_euid);
+#ifdef SWIGPYTHON
+ // Initialise python threads, this allows use to grab the GIL when we are
+ // required to do so
+ Py_InitializeEx(0);
+ PyEval_InitThreads();
+#endif
+
mraa_platform_t platform_type;
#if defined(X86PLAT)
// Use runtime x86 platform detection
@@ -132,7 +122,8 @@ imraa_init()
platform_name = NULL;
}
- // Create null base platform if one doesn't already exist
+#if defined(USBPLAT)
+ // This is a platform extender so create null base platform if one doesn't already exist
if (plat == NULL) {
plat = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
if (plat != NULL) {
@@ -140,8 +131,6 @@ imraa_init()
plat->platform_name = "Unknown platform";
}
}
-
-#if defined(USBPLAT)
// Now detect sub platform, note this is not an else since we could be in
// an error case and fall through to MRAA_ERROR_PLATFORM_NOT_INITIALISED
if (plat != NULL) {
@@ -157,11 +146,6 @@ imraa_init()
}
#endif
-#if defined(IMRAA)
- const char* subplatform_lockfile = "/tmp/imraa.lock";
- mraa_add_from_lockfile(subplatform_lockfile);
-#endif
-
// Look for IIO devices
mraa_iio_detect();
@@ -179,29 +163,10 @@ imraa_init()
}
}
- lang_func = (mraa_lang_func_t*) calloc(1, sizeof(mraa_lang_func_t));
- if (lang_func == NULL) {
- return MRAA_ERROR_NO_RESOURCES;
- }
-
syslog(LOG_NOTICE, "libmraa initialised for platform '%s' of type %d", mraa_get_platform_name(), mraa_get_platform_type());
return MRAA_SUCCESS;
}
-#if (defined SWIGPYTHON) || (defined SWIG)
-mraa_result_t
-#else
-mraa_result_t __attribute__((constructor))
-#endif
-mraa_init()
-{
- if (plat != NULL) {
- return MRAA_SUCCESS;
- } else {
- return imraa_init();
- }
-}
-
void
mraa_deinit()
{
@@ -226,7 +191,7 @@ mraa_deinit()
}
int
-mraa_set_priority(const int priority)
+mraa_set_priority(const unsigned int priority)
{
struct sched_param sched_s;
@@ -288,168 +253,27 @@ mraa_iio_detect()
return MRAA_SUCCESS;
}
+
mraa_result_t
mraa_setup_mux_mapped(mraa_pin_t meta)
{
- unsigned int mi;
- mraa_result_t ret;
- mraa_gpio_context mux_i = NULL;
- // avoids the unsigned comparison and we should never have a pin that is UINT_MAX!
- unsigned int last_pin = UINT_MAX;
+ int mi;
for (mi = 0; mi < meta.mux_total; mi++) {
+ mraa_gpio_context mux_i;
+ mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
+ if (mux_i == NULL) {
+ return MRAA_ERROR_INVALID_HANDLE;
+ }
+ // this function will sometimes fail, however this is not critical as
+ // long as the write succeeds - Test case galileo gen2 pin2
+ mraa_gpio_dir(mux_i, MRAA_GPIO_OUT);
+ mraa_gpio_owner(mux_i, 0);
- switch(meta.mux[mi].pincmd) {
- case PINCMD_UNDEFINED: // used for backward compatibility
- if(meta.mux[mi].pin != last_pin) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
- if (mux_i == NULL) return MRAA_ERROR_INVALID_HANDLE;
- last_pin = meta.mux[mi].pin;
- }
- // this function will sometimes fail, however this is not critical as
- // long as the write succeeds - Test case galileo gen2 pin2
- mraa_gpio_dir(mux_i, MRAA_GPIO_OUT);
- ret = mraa_gpio_write(mux_i, meta.mux[mi].value);
- if(ret != MRAA_SUCCESS) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- break;
-
- case PINCMD_SET_VALUE:
- if(meta.mux[mi].pin != last_pin) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
- if (mux_i == NULL) return MRAA_ERROR_INVALID_HANDLE;
- last_pin = meta.mux[mi].pin;
- }
-
- ret = mraa_gpio_write(mux_i, meta.mux[mi].value);
-
- if(ret != MRAA_SUCCESS) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- break;
-
- case PINCMD_SET_DIRECTION:
- if(meta.mux[mi].pin != last_pin) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
- if (mux_i == NULL) return MRAA_ERROR_INVALID_HANDLE;
- last_pin = meta.mux[mi].pin;
- }
-
- ret = mraa_gpio_dir(mux_i, meta.mux[mi].value);
-
- if(ret != MRAA_SUCCESS) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- break;
-
- case PINCMD_SET_IN_VALUE:
- if(meta.mux[mi].pin != last_pin) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
- if (mux_i == NULL) return MRAA_ERROR_INVALID_HANDLE;
- last_pin = meta.mux[mi].pin;
- }
-
- ret = mraa_gpio_dir(mux_i, MRAA_GPIO_IN);
-
- if(ret == MRAA_SUCCESS)
- ret = mraa_gpio_write(mux_i, meta.mux[mi].value);
-
- if(ret != MRAA_SUCCESS) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- break;
-
- case PINCMD_SET_OUT_VALUE:
- if(meta.mux[mi].pin != last_pin) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
- if (mux_i == NULL) return MRAA_ERROR_INVALID_HANDLE;
- last_pin = meta.mux[mi].pin;
- }
-
- ret = mraa_gpio_dir(mux_i, MRAA_GPIO_OUT);
-
- if(ret == MRAA_SUCCESS)
- ret = mraa_gpio_write(mux_i, meta.mux[mi].value);
-
- if(ret != MRAA_SUCCESS) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- break;
-
- case PINCMD_SET_MODE:
- if(meta.mux[mi].pin != last_pin) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- mux_i = mraa_gpio_init_raw(meta.mux[mi].pin);
- if (mux_i == NULL) return MRAA_ERROR_INVALID_HANDLE;
- last_pin = meta.mux[mi].pin;
- }
-
- ret = mraa_gpio_mode(mux_i, meta.mux[mi].value);
-
- if(ret != MRAA_SUCCESS) {
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
- mraa_gpio_close(mux_i);
- }
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- break;
-
- case PINCMD_SKIP:
- break;
-
- default:
- syslog(LOG_NOTICE, "mraa_setup_mux_mapped: wrong command %d on pin %d with value %d", meta.mux[mi].pincmd, meta.mux[mi].pin, meta.mux[mi].value);
- break;
+ if (mraa_gpio_write(mux_i, meta.mux[mi].value) != MRAA_SUCCESS) {
+ mraa_gpio_close(mux_i);
+ return MRAA_ERROR_INVALID_RESOURCE;
}
- }
-
- if (mux_i != NULL) {
- mraa_gpio_owner(mux_i, 0);
mraa_gpio_close(mux_i);
}
@@ -496,14 +320,8 @@ mraa_result_print(mraa_result_t result)
case MRAA_ERROR_PLATFORM_NOT_INITIALISED:
fprintf(stdout, "MRAA: Platform not initialised.\n");
break;
- case MRAA_ERROR_UART_OW_SHORTED:
- fprintf(stdout, "MRAA: UART OW: Bus short detected.\n");
- break;
- case MRAA_ERROR_UART_OW_NO_DEVICES:
- fprintf(stdout, "MRAA: UART OW: No devices detected on bus.\n");
- break;
- case MRAA_ERROR_UART_OW_DATA_ERROR:
- fprintf(stdout, "MRAA: UART OW: Data or Bus error detected.\n");
+ case MRAA_ERROR_PLATFORM_ALREADY_INITIALISED:
+ fprintf(stdout, "MRAA: Platform already initialised.\n");
break;
case MRAA_ERROR_UNSPECIFIED:
fprintf(stdout, "MRAA: Unspecified Error.\n");
@@ -537,7 +355,7 @@ mraa_pin_mode_test(int pin, mraa_pinmodes_t mode)
pin = mraa_get_sub_platform_index(pin);
}
- if (current_plat == NULL || current_plat->platform_type == MRAA_UNKNOWN_PLATFORM || current_plat->platform_type == MRAA_NULL_PLATFORM) {
+ if (current_plat == NULL || current_plat->platform_type == MRAA_UNKNOWN_PLATFORM) {
return 0;
}
if (pin > (current_plat->phy_pin_count - 1) || pin < 0)
@@ -685,7 +503,7 @@ mraa_get_i2c_bus_count()
}
int
-mraa_get_i2c_bus_id(int i2c_bus)
+mraa_get_i2c_bus_id(unsigned i2c_bus)
{
if (plat == NULL) {
return -1;
@@ -986,251 +804,3 @@ mraa_get_iio_device_count()
{
return plat_iio->iio_device_count;
}
-
-mraa_result_t
-mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev)
-{
-#if defined(FIRMATA)
- if (subplatformtype == MRAA_GENERIC_FIRMATA) {
- if (plat->sub_platform != NULL) {
- return MRAA_ERROR_INVALID_PARAMETER;
- }
- if (mraa_firmata_platform(plat, uart_dev) == MRAA_GENERIC_FIRMATA) {
- syslog(LOG_NOTICE, "mraa: Added firmata subplatform");
- return MRAA_SUCCESS;
- }
- syslog(LOG_NOTICE, "mraa: Failed to add firmata subplatform");
- }
-#endif
-
- return MRAA_ERROR_INVALID_PARAMETER;
-}
-
-mraa_result_t
-mraa_remove_subplatform(mraa_platform_t subplatformtype)
-{
-#if defined(FIRMATA)
- if (subplatformtype == MRAA_GENERIC_FIRMATA) {
- if (plat == NULL || plat->sub_platform == NULL) {
- return MRAA_ERROR_INVALID_PARAMETER;
- }
- free(plat->sub_platform->adv_func);
- free(plat->sub_platform->pins);
- free(plat->sub_platform);
- }
-#endif
- return MRAA_ERROR_INVALID_PARAMETER;
-}
-
-#if defined(IMRAA)
-mraa_result_t
-mraa_add_from_lockfile(const char* imraa_lock_file)
-{
- mraa_result_t ret = MRAA_SUCCESS;
- mraa_platform_t type = plat->platform_type;
- char* buffer = NULL;
- off_t file_size;
- struct stat st;
- int i = 0;
- uint32_t subplat_num = 0;
- int flock = open(imraa_lock_file, O_RDONLY);
- if (flock == -1) {
- syslog(LOG_ERR, "imraa: Failed to open lock file");
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- if (fstat(flock, &st) != 0 || (!S_ISREG(st.st_mode))) {
- close(flock);
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- buffer = mmap(0, st.st_size, PROT_READ, MAP_SHARED, flock, 0);
- close(flock);
- if (buffer == MAP_FAILED) {
- syslog(LOG_ERR, "imraa: lockfile read error");
- return MRAA_ERROR_INVALID_RESOURCE;
- }
- json_object* jobj_lock = json_tokener_parse(buffer);
-
- struct json_object* ioarray;
- if (json_object_object_get_ex(jobj_lock, "Platform", &ioarray) == true &&
- json_object_is_type(ioarray, json_type_array)) {
- subplat_num = json_object_array_length(ioarray);
- int id = -1;
- const char* uartdev = NULL;
- for (i = 0; i < subplat_num; i++) {
- struct json_object *ioobj = json_object_array_get_idx(ioarray, i);
- json_object_object_foreach(ioobj, key, val) {
- if (strcmp(key, "id") == 0) {
- id = atoi(json_object_get_string(val));
- } else if (strcmp(key, "uart") == 0) {
- uartdev = json_object_get_string(val);
- }
- }
- if (id != -1 && id != MRAA_NULL_PLATFORM && id != MRAA_UNKNOWN_PLATFORM && uartdev != NULL) {
- if (mraa_add_subplatform(id, uartdev) == MRAA_SUCCESS) {
- syslog(LOG_NOTICE, "imraa: automatically added subplatform %d, %s", id, uartdev);
- } else {
- syslog(LOG_ERR, "imraa: Failed to add subplatform (%d on %s) from lockfile", id, uartdev);
- }
- id = -1;
- uartdev = NULL;
- }
- }
- } else {
- ret = MRAA_ERROR_INVALID_RESOURCE;
- }
- json_object_put(jobj_lock);
- munmap(buffer, st.st_size);
- return ret;
-}
-#endif
-
-void
-mraa_to_upper(char* s)
-{
- char* t = s;
- for (; *t; ++t) {
- *t = toupper(*t);
- }
-}
-
-mraa_result_t
-mraa_atoi(char* intStr, int* value)
-{
- char* end;
- // here 10 determines the number base in which strol is to work
- long val = strtol(intStr, &end, 10);
- if (*end != '\0' || errno == ERANGE || end == intStr || val > INT_MAX || val < INT_MIN) {
- *value = 0;
- return MRAA_ERROR_UNSPECIFIED;
- }
- *value = (int) val;
- return MRAA_SUCCESS;
-}
-
-mraa_result_t
-mraa_init_io_helper(char** str, int* value, const char* delim)
-{
- // This function is a result of a repeated pattern within mraa_init_io
- // when determining if a value can be derived from a string
- char* token;
- token = strsep(str, delim);
- // check to see if empty string returned
- if (token == NULL) {
- *value = 0;
- return MRAA_ERROR_NO_DATA_AVAILABLE;
- }
- return mraa_atoi(token, value);
-}
-
-void*
-mraa_init_io(const char* desc)
-{
- const char* delim = "-";
- int length = 0, raw = 0;
- int pin = 0, id = 0;
- // 256 denotes the maximum size of our buffer
- // 8 denotes the maximum size of our type rounded to the nearest power of 2
- // max size is 4 + 1 for the \0 = 5 rounded to 8
- char buffer[256] = { 0 }, type[8] = { 0 };
- char *token = 0, *str = 0;
- if (desc == NULL) {
- return NULL;
- }
- length = strlen(desc);
- // Check to see the length is less than or equal to 255 which means
- // byte 256 is supposed to be \0
- if (length > 255 || length == 0) {
- return NULL;
- }
- strncpy(buffer, desc, length);
-
- str = buffer;
- token = strsep(&str, delim);
- length = strlen(token);
- // Check to see they haven't given us a type whose length is greater than the
- // largest type we know about
- if (length > 4) {
- syslog(LOG_ERR, "mraa_init_io: An invalid IO type was provided");
- return NULL;
- }
- strncpy(type, token, length);
- mraa_to_upper(type);
- token = strsep(&str, delim);
- // Check that they've given us more information than just the type
- if (token == NULL) {
- syslog(LOG_ERR, "mraa_init_io: Missing information after type");
- return NULL;
- }
- // If we cannot convert the pin to a number maybe it says raw?
- if (mraa_atoi(token, &pin) != MRAA_SUCCESS) {
- mraa_to_upper(token);
- if (strncmp(token, "RAW", 3)) {
- syslog(LOG_ERR, "mraa_init_io: Description does not adhere to a known format");
- return NULL;
- }
- raw = 1;
- }
- if (!raw && str != NULL) {
- syslog(LOG_ERR, "mraa_init_io: More information than required was provided");
- return NULL;
- }
-
- if (strncmp(type, "GPIO", 4) == 0) {
- if (raw) {
- if (mraa_init_io_helper(&str, &pin, delim) == MRAA_SUCCESS) {
- return (void*) mraa_gpio_init_raw(pin);
- }
- syslog(LOG_ERR, "mraa_init_io: Invalid Raw description for GPIO");
- return NULL;
- }
- return (void*) mraa_gpio_init(pin);
- } else if (strncmp(type, "I2C", 3) == 0) {
- if (raw) {
- if (mraa_init_io_helper(&str, &pin, delim) == MRAA_SUCCESS) {
- return (void*) mraa_i2c_init_raw(pin);
- }
- syslog(LOG_ERR, "mraa_init_io: Invalid Raw description for I2C");
- return NULL;
- }
- return (void*) mraa_i2c_init(pin);
- } else if (strncmp(type, "AIO", 3) == 0) {
- if (raw) {
- syslog(LOG_ERR, "mraa_init_io: Aio doesn't have a RAW mode");
- return NULL;
- }
- return (void*) mraa_aio_init(pin);
- } else if (strncmp(type, "PWM", 3) == 0) {
- if (raw) {
- if (mraa_init_io_helper(&str, &id, delim) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "mraa_init_io: Pwm, unable to convert the chip id string into a useable Int");
- return NULL;
- }
- if (mraa_init_io_helper(&str, &pin, delim) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "mraa_init_io: Pwm, unable to convert the pin string into a useable Int");
- return NULL;
- }
- return (void*) mraa_pwm_init_raw(id, pin);
- }
- return (void*) mraa_pwm_init(pin);
- } else if (strncmp(type, "SPI", 3) == 0) {
- if (raw) {
- if (mraa_init_io_helper(&str, &id, delim) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "mraa_init_io: Spi, unable to convert the bus string into a useable Int");
- return NULL;
- }
- if (mraa_init_io_helper(&str, &pin, delim) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "mraa_init_io: Spi, unable to convert the cs string into a useable Int");
- return NULL;
- }
- return (void*) mraa_spi_init_raw(id, pin);
- }
- return (void*) mraa_spi_init(pin);
- } else if (strncmp(type, "UART", 4) == 0) {
- if (raw) {
- return (void*) mraa_uart_init_raw(str);
- }
- return (void*) mraa_uart_init(pin);
- }
- syslog(LOG_ERR, "mraa_init_io: Invalid IO type given.");
- return NULL;
-}
diff --git a/peripheral/libmraa/src/mraa.i b/peripheral/libmraa/src/mraa.i
index 4810a51..5259951 100644
--- a/peripheral/libmraa/src/mraa.i
+++ b/peripheral/libmraa/src/mraa.i
@@ -41,19 +41,6 @@
%include "types.hpp"
%include "common.hpp"
-%template (gpioFromDesc) mraa::initIo<mraa::Gpio>;
-%template (aioFromDesc) mraa::initIo<mraa::Aio>;
-%template (uartFromDesc) mraa::initIo<mraa::Uart>;
-%template (spiFromDesc) mraa::initIo<mraa::Spi>;
-%template (i2cFromDesc) mraa::initIo<mraa::I2c>;
-%template (pwmFromDesc) mraa::initIo<mraa::Pwm>;
-
-%ignore Aio(void* aio_context);
-%ignore Pwm(void* pwm_context);
-%ignore Uart(void* uart_context);
-%ignore Spi(void* spi_context);
-%ignore I2c(void* i2c_context);
-%ignore Gpio(void* gpio_context);
%ignore Gpio::nop(uv_work_t* req);
%ignore Gpio::v8isr(uv_work_t* req);
diff --git a/peripheral/libmraa/src/mraa.pc.cmake b/peripheral/libmraa/src/mraa.pc.cmake
index 33de3af..fb5c0b1 100644
--- a/peripheral/libmraa/src/mraa.pc.cmake
+++ b/peripheral/libmraa/src/mraa.pc.cmake
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${exec_prefix}/@LIB_INSTALL_DIR@
+libdir=${exec_prefix}/lib@LIB_SUFFIX@
includedir=${prefix}/include
Name: mraa
diff --git a/peripheral/libmraa/src/pwm/pwm.c b/peripheral/libmraa/src/pwm/pwm.c
index 43a5ba4..f8decce 100644
--- a/peripheral/libmraa/src/pwm/pwm.c
+++ b/peripheral/libmraa/src/pwm/pwm.c
@@ -27,8 +27,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
-#include <errno.h>
-#include <string.h>
#include "pwm.h"
#include "mraa_internal.h"
@@ -52,11 +50,6 @@ mraa_pwm_setup_duty_fp(mraa_pwm_context dev)
static mraa_result_t
mraa_pwm_write_period(mraa_pwm_context dev, int period)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: write_period: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
if (IS_FUNC_DEFINED(dev, pwm_period_replace)) {
mraa_result_t result = dev->advance_func->pwm_period_replace(dev, period);
if (result == MRAA_SUCCESS) {
@@ -69,14 +62,13 @@ mraa_pwm_write_period(mraa_pwm_context dev, int period)
int period_f = open(bu, O_RDWR);
if (period_f == -1) {
- syslog(LOG_ERR, "pwm%i write_period: Failed to open period for writing: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to open period for writing");
return MRAA_ERROR_INVALID_RESOURCE;
}
char out[MAX_SIZE];
int length = snprintf(out, MAX_SIZE, "%d", period);
if (write(period_f, out, length * sizeof(char)) == -1) {
close(period_f);
- syslog(LOG_ERR, "pwm%i write_period: Failed to write to period: %s", dev->pin, strerror(errno));
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -88,67 +80,48 @@ mraa_pwm_write_period(mraa_pwm_context dev, int period)
static mraa_result_t
mraa_pwm_write_duty(mraa_pwm_context dev, int duty)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: write_duty: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, pwm_write_replace)) {
- return dev->advance_func->pwm_write_replace(dev, duty);
- }
if (dev->duty_fp == -1) {
if (mraa_pwm_setup_duty_fp(dev) == 1) {
- syslog(LOG_ERR, "pwm%i write_duty: Failed to open duty_cycle for writing: %s", dev->pin, strerror(errno));
- return MRAA_ERROR_INVALID_RESOURCE;
+ return MRAA_ERROR_INVALID_HANDLE;
}
}
char bu[64];
int length = sprintf(bu, "%d", duty);
if (write(dev->duty_fp, bu, length * sizeof(char)) == -1)
- {
- syslog(LOG_ERR, "pwm%i write_duty: Failed to write to duty_cycle: %s", dev->pin, strerror(errno));
return MRAA_ERROR_INVALID_RESOURCE;
- }
return MRAA_SUCCESS;
}
static int
mraa_pwm_read_period(mraa_pwm_context dev)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: read_period: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, pwm_read_replace)) {
- return dev->period;
- }
-
char bu[MAX_SIZE];
char output[MAX_SIZE];
snprintf(bu, MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/period", dev->chipid, dev->pin);
int period_f = open(bu, O_RDWR);
if (period_f == -1) {
- syslog(LOG_ERR, "pwm%i read_period: Failed to open period for reading: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to open period for reading");
return 0;
}
+ off_t size = lseek(period_f, 0, SEEK_END);
+ lseek(period_f, 0, SEEK_SET);
- ssize_t rb = read(period_f, output, MAX_SIZE);
+ ssize_t rb = read(period_f, output, size + 1);
close(period_f);
if (rb < 0) {
- syslog(LOG_ERR, "pwm%i read_period: Failed to read period: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Error in reading period");
return -1;
}
char* endptr;
long int ret = strtol(output, &endptr, 10);
if ('\0' != *endptr && '\n' != *endptr) {
- syslog(LOG_ERR, "pwm%i read_period: Error in string conversion", dev->pin);
+ syslog(LOG_ERR, "pwm: Error in string conversion");
return -1;
} else if (ret > INT_MAX || ret < INT_MIN) {
- syslog(LOG_ERR, "pwm%i read_period: Number is invalid", dev->pin);
+ syslog(LOG_ERR, "pwm: Number is invalid");
return -1;
}
dev->period = (int) ret;
@@ -158,39 +131,29 @@ mraa_pwm_read_period(mraa_pwm_context dev)
static int
mraa_pwm_read_duty(mraa_pwm_context dev)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: read_duty: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, pwm_read_replace)) {
- return dev->advance_func->pwm_read_replace(dev);
- }
-
if (dev->duty_fp == -1) {
if (mraa_pwm_setup_duty_fp(dev) == 1) {
- syslog(LOG_ERR, "pwm%i read_duty: Failed to open duty_cycle for reading: %s",
- dev->pin, strerror(errno));
- return -1;
+ return MRAA_ERROR_INVALID_HANDLE;
}
} else {
lseek(dev->duty_fp, 0, SEEK_SET);
}
-
+ off_t size = lseek(dev->duty_fp, 0, SEEK_END);
+ lseek(dev->duty_fp, 0, SEEK_SET);
char output[MAX_SIZE];
- ssize_t rb = read(dev->duty_fp, output, MAX_SIZE);
+ ssize_t rb = read(dev->duty_fp, output, size + 1);
if (rb < 0) {
- syslog(LOG_ERR, "pwm%i read_duty: Failed to read duty_cycle: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Error in reading duty");
return -1;
}
char* endptr;
long int ret = strtol(output, &endptr, 10);
if ('\0' != *endptr && '\n' != *endptr) {
- syslog(LOG_ERR, "pwm%i read_duty: Error in string conversion", dev->pin);
+ syslog(LOG_ERR, "pwm: Error in string converstion");
return -1;
} else if (ret > INT_MAX || ret < INT_MIN) {
- syslog(LOG_ERR, "pwm%i read_duty: Number is invalid", dev->pin);
+ syslog(LOG_ERR, "pwm: Number is invalid");
return -1;
}
return (int) ret;
@@ -215,75 +178,66 @@ mraa_pwm_init_internal(mraa_adv_func_t* func_table, int chipin, int pin)
mraa_pwm_context
mraa_pwm_init(int pin)
{
- mraa_board_t* board = plat;
- if (board == NULL) {
- syslog(LOG_ERR, "pwm_init: Platform Not Initialised");
+ if (plat == NULL) {
+ syslog(LOG_ERR, "pwm: Platform Not Initialised");
return NULL;
}
if (mraa_is_sub_platform_id(pin)) {
- syslog(LOG_NOTICE, "pwm_init: Using sub platform");
- board = board->sub_platform;
- if (board == NULL) {
- syslog(LOG_ERR, "pwm_init: Sub platform Not Initialised");
- return NULL;
- }
- pin = mraa_get_sub_platform_index(pin);
+ syslog(LOG_NOTICE, "pwm: Using sub platform is not supported");
+ return NULL;
}
- if (pin < 0 || pin > board->phy_pin_count) {
- syslog(LOG_ERR, "pwm_init: pin %i beyond platform definition", pin);
+ if (pin < 0 || pin > plat->phy_pin_count) {
+ syslog(LOG_ERR, "pwm: pin %i beyond platform definition", pin);
return NULL;
}
- if (board->pins[pin].capabilites.pwm != 1) {
- syslog(LOG_ERR, "pwm_init: pin %i not capable of pwm", pin);
+ if (plat->pins[pin].capabilites.pwm != 1) {
+ syslog(LOG_ERR, "pwm: pin not capable of pwm");
return NULL;
}
- if (board->adv_func->pwm_init_replace != NULL) {
- return board->adv_func->pwm_init_replace(pin);
+ if (plat->adv_func->pwm_init_replace != NULL) {
+ return plat->adv_func->pwm_init_replace(pin);
}
- if (board->adv_func->pwm_init_internal_replace != NULL) {
- return board->adv_func->pwm_init_internal_replace(board->adv_func, pin);
- }
- if (board->adv_func->pwm_init_pre != NULL) {
- if (board->adv_func->pwm_init_pre(pin) != MRAA_SUCCESS)
+ if (plat->adv_func->pwm_init_pre != NULL) {
+ if (plat->adv_func->pwm_init_pre(pin) != MRAA_SUCCESS)
return NULL;
}
- if (board->pins[pin].capabilites.gpio == 1) {
+ if (plat->pins[pin].capabilites.gpio == 1) {
// This deserves more investigation
mraa_gpio_context mux_i;
- mux_i = mraa_gpio_init_raw(board->pins[pin].gpio.pinmap);
+ mux_i = mraa_gpio_init_raw(plat->pins[pin].gpio.pinmap);
if (mux_i == NULL) {
- syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_init", pin);
+ syslog(LOG_ERR, "pwm: error in gpio->pwm transition");
return NULL;
}
if (mraa_gpio_dir(mux_i, MRAA_GPIO_OUT) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_dir", pin);
+ syslog(LOG_ERR, "pwm: error in gpio->pwm transition");
return NULL;
}
if (mraa_gpio_write(mux_i, 1) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_write", pin);
+ syslog(LOG_ERR, "pwm: error in gpio->pwm transition");
return NULL;
}
if (mraa_gpio_close(mux_i) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_close", pin);
+ syslog(LOG_ERR, "pwm: error in gpio->pwm transition");
return NULL;
}
}
- if (board->pins[pin].pwm.mux_total > 0) {
- if (mraa_setup_mux_mapped(board->pins[pin].pwm) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "pwm_init: Failed to set-up pwm%i multiplexer", pin);
+ if (plat->pins[pin].pwm.mux_total > 0) {
+ if (mraa_setup_mux_mapped(plat->pins[pin].pwm) != MRAA_SUCCESS) {
+ syslog(LOG_ERR, "pwm: Failed to set-up multiplexer");
return NULL;
}
}
- int chip = board->pins[pin].pwm.parent_id;
- int pinn = board->pins[pin].pwm.pinmap;
+ int chip = plat->pins[pin].pwm.parent_id;
+ int pinn = plat->pins[pin].pwm.pinmap;
- if (board->adv_func->pwm_init_post != NULL) {
+ if (plat->adv_func->pwm_init_post != NULL) {
mraa_pwm_context pret = mraa_pwm_init_raw(chip, pinn);
- mraa_result_t ret = board->adv_func->pwm_init_post(pret);
+ mraa_result_t ret = plat->adv_func->pwm_init_post(pret);
if (ret != MRAA_SUCCESS) {
free(pret);
return NULL;
@@ -304,14 +258,14 @@ mraa_pwm_init_raw(int chipin, int pin)
snprintf(directory, MAX_SIZE, SYSFS_PWM "/pwmchip%d/pwm%d", dev->chipid, dev->pin);
struct stat dir;
if (stat(directory, &dir) == 0 && S_ISDIR(dir.st_mode)) {
- syslog(LOG_NOTICE, "pwm_init: pwm%i already exported, continuing", pin);
+ syslog(LOG_NOTICE, "pwm: Pin already exported, continuing");
dev->owner = 0; // Not Owner
} else {
char buffer[MAX_SIZE];
snprintf(buffer, MAX_SIZE, "/sys/class/pwm/pwmchip%d/export", dev->chipid);
int export_f = open(buffer, O_WRONLY);
if (export_f == -1) {
- syslog(LOG_ERR, "pwm_init: pwm%i. Failed to open export for writing: %s", pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to open export for writing");
free(dev);
return NULL;
}
@@ -319,7 +273,7 @@ mraa_pwm_init_raw(int chipin, int pin)
char out[MAX_SIZE];
int size = snprintf(out, MAX_SIZE, "%d", dev->pin);
if (write(export_f, out, size * sizeof(char)) == -1) {
- syslog(LOG_WARNING, "pwm_init: pwm%i. Failed to write to export! (%s) Potentially already in use.", pin, strerror(errno));
+ syslog(LOG_WARNING, "pwm: Failed to write to export! Potentially already enabled");
close(export_f);
free(dev);
return NULL;
@@ -335,25 +289,13 @@ mraa_pwm_init_raw(int chipin, int pin)
mraa_result_t
mraa_pwm_write(mraa_pwm_context dev, float percentage)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: write: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, pwm_write_pre)) {
- if (dev->advance_func->pwm_write_pre(dev, percentage) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "mraa_pwm_write (pwm%i): pwm_write_pre failed, see syslog", dev->pin);
- return MRAA_ERROR_UNSPECIFIED;
- }
- }
-
if (dev->period == -1) {
if (mraa_pwm_read_period(dev) <= 0)
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
if (percentage > 1.0f) {
- syslog(LOG_WARNING, "pwm_write: %i%% entered, defaulting to 100%%",(int) percentage * 100);
+ syslog(LOG_WARNING, "pwm: number greater than 1 entered, defaulting to 100%%");
return mraa_pwm_write_duty(dev, dev->period);
}
return mraa_pwm_write_duty(dev, percentage * dev->period);
@@ -362,11 +304,6 @@ mraa_pwm_write(mraa_pwm_context dev, float percentage)
float
mraa_pwm_read(mraa_pwm_context dev)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: read: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
int period = mraa_pwm_read_period(dev);
if (period > 0) {
return (mraa_pwm_read_duty(dev) / (float) period);
@@ -389,22 +326,8 @@ mraa_pwm_period_ms(mraa_pwm_context dev, int ms)
mraa_result_t
mraa_pwm_period_us(mraa_pwm_context dev, int us)
{
- int min, max;
-
- if (!dev) {
- syslog(LOG_ERR, "pwm: period: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (mraa_is_sub_platform_id(dev->chipid)) {
- min = plat->sub_platform->pwm_min_period;
- max = plat->sub_platform->pwm_max_period;
- } else {
- min = plat->pwm_min_period;
- max = plat->pwm_max_period;
- }
- if (us < min || us > max) {
- syslog(LOG_ERR, "pwm_period: pwm%i: %i uS outside platform range", dev->pin, us);
+ if (us < plat->pwm_min_period || us > plat->pwm_max_period) {
+ syslog(LOG_ERR, "pwm: period value outside platform range");
return MRAA_ERROR_INVALID_PARAMETER;
}
return mraa_pwm_write_period(dev, us * 1000);
@@ -431,37 +354,27 @@ mraa_pwm_pulsewidth_us(mraa_pwm_context dev, int us)
mraa_result_t
mraa_pwm_enable(mraa_pwm_context dev, int enable)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: enable: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (IS_FUNC_DEFINED(dev, pwm_enable_replace)) {
- return dev->advance_func->pwm_enable_replace(dev, enable);
- }
-
- if (IS_FUNC_DEFINED(dev, pwm_enable_pre)) {
- if (dev->advance_func->pwm_enable_pre(dev, enable) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "mraa_pwm_enable (pwm%i): pwm_enable_pre failed, see syslog", dev->pin);
- return MRAA_ERROR_UNSPECIFIED;
- }
+ int status;
+ if (enable != 0) {
+ status = 1;
+ } else {
+ status = enable;
}
-
char bu[MAX_SIZE];
snprintf(bu, MAX_SIZE, "/sys/class/pwm/pwmchip%d/pwm%d/enable", dev->chipid, dev->pin);
int enable_f = open(bu, O_RDWR);
if (enable_f == -1) {
- syslog(LOG_ERR, "pwm_enable: pwm%i: Failed to open enable for writing: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to open enable for writing");
return MRAA_ERROR_INVALID_RESOURCE;
}
char out[2];
int size = snprintf(out, sizeof(out), "%d", enable);
if (write(enable_f, out, size * sizeof(char)) == -1) {
- syslog(LOG_ERR, "pwm_enable: pwm%i: Failed to write to enable: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to write to enable");
close(enable_f);
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(enable_f);
return MRAA_SUCCESS;
@@ -475,16 +388,16 @@ mraa_pwm_unexport_force(mraa_pwm_context dev)
int unexport_f = open(filepath, O_WRONLY);
if (unexport_f == -1) {
- syslog(LOG_ERR, "pwm_unexport: pwm%i: Failed to open unexport for writing: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to open unexport for writing");
return MRAA_ERROR_INVALID_RESOURCE;
}
char out[MAX_SIZE];
int size = snprintf(out, MAX_SIZE, "%d", dev->pin);
if (write(unexport_f, out, size * sizeof(char)) == -1) {
- syslog(LOG_ERR, "pwm_unexport: pwm%i: Failed to write to unexport: %s", dev->pin, strerror(errno));
+ syslog(LOG_ERR, "pwm: Failed to write to unexport");
close(unexport_f);
- return MRAA_ERROR_UNSPECIFIED;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
close(unexport_f);
@@ -494,26 +407,16 @@ mraa_pwm_unexport_force(mraa_pwm_context dev)
mraa_result_t
mraa_pwm_unexport(mraa_pwm_context dev)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: unexport: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
mraa_pwm_enable(dev, 0);
if (dev->owner) {
return mraa_pwm_unexport_force(dev);
}
- return MRAA_ERROR_INVALID_PARAMETER;
+ return MRAA_ERROR_INVALID_RESOURCE;
}
mraa_result_t
mraa_pwm_close(mraa_pwm_context dev)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: close: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
mraa_pwm_unexport(dev);
free(dev);
return MRAA_SUCCESS;
@@ -522,46 +425,74 @@ mraa_pwm_close(mraa_pwm_context dev)
mraa_result_t
mraa_pwm_owner(mraa_pwm_context dev, mraa_boolean_t owner_new)
{
- if (!dev) {
- syslog(LOG_ERR, "pwm: owner: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
+ if (dev == NULL)
+ return MRAA_ERROR_INVALID_RESOURCE;
dev->owner = owner_new;
return MRAA_SUCCESS;
}
-int
-mraa_pwm_get_max_period(mraa_pwm_context dev)
+mraa_result_t
+mraa_pwm_config_ms(mraa_pwm_context dev, int ms, float ms_float)
{
- if (plat == NULL) {
- return -1;
+ int old_dutycycle, old_period, status;
+ old_dutycycle = mraa_pwm_read_duty(dev);
+ old_period = mraa_pwm_read_period(dev);
+ status = mraa_pwm_period_us(dev, ms * 1000);
+ if (status != MRAA_SUCCESS) {
+ mraa_pwm_write_duty(dev, old_dutycycle);
+ return status;
+ }
+ status = mraa_pwm_write_duty(dev, 0);
+ if (status != MRAA_SUCCESS) {
+ return status;
+ }
+ status = mraa_pwm_pulsewidth_us(dev, ms_float * 1000);
+ if (status != MRAA_SUCCESS) {
+ mraa_pwm_write_duty(dev, old_dutycycle);
+ mraa_pwm_write_period(dev, old_period);
+ return status;
}
+ return MRAA_SUCCESS;
+}
- if (!dev) {
- syslog(LOG_ERR, "pwm: get_max_period: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
+mraa_result_t
+mraa_pwm_config_percent(mraa_pwm_context dev, int ms, float percentage)
+{
+ int old_dutycycle, old_period, status;
+ old_dutycycle = mraa_pwm_read_duty(dev);
+ old_period = mraa_pwm_read_period(dev);
+ status = mraa_pwm_period_us(dev, ms * 1000);
+ if (status != MRAA_SUCCESS) {
+ mraa_pwm_write_duty(dev, old_dutycycle);
+ return status;
+ }
+ status = mraa_pwm_write_duty(dev, 0);
+ if (status != MRAA_SUCCESS) {
+ return status;
+ }
+ status = mraa_pwm_pulsewidth_us(dev, (ms * 1000) * percentage);
+ if (status != MRAA_SUCCESS) {
+ mraa_pwm_write_duty(dev, old_dutycycle);
+ mraa_pwm_write_period(dev, old_period);
+ return status;
}
+ return MRAA_SUCCESS;
+}
- if (mraa_is_sub_platform_id(dev->chipid)) {
- return plat->sub_platform->pwm_max_period;
+int
+mraa_pwm_get_max_period()
+{
+ if (plat == NULL) {
+ return -1;
}
return plat->pwm_max_period;
}
int
-mraa_pwm_get_min_period(mraa_pwm_context dev)
+mraa_pwm_get_min_period()
{
if (plat == NULL) {
return -1;
}
-
- if (!dev) {
- syslog(LOG_ERR, "pwm: get_min_period: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- if (mraa_is_sub_platform_id(dev->chipid)) {
- return plat->sub_platform->pwm_min_period;
- }
return plat->pwm_min_period;
}
diff --git a/peripheral/libmraa/src/python/CMakeLists.txt b/peripheral/libmraa/src/python/CMakeLists.txt
index e014fad..1d06b82 100644
--- a/peripheral/libmraa/src/python/CMakeLists.txt
+++ b/peripheral/libmraa/src/python/CMakeLists.txt
@@ -1,5 +1,52 @@
-set_source_files_properties (mraapython.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties (mraapython.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
+find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED)
-add_subdirectory (python2)
-add_subdirectory (python3)
+INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+ ${PYTHON_INCLUDE_DIRS}
+)
+
+set_source_files_properties (mraa.i PROPERTIES CPLUSPLUS ON)
+set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
+swig_add_module (python-mraa python mraa.i ${mraa_LIB_SRCS})
+swig_link_libraries (python-mraa ${PYTHON_LIBRARIES} ${mraa_LIBS})
+
+if (DOXYGEN_FOUND)
+ foreach (_file ${DOCCLASSES})
+ add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} ${_file}class_doc_i)
+ endforeach ()
+ add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} common_hpp_doc_i)
+
+ add_custom_target (pydoc
+ pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Generating API documentation with pydoc" VERBATIM
+ )
+endif ()
+
+set_target_properties (${SWIG_MODULE_python-mraa_REAL_NAME} PROPERTIES
+ OUTPUT_NAME _mraa
+ COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND}"
+)
+
+execute_process (
+ COMMAND ${PYTHON_EXECUTABLE} -c
+ "import site, sys; sys.stdout.write(site.PREFIXES[-1])"
+ OUTPUT_VARIABLE PYTHON_PREFIX
+)
+file (TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX)
+execute_process (
+ COMMAND ${PYTHON_EXECUTABLE} -c
+ "import site, sys; sys.stdout.write(site.getusersitepackages().replace(site.getuserbase(), site.PREFIXES[-1]))"
+ OUTPUT_VARIABLE PYTHON_SITE_DIR
+)
+file (TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR)
+string (REGEX REPLACE "^${PYTHON_PREFIX}/" ""
+ PYTHON_SITE_DIR "${PYTHON_SITE_DIR}")
+
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa.so
+ ${CMAKE_CURRENT_BINARY_DIR}/mraa.py
+ DESTINATION ${PYTHON_SITE_DIR})
+
+add_subdirectory (docs)
diff --git a/peripheral/libmraa/src/python/python2/docs/CMakeLists.txt b/peripheral/libmraa/src/python/docs/CMakeLists.txt
index c2a7c98..9ce7880 100644
--- a/peripheral/libmraa/src/python/python2/docs/CMakeLists.txt
+++ b/peripheral/libmraa/src/python/docs/CMakeLists.txt
@@ -36,6 +36,6 @@ if (DOXYGEN_FOUND)
COMMENT "Building HTML documentation with Sphinx"
)
- add_dependencies (sphinx ${SWIG_MODULE_python2-mraa_REAL_NAME})
+ add_dependencies (sphinx ${SWIG_MODULE_python-mraa_REAL_NAME})
endif ()
endif ()
diff --git a/peripheral/libmraa/src/python/python2/docs/conf.py.in b/peripheral/libmraa/src/python/docs/conf.py.in
index fa662ff..344abe1 100644
--- a/peripheral/libmraa/src/python/python2/docs/conf.py.in
+++ b/peripheral/libmraa/src/python/docs/conf.py.in
@@ -19,7 +19,7 @@ import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-sys.path.insert(0, "@CMAKE_BINARY_DIR@/src/python/python2")
+sys.path.insert(0, "@CMAKE_BINARY_DIR@/src/python")
# -- General configuration ------------------------------------------------
diff --git a/peripheral/libmraa/src/python/python2/docs/example.rst b/peripheral/libmraa/src/python/docs/example.rst
index ab11be5..4daf98c 100644
--- a/peripheral/libmraa/src/python/python2/docs/example.rst
+++ b/peripheral/libmraa/src/python/docs/example.rst
@@ -16,13 +16,13 @@ Here is the simplest Gpio program in mraa.
:prepend: import mraa
:start-after: import mraa
-GPIO Interrupt (isr)
+GPIO Interupt (isr)
===================
-The GPIO module allows you to set an interrupt on a GPIO. This interrupt is
+The GPIO module allows you to set an interupt on a GPIO. This interupt is
controlled by the mode that the 'edge' is in. Before setting another isr please
remove the first one, multiple isrs on one pin are not supported. Some
-platforms will not support interrupts on all pins so please check your return
+platforms will not support interupts on all pins so please check your return
values.
**Note:** Galileo Gen1 only supports EDGE_BOTH
diff --git a/peripheral/libmraa/src/python/python2/docs/index.rst b/peripheral/libmraa/src/python/docs/index.rst
index cbdbab0..cbdbab0 100644
--- a/peripheral/libmraa/src/python/python2/docs/index.rst
+++ b/peripheral/libmraa/src/python/docs/index.rst
diff --git a/peripheral/libmraa/src/python/python2/docs/mraa.rst b/peripheral/libmraa/src/python/docs/mraa.rst
index 04e7c1e..04e7c1e 100644
--- a/peripheral/libmraa/src/python/python2/docs/mraa.rst
+++ b/peripheral/libmraa/src/python/docs/mraa.rst
diff --git a/peripheral/libmraa/src/python/mraapython.i b/peripheral/libmraa/src/python/mraa.i
index 521ef53..64d086e 100644
--- a/peripheral/libmraa/src/python/mraapython.i
+++ b/peripheral/libmraa/src/python/mraa.i
@@ -1,3 +1,7 @@
+%module(docstring="Python interface to libmraa") mraa
+
+%feature("autodoc", "3");
+
%include typemaps.i
%include carrays.i
@@ -145,19 +149,6 @@ class Spi;
%include ../mraa.i
%init %{
- #include "python/mraapy.h"
- #include "mraa_lang_func.h"
- extern mraa_lang_func_t* lang_func;
- // Initialise python threads, this allows use to grab the GIL when we are
- // required to do so
- Py_InitializeEx(0);
- PyEval_InitThreads();
- // Add mraa_init() to the module initialisation process and set isr function
- mraa_result_t res = mraa_init();
- if (res == MRAA_SUCCESS) {
- lang_func->python_isr = &mraa_python_isr;
- }
- else
- SWIG_Error(SWIG_RuntimeError, "mraa_init() failed");
-
+ //Adding mraa_init() to the module initialisation process
+ mraa_init();
%}
diff --git a/peripheral/libmraa/src/python/mraapy.c b/peripheral/libmraa/src/python/mraapy.c
deleted file mode 100644
index 84b8c36..0000000
--- a/peripheral/libmraa/src/python/mraapy.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 <syslog.h>
-#include <Python.h>
-#include "python/mraapy.h"
-
-
-// In order to call a python object (all python functions are objects) we
-// need to aquire the GIL (Global Interpreter Lock). This may not always be
-// necessary but especially if doing IO (like print()) python will segfault
-// if we do not hold a lock on the GIL
-void
-mraa_python_isr(void (*isr)(void*), void* isr_args)
-{
-
- PyGILState_STATE gilstate = PyGILState_Ensure();
- PyObject* arglist;
- PyObject* ret;
- arglist = Py_BuildValue("(O)", isr_args);
- if (arglist == NULL) {
- syslog(LOG_ERR, "gpio: Py_BuildValue NULL");
- } else {
- ret = PyEval_CallObject((PyObject*) isr, arglist);
- if (ret == NULL) {
- syslog(LOG_ERR, "gpio: PyEval_CallObject failed");
- PyObject *pvalue, *ptype, *ptraceback;
- PyObject *pvalue_pystr, *ptype_pystr, *ptraceback_pystr;
- char *pvalue_cstr, *ptype_cstr, *ptraceback_cstr;
- PyErr_Fetch(&pvalue, &ptype, &ptraceback);
- pvalue_pystr = PyObject_Str(pvalue);
- ptype_pystr = PyObject_Str(ptype);
- ptraceback_pystr = PyObject_Str(ptraceback);
-// Python2
-#if PY_VERSION_HEX < 0x03000000
- pvalue_cstr = PyString_AsString(pvalue_pystr);
- ptype_cstr = PyString_AsString(ptype_pystr);
- ptraceback_cstr = PyString_AsString(ptraceback_pystr);
-// Python 3 and up
-#elif PY_VERSION_HEX >= 0x03000000
- // In Python 3 we need one extra conversion
- PyObject *pvalue_ustr, *ptype_ustr, *ptraceback_ustr;
- pvalue_ustr = PyUnicode_AsUTF8String(pvalue_pystr);
- pvalue_cstr = PyBytes_AsString(pvalue_ustr);
- ptype_ustr = PyUnicode_AsUTF8String(ptype_pystr);
- ptype_cstr = PyBytes_AsString(ptype_ustr);
- ptraceback_ustr = PyUnicode_AsUTF8String(ptraceback_pystr);
- ptraceback_cstr = PyBytes_AsString(ptraceback_ustr);
-#endif // PY_VERSION_HEX
- syslog(LOG_ERR, "gpio: the error was %s:%s:%s", pvalue_cstr, ptype_cstr, ptraceback_cstr);
- Py_XDECREF(pvalue);
- Py_XDECREF(ptype);
- Py_XDECREF(ptraceback);
- Py_XDECREF(pvalue_pystr);
- Py_XDECREF(ptype_pystr);
- Py_XDECREF(ptraceback_pystr);
-// Python 3 and up
-#if PY_VERSION_HEX >= 0x03000000
- Py_XDECREF(pvalue_ustr);
- Py_XDECREF(ptype_ustr);
- Py_XDECREF(ptraceback_ustr);
-#endif // PY_VERSION_HEX
- } else {
- Py_DECREF(ret);
- }
- Py_DECREF(arglist);
- }
-
- PyGILState_Release(gilstate);
-}
diff --git a/peripheral/libmraa/src/python/python2/CMakeLists.txt b/peripheral/libmraa/src/python/python2/CMakeLists.txt
deleted file mode 100644
index 10d23c2..0000000
--- a/peripheral/libmraa/src/python/python2/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-set_source_files_properties (mraa2.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties (mraa2.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
-
-if (PYTHON2_LIBRARY)
- message ("PYTHON2 attempting to build!")
-
- swig_add_module (python2-mraa python mraa2.i ../mraapy.c)
- swig_link_libraries (python2-mraa ${PYTHON2_LIBRARIES} mraa)
-
- target_include_directories(${SWIG_MODULE_python2-mraa_REAL_NAME}
- PUBLIC
- "${CMAKE_CURRENT_SOURCE_DIR}/../.."
- "${PYTHON2_INCLUDE_DIR}"
- )
-
- if (DOXYGEN_FOUND AND PYTHON2_EXECUTABLE)
- foreach (_file ${DOCCLASSES})
- add_dependencies (${SWIG_MODULE_python2-mraa_REAL_NAME} ${_file}class_doc_i)
- endforeach ()
- add_dependencies (${SWIG_MODULE_python2-mraa_REAL_NAME} common_hpp_doc_i)
-
- add_custom_target (pydoc
- pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "Generating API documentation with pydoc" VERBATIM
- )
- endif ()
-
- set_target_properties (${SWIG_MODULE_python2-mraa_REAL_NAME} PROPERTIES
- OUTPUT_NAME _mraa
- COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND}"
- )
-
- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa.so
- ${CMAKE_CURRENT_BINARY_DIR}/mraa.py
- DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON2_PACKAGES_PATH})
-endif()
-
-add_subdirectory (docs)
diff --git a/peripheral/libmraa/src/python/python2/mraa2.i b/peripheral/libmraa/src/python/python2/mraa2.i
deleted file mode 100644
index 81f9158..0000000
--- a/peripheral/libmraa/src/python/python2/mraa2.i
+++ /dev/null
@@ -1,5 +0,0 @@
-%module(docstring="Python interface to libmraa") mraa
-
-%feature("autodoc", "3");
-
-%include ../mraapython.i
diff --git a/peripheral/libmraa/src/python/python3/CMakeLists.txt b/peripheral/libmraa/src/python/python3/CMakeLists.txt
deleted file mode 100644
index 5fb8822..0000000
--- a/peripheral/libmraa/src/python/python3/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-set_source_files_properties (mraa3.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties (mraa3.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
-
-if (PYTHON3_LIBRARY)
- message ("PYTHON3 attempting to build!")
-
- swig_add_module (python3-mraa python mraa3.i ../mraapy.c)
- swig_link_libraries (python3-mraa ${PYTHON3_LIBRARIES} mraa)
-
- target_include_directories(${SWIG_MODULE_python3-mraa_REAL_NAME}
- PUBLIC
- "${CMAKE_CURRENT_SOURCE_DIR}/../.."
- "${PYTHON3_INCLUDE_DIR}"
- )
-
- set_target_properties (${SWIG_MODULE_python3-mraa_REAL_NAME} PROPERTIES
- OUTPUT_NAME _mraa
- COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND}"
- )
-
- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa.so
- ${CMAKE_CURRENT_BINARY_DIR}/mraa.py
- DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON3_PACKAGES_PATH})
-endif ()
diff --git a/peripheral/libmraa/src/python/python3/mraa3.i b/peripheral/libmraa/src/python/python3/mraa3.i
deleted file mode 100644
index e3df17a..0000000
--- a/peripheral/libmraa/src/python/python3/mraa3.i
+++ /dev/null
@@ -1,3 +0,0 @@
-%module(docstring="Python interface to libmraa") mraa
-
-%include ../mraapython.i
diff --git a/peripheral/libmraa/src/spi/spi.c b/peripheral/libmraa/src/spi/spi.c
index 570c207..384cc20 100644
--- a/peripheral/libmraa/src/spi/spi.c
+++ b/peripheral/libmraa/src/spi/spi.c
@@ -143,12 +143,10 @@ mraa_spi_init_raw(unsigned int bus, unsigned int cs)
}
int speed = 0;
- if (ioctl(dev->devfd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) != -1) {
+ if ((ioctl(dev->devfd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) != -1) && (speed < 4000000)) {
dev->clock = speed;
} else {
- // We had this on Galileo Gen1, so let it be a fallback value
dev->clock = 4000000;
- syslog(LOG_WARNING, "spi: Max speed query failed, setting %d", dev->clock);
}
if (mraa_spi_mode(dev, MRAA_SPI_MODE0) != MRAA_SUCCESS) {
@@ -267,7 +265,7 @@ mraa_spi_write(mraa_spi_context dev, uint8_t data)
return (int) recv;
}
-int
+uint16_t
mraa_spi_write_word(mraa_spi_context dev, uint16_t data)
{
struct spi_ioc_transfer msg;
@@ -286,7 +284,7 @@ mraa_spi_write_word(mraa_spi_context dev, uint16_t data)
syslog(LOG_ERR, "spi: Failed to perform dev transfer");
return -1;
}
- return (int) recv;
+ return recv;
}
mraa_result_t
diff --git a/peripheral/libmraa/src/uart/uart.c b/peripheral/libmraa/src/uart/uart.c
index d39559f..0f8a2e3 100644
--- a/peripheral/libmraa/src/uart/uart.c
+++ b/peripheral/libmraa/src/uart/uart.c
@@ -30,8 +30,6 @@
#include <string.h>
#include <termios.h>
#include <sys/select.h>
-#include <errno.h>
-#include <string.h>
#include "uart.h"
#include "mraa_internal.h"
@@ -108,7 +106,9 @@ uint2speed(unsigned int speed)
return B4000000;
default:
// if we are here, then an unsupported baudrate was selected.
- return 0;
+ // Report it via syslog and return B9600, a common default.
+ syslog(LOG_ERR, "uart: unsupported baud rate, defaulting to 9600.");
+ return B9600;
}
}
@@ -131,29 +131,29 @@ mraa_uart_context
mraa_uart_init(int index)
{
if (plat == NULL) {
- syslog(LOG_ERR, "uart%i: init: platform not initialised", index);
+ syslog(LOG_ERR, "uart: platform not initialised");
return NULL;
}
if (mraa_is_sub_platform_id(index)) {
- syslog(LOG_NOTICE, "uart%i: init: Using sub platform is not supported", index);
+ syslog(LOG_NOTICE, "uart: Using sub platform is not supported");
return NULL;
}
if (plat->adv_func->uart_init_pre != NULL) {
if (plat->adv_func->uart_init_pre(index) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "uart%i: init: failure in pre-init platform hook", index);
+ syslog(LOG_ERR, "uart: failure in pre-init platform hook");
return NULL;
}
}
if (plat->uart_dev_count == 0) {
- syslog(LOG_ERR, "uart%i: init: platform has no UARTs defined", index);
+ syslog(LOG_ERR, "uart: platform has no UARTs defined");
return NULL;
}
if (plat->uart_dev_count <= index) {
- syslog(LOG_ERR, "uart%i: init: platform has only %i uarts", index, plat->uart_dev_count);
+ syslog(LOG_ERR, "uart: platform has only %i", plat->uart_dev_count);
return NULL;
}
@@ -162,7 +162,7 @@ mraa_uart_init(int index)
if (pos >= 0) {
if (plat->pins[pos].uart.mux_total > 0) {
if (mraa_setup_mux_mapped(plat->pins[pos].uart) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "uart%i: init: failed to setup muxes for RX pin", index);
+ syslog(LOG_ERR, "uart: failed to setup muxes for RX pin");
return NULL;
}
}
@@ -172,7 +172,7 @@ mraa_uart_init(int index)
if (pos >= 0) {
if (plat->pins[pos].uart.mux_total > 0) {
if (mraa_setup_mux_mapped(plat->pins[pos].uart) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "uart%i: init: failed to setup muxes for TX pin", index);
+ syslog(LOG_ERR, "uart: failed to setup muxes for TX pin");
return NULL;
}
}
@@ -199,11 +199,6 @@ mraa_uart_init(int index)
mraa_uart_context
mraa_uart_init_raw(const char* path)
{
- if (!path) {
- syslog(LOG_ERR, "uart: device path undefined");
- return NULL;
- }
-
mraa_uart_context dev = mraa_uart_init_internal(plat == NULL ? NULL : plat->adv_func);
if (dev == NULL) {
syslog(LOG_ERR, "uart: Failed to allocate memory for context");
@@ -211,9 +206,15 @@ mraa_uart_init_raw(const char* path)
}
dev->path = path;
+ if (!dev->path) {
+ syslog(LOG_ERR, "uart: device path undefined, open failed");
+ free(dev);
+ return NULL;
+ }
+
// now open the device
if ((dev->fd = open(dev->path, O_RDWR)) == -1) {
- syslog(LOG_ERR, "uart: open(%s) failed: %s", path, strerror(errno));
+ syslog(LOG_ERR, "uart: open() failed");
free(dev);
return NULL;
}
@@ -223,7 +224,7 @@ mraa_uart_init_raw(const char* path)
// get current modes
if (tcgetattr(dev->fd, &termio)) {
- syslog(LOG_ERR, "uart: tcgetattr(%s) failed: %s", path, strerror(errno));
+ syslog(LOG_ERR, "uart: tcgetattr() failed");
close(dev->fd);
free(dev);
return NULL;
@@ -234,7 +235,7 @@ mraa_uart_init_raw(const char* path)
// cfmakeraw is not POSIX!
cfmakeraw(&termio);
if (tcsetattr(dev->fd, TCSAFLUSH, &termio) < 0) {
- syslog(LOG_ERR, "uart: tcsetattr(%s) failed after cfmakeraw(): %s", path, strerror(errno));
+ syslog(LOG_ERR, "uart: tcsetattr() failed after cfmakeraw()");
close(dev->fd);
free(dev);
return NULL;
@@ -271,7 +272,7 @@ mraa_result_t
mraa_uart_flush(mraa_uart_context dev)
{
if (!dev) {
- syslog(LOG_ERR, "uart: flush: context is NULL");
+ syslog(LOG_ERR, "uart: stop: context is NULL");
return MRAA_ERROR_INVALID_HANDLE;
}
@@ -286,29 +287,24 @@ mraa_result_t
mraa_uart_set_baudrate(mraa_uart_context dev, unsigned int baud)
{
if (!dev) {
- syslog(LOG_ERR, "uart: set_baudrate: context is NULL");
+ syslog(LOG_ERR, "uart: stop: context is NULL");
return MRAA_ERROR_INVALID_HANDLE;
}
struct termios termio;
if (tcgetattr(dev->fd, &termio)) {
- syslog(LOG_ERR, "uart%i: set_baudrate: tcgetattr() failed: %s", dev->index, strerror(errno));
- return MRAA_ERROR_INVALID_RESOURCE;
+ syslog(LOG_ERR, "uart: tcgetattr() failed");
+ return MRAA_ERROR_INVALID_HANDLE;
}
// set our baud rates
speed_t speed = uint2speed(baud);
- if (speed == 0)
- {
- syslog(LOG_ERR, "uart%i: set_baudrate: invalid baudrate: %i", dev->index, baud);
- return MRAA_ERROR_INVALID_PARAMETER;
- }
cfsetispeed(&termio, speed);
cfsetospeed(&termio, speed);
// make it so
if (tcsetattr(dev->fd, TCSAFLUSH, &termio) < 0) {
- syslog(LOG_ERR, "uart%i: set_baudrate: tcsetattr() failed: %s", dev->index, strerror(errno));
+ syslog(LOG_ERR, "uart: tcsetattr() failed");
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
}
return MRAA_SUCCESS;
@@ -318,14 +314,14 @@ mraa_result_t
mraa_uart_set_mode(mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits)
{
if (!dev) {
- syslog(LOG_ERR, "uart: set_mode: context is NULL");
+ syslog(LOG_ERR, "uart: stop: context is NULL");
return MRAA_ERROR_INVALID_HANDLE;
}
struct termios termio;
if (tcgetattr(dev->fd, &termio)) {
- syslog(LOG_ERR, "uart%i: set_mode: tcgetattr() failed: %s", dev->index, strerror(errno));
- return MRAA_ERROR_INVALID_RESOURCE;
+ syslog(LOG_ERR, "uart: tcgetattr() failed");
+ return MRAA_ERROR_INVALID_HANDLE;
}
termio.c_cflag &= ~CSIZE;
@@ -379,7 +375,7 @@ mraa_uart_set_mode(mraa_uart_context dev, int bytesize, mraa_uart_parity_t parit
}
if (tcsetattr(dev->fd, TCSAFLUSH, &termio) < 0) {
- syslog(LOG_ERR, "uart%i: set_mode: tcsetattr() failed: %s", dev->index, strerror(errno));
+ syslog(LOG_ERR, "uart: tcsetattr() failed");
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
}
@@ -390,7 +386,7 @@ mraa_result_t
mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts)
{
if (!dev) {
- syslog(LOG_ERR, "uart: set_flowcontrol: context is NULL");
+ syslog(LOG_ERR, "uart: stop: context is NULL");
return MRAA_ERROR_INVALID_HANDLE;
}
@@ -408,8 +404,8 @@ mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_bo
// get current modes
if (tcgetattr(dev->fd, &termio)) {
- syslog(LOG_ERR, "uart%i: set_flowcontrol: tcgetattr() failed: %s", dev->index, strerror(errno));
- return MRAA_ERROR_INVALID_RESOURCE;
+ syslog(LOG_ERR, "uart: tcgetattr() failed");
+ return MRAA_ERROR_INVALID_HANDLE;
}
if (rtscts) {
@@ -419,7 +415,7 @@ mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_bo
}
if (tcsetattr(dev->fd, TCSAFLUSH, &termio) < 0) {
- syslog(LOG_ERR, "uart%i: set_flowcontrol: tcsetattr() failed: %s", dev->index, strerror(errno));
+ syslog(LOG_ERR, "uart: tcsetattr() failed");
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
}
@@ -430,15 +426,15 @@ mraa_result_t
mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar)
{
if (!dev) {
- syslog(LOG_ERR, "uart: set_timeout: context is NULL");
+ syslog(LOG_ERR, "uart: stop: context is NULL");
return MRAA_ERROR_INVALID_HANDLE;
}
struct termios termio;
// get current modes
if (tcgetattr(dev->fd, &termio)) {
- syslog(LOG_ERR, "uart%i: set_timeout: tcgetattr() failed: %s", dev->index, strerror(errno));
- return MRAA_ERROR_INVALID_RESOURCE;
+ syslog(LOG_ERR, "uart: tcgetattr() failed");
+ return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
}
if (read > 0) {
read = read / 100;
@@ -448,47 +444,22 @@ mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar)
termio.c_lflag &= ~ICANON; /* Set non-canonical mode */
termio.c_cc[VTIME] = read; /* Set timeout in tenth seconds */
if (tcsetattr(dev->fd, TCSANOW, &termio) < 0) {
- syslog(LOG_ERR, "uart%i: set_timeout: tcsetattr() failed: %s", dev->index, strerror(errno));
+ syslog(LOG_ERR, "uart: tcsetattr() failed");
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
}
return MRAA_SUCCESS;
}
-mraa_result_t
-mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t nonblock)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart: non_blocking: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- // get current flags
- int flags = fcntl(dev->fd, F_GETFL);
-
- // update flags with new blocking state according to nonblock bool
- if (nonblock) {
- flags |= O_NONBLOCK;
- } else {
- flags &= ~O_NONBLOCK;
- }
-
- // set new flags
- if (fcntl(dev->fd, F_SETFL, flags) < 0) {
- syslog(LOG_ERR, "uart%i: non_blocking: failed changing fd blocking state: %s", dev->index, strerror(errno));
- return MRAA_ERROR_UNSPECIFIED;
- }
-
- return MRAA_SUCCESS;
-}
-
const char*
mraa_uart_get_dev_path(mraa_uart_context dev)
{
if (!dev) {
+ syslog(LOG_ERR, "uart: get_device_path failed, context is NULL");
return NULL;
}
if (dev->path == NULL) {
+ syslog(LOG_ERR, "uart: device path undefined");
return NULL;
}
@@ -504,7 +475,7 @@ mraa_uart_read(mraa_uart_context dev, char* buf, size_t len)
}
if (dev->fd < 0) {
- syslog(LOG_ERR, "uart%i: read: port is not open", dev->index);
+ syslog(LOG_ERR, "uart: port is not open");
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -520,7 +491,7 @@ mraa_uart_write(mraa_uart_context dev, const char* buf, size_t len)
}
if (dev->fd < 0) {
- syslog(LOG_ERR, "uart%i: write: port is not open", dev->index);
+ syslog(LOG_ERR, "uart: port is not open");
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -531,12 +502,12 @@ mraa_boolean_t
mraa_uart_data_available(mraa_uart_context dev, unsigned int millis)
{
if (!dev) {
- syslog(LOG_ERR, "uart: data_available: context is NULL");
+ syslog(LOG_ERR, "uart: data_available: write context is NULL");
return 0;
}
if (dev->fd < 0) {
- syslog(LOG_ERR, "uart%i: data_available: port is not open", dev->index);
+ syslog(LOG_ERR, "uart: port is not open");
return 0;
}
diff --git a/peripheral/libmraa/src/uart_ow/CMakeLists.txt b/peripheral/libmraa/src/uart_ow/CMakeLists.txt
deleted file mode 100644
index 8ea5bdb..0000000
--- a/peripheral/libmraa/src/uart_ow/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-if (ONEWIRE)
- message (STATUS "INFO - Adding onewire backend support")
- set (mraa_LIB_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO}
- ${PROJECT_SOURCE_DIR}/src/uart_ow/uart_ow.c
- PARENT_SCOPE
- )
-endif ()
diff --git a/peripheral/libmraa/src/uart_ow/uart_ow.c b/peripheral/libmraa/src/uart_ow/uart_ow.c
deleted file mode 100644
index 759ba2f..0000000
--- a/peripheral/libmraa/src/uart_ow/uart_ow.c
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation
- *
- * Portions (search) copyright:
- * Copyright (C) 2004 Dallas Semiconductor Corporation, All Rights Reserved.
- *
- * For the crc8 algorithm:
- * Copyright (c) 2002 Colin O'Flynn
- *
- * 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 <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include "uart.h"
-#include "uart_ow.h"
-#include "mraa_internal.h"
-
-// low-level read byte
-static mraa_result_t
-_ow_read_byte(mraa_uart_ow_context dev, uint8_t *ch)
-{
- while (!mraa_uart_read(dev->uart, (char*) ch, 1))
- ;
-
- return MRAA_SUCCESS;
-}
-
-// low-level write byte
-static int
-_ow_write_byte(mraa_uart_ow_context dev, const char ch)
-{
- return mraa_uart_write(dev->uart, &ch, 1);
-}
-
-// Here we setup a very simple termios with the minimum required
-// settings. We use this to also change speed from high to low. We
-// use the low speed (9600 bd) for emitting the reset pulse, and
-// high speed (115200 bd) for actual data communications.
-//
-static mraa_result_t
-_ow_set_speed(mraa_uart_ow_context dev, mraa_boolean_t speed)
-{
-
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: set_speed: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- static speed_t baud;
- if (speed) {
- baud = B115200;
- }
- else {
- baud = B9600;
- }
-
- struct termios termio = {
- .c_cflag = baud | CS8 | CLOCAL | CREAD, .c_iflag = 0, .c_oflag = 0, .c_lflag = NOFLSH, .c_cc = { 0 },
- };
-
- tcflush(dev->uart->fd, TCIFLUSH);
-
- // TCSANOW is required
- if (tcsetattr(dev->uart->fd, TCSANOW, &termio) < 0) {
- syslog(LOG_ERR, "uart_ow: tcsetattr() failed");
- return MRAA_ERROR_INVALID_RESOURCE;
- }
-
- return MRAA_SUCCESS;
-}
-
-// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing
-// search state.
-// Return 1 : device found, ROM number in ROM_NO buffer
-// 0 : device not found, end of search
-//
-static mraa_boolean_t
-_ow_search(mraa_uart_ow_context dev)
-{
- int id_bit_number;
- int last_zero, rom_byte_number, search_result;
- int id_bit, cmp_id_bit;
- unsigned char rom_byte_mask, search_direction;
-
- // initialize for search
- id_bit_number = 1;
- last_zero = 0;
- rom_byte_number = 0;
- rom_byte_mask = 1;
- search_result = 0;
-
- // if the last call was not the last device
- if (!dev->LastDeviceFlag) {
- // 1-Wire reset
- if (mraa_uart_ow_reset(dev) != MRAA_SUCCESS) {
- // reset the search
- dev->LastDiscrepancy = 0;
- dev->LastDeviceFlag = 0;
- dev->LastFamilyDiscrepancy = 0;
- return 0;
- }
-
- // issue the search command
- mraa_uart_ow_write_byte(dev, MRAA_UART_OW_CMD_SEARCH_ROM);
-
- // loop to do the search
- do {
- // read a bit and its complement
- id_bit = mraa_uart_ow_bit(dev, 1);
- cmp_id_bit = mraa_uart_ow_bit(dev, 1);
-
- // check for no devices on 1-wire
- if ((id_bit == 1) && (cmp_id_bit == 1))
- break;
- else {
- // all devices coupled have 0 or 1
- if (id_bit != cmp_id_bit)
- search_direction = id_bit; // bit write value for search
- else {
- // if this discrepancy if before the Last Discrepancy
- // on a previous next then pick the same as last time
- if (id_bit_number < dev->LastDiscrepancy)
- search_direction = ((dev->ROM_NO[rom_byte_number] & rom_byte_mask) > 0);
- else
- // if equal to last pick 1, if not then pick 0
- search_direction = (id_bit_number == dev->LastDiscrepancy);
- // if 0 was picked then record its position in LastZero
- if (search_direction == 0) {
- last_zero = id_bit_number;
- // check for Last discrepancy in family
- if (last_zero < 9)
- dev->LastFamilyDiscrepancy = last_zero;
- }
- }
-
- // set or clear the bit in the ROM byte rom_byte_number
- // with mask rom_byte_mask
- if (search_direction == 1)
- dev->ROM_NO[rom_byte_number] |= rom_byte_mask;
- else
- dev->ROM_NO[rom_byte_number] &= ~rom_byte_mask;
-
- // serial number search direction write bit
- mraa_uart_ow_bit(dev, search_direction);
-
- // increment the byte counter id_bit_number
- // and shift the mask rom_byte_mask
- id_bit_number++;
- rom_byte_mask <<= 1;
- // if the mask is 0 then go to new SerialNum byte
- // rom_byte_number and reset
- if (rom_byte_mask == 0) {
- rom_byte_number++;
- rom_byte_mask = 1;
- }
- }
- } while (rom_byte_number < 8);
-
- // loop until through all ROM bytes 0-7
- // if the search was successful then
- if (id_bit_number >= 65) {
- // search successful so set
- // LastDiscrepancy,LastDeviceFlag,search_result
- dev->LastDiscrepancy = last_zero;
-
- // check for last device
- if (dev->LastDiscrepancy == 0)
- dev->LastDeviceFlag = 1;
- }
- search_result = 1;
- }
-
- // if no device found then reset counters so next 'search' will be
- // like a first
- if (!search_result || !dev->ROM_NO[0]) {
- dev->LastDiscrepancy = 0;
- dev->LastDeviceFlag = 0;
- dev->LastFamilyDiscrepancy = 0;
- search_result = 0;
- }
-
- return search_result;
-}
-
-//--------------------------------------------------------------------------
-// Find the 'first' devices on the 1-Wire bus
-// Return 1 : device found, ROM number in ROM_NO buffer
-// 0 : no device present
-//
-static mraa_boolean_t
-_ow_first(mraa_uart_ow_context dev)
-{
- // reset the search state
- dev->LastDiscrepancy = 0;
- dev->LastDeviceFlag = 0;
- dev->LastFamilyDiscrepancy = 0;
-
- return _ow_search(dev);
-}
-
-//--------------------------------------------------------------------------
-// Find the 'next' devices on the 1-Wire bus
-// Return 1 : device found, ROM number in ROM_NO buffer
-// 0 : device not found, end of search
-//
-static mraa_boolean_t
-_ow_next(mraa_uart_ow_context dev)
-{
- // leave the search state alone
- return _ow_search(dev);
-}
-
-// Start of exported mraa functionality
-
-mraa_uart_ow_context
-mraa_uart_ow_init(int index)
-{
- mraa_uart_ow_context dev = calloc(1, sizeof(struct _mraa_uart_ow));
- if (!dev)
- return NULL;
-
- dev->uart = mraa_uart_init(index);
- if (!dev->uart)
- {
- free(dev);
- return NULL;
- }
-
-
- // now get the fd, and set it up for non-blocking operation
- if (fcntl(dev->uart->fd, F_SETFL, O_NONBLOCK) == -1) {
- syslog(LOG_ERR, "uart_ow: failed to set non-blocking on fd");
- mraa_uart_ow_stop(dev);
- return NULL;
- }
-
- return dev;
-}
-
-mraa_uart_ow_context
-mraa_uart_ow_init_raw(const char* path)
-{
- mraa_uart_ow_context dev = calloc(1, sizeof(struct _mraa_uart_ow));
- if (!dev)
- return NULL;
-
- dev->uart = mraa_uart_init_raw(path);
- if (!dev->uart)
- {
- free(dev);
- return NULL;
- }
-
- // now get the fd, and set it up for non-blocking operation
- if (fcntl(dev->uart->fd, F_SETFL, O_NONBLOCK) == -1) {
- syslog(LOG_ERR, "uart_ow: failed to set non-blocking on fd");
- mraa_uart_ow_stop(dev);
- return NULL;
- }
-
- return dev;
-}
-
-mraa_result_t
-mraa_uart_ow_stop(mraa_uart_ow_context dev)
-{
- mraa_result_t rv = mraa_uart_stop(dev->uart);
- free(dev);
- return rv;
-}
-
-const char*
-mraa_uart_ow_get_dev_path(mraa_uart_ow_context dev)
-{
- return mraa_uart_get_dev_path(dev->uart);
-}
-
-int
-mraa_uart_ow_bit(mraa_uart_ow_context dev, uint8_t bit)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: ow_bit: context is NULL");
- return -1;
- }
-
- int ret = 0;
- uint8_t ch;
- if (bit) {
- ret = _ow_write_byte(dev, 0xff); /* write a 1 bit */
- }
- else {
- ret = _ow_write_byte(dev, 0x00); /* write a 0 bit */
- }
-
- /* return the bit present on the bus (0xff is a '1', anything else
- * (typically 0xfc or 0x00) is a 0
- */
- if (_ow_read_byte(dev, &ch) == -1 || ret == -1) {
- return -1;
- }
- return (ch == 0xff);
-}
-
-int
-mraa_uart_ow_write_byte(mraa_uart_ow_context dev, uint8_t byte)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: write_byte: context is NULL");
- return -1;
- }
-
- /* writing bytes - each bit on the byte to send corresponds to a
- * byte on the uart. At the same time, we read bits (uart bytes)
- * from the bus and build a byte to return. This is possible due to
- * the way we wire the UART TX/RX pins together, similar to a
- * loopback connection, except the devices on the 1-wire bus have
- * the ability to modify the returning bitstream.
- */
-
- uint8_t bit;
- int i;
- for (i = 0; i < 8; i++) {
- bit = mraa_uart_ow_bit(dev, byte & 0x01);
- /* prep for next bit to send, and clear space for bit read */
- byte >>= 1;
- /* store read bit in the msb */
- if (bit)
- byte |= 0x80;
- }
-
- /* return the new byte read */
- return byte;
-}
-
-int
-mraa_uart_ow_read_byte(mraa_uart_ow_context dev)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: read_byte: context is NULL");
- return -1;
- }
-
- /* we read by sending 0xff, so the bus is released on the initial
- * low pulse (uart start bit) for every timeslot, when the device
- * will then send it's bits
- */
- return mraa_uart_ow_write_byte(dev, 0xff);
-}
-
-mraa_result_t
-mraa_uart_ow_reset(mraa_uart_ow_context dev)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: reset: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- uint8_t rv;
-
- /* To emit a proper reset pulse, we set low speed (9600 baud) for
- * the reset pulse and send 0xf0 to pull the line down for the
- * minimum amount of time.
- *
- * From the Maxim whitepaper:
- *
- * Transmitting an 0xF0 from the UART forms a proper Reset
- * pulse. The receive value depends on whether one or more 1-Wire
- * slave devices are present, their internal timing of each slave
- * device present, and the UART's detection timing within each bit
- * window. If no device is present, the receive value will equal the
- * transmit value. Otherwise the receive value can vary.
- */
- if (_ow_set_speed(dev, 0) != MRAA_SUCCESS) {
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- /* pull the data line low */
- _ow_write_byte(dev, 0xf0);
-
- _ow_read_byte(dev, &rv);
-
- /* back up to high speed for normal data transmissions */
- if (_ow_set_speed(dev, 1) != MRAA_SUCCESS) {
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- /* shorted data line */
- if (rv == 0x00)
- return MRAA_ERROR_UART_OW_SHORTED;
-
- /* no devices detected (no presence pulse) */
- if (rv == 0xf0)
- return MRAA_ERROR_UART_OW_NO_DEVICES;
-
- /* otherwise, at least one device is present */
- return MRAA_SUCCESS;
-}
-
-
-mraa_result_t
-mraa_uart_ow_rom_search(mraa_uart_ow_context dev, mraa_boolean_t start, uint8_t* id)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: rom_search: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- // bail if there aren't any devices, or some other error occurs
- mraa_result_t rv;
- if ((rv = mraa_uart_ow_reset(dev)) != MRAA_SUCCESS)
- return rv;
-
- mraa_boolean_t result;
-
- // see if we are starting from scratch
- if (start)
- result = _ow_first(dev);
- else
- result = _ow_next(dev);
-
- if (result) {
- // found one. Copy into id and return 1
- int i;
- for (i = 0; i < MRAA_UART_OW_ROMCODE_SIZE; i++)
- id[i] = dev->ROM_NO[i];
-
- return MRAA_SUCCESS;
- } else
- return MRAA_ERROR_UART_OW_NO_DEVICES;
-}
-
-mraa_result_t
-mraa_uart_ow_command(mraa_uart_ow_context dev, uint8_t command, uint8_t* id)
-{
- if (!dev) {
- syslog(LOG_ERR, "uart_ow: ow_command: context is NULL");
- return MRAA_ERROR_INVALID_HANDLE;
- }
-
- /* send reset pulse first */
- mraa_result_t rv = mraa_uart_ow_reset(dev);
-
- if (rv != MRAA_SUCCESS)
- return rv;
-
- if (id) {
- /* send the match rom command */
- mraa_uart_ow_write_byte(dev, MRAA_UART_OW_CMD_MATCH_ROM);
-
- /* sending to a specific device, so send out the full romcode */
- int i;
- for (i = 0; i < MRAA_UART_OW_ROMCODE_SIZE; i++)
- mraa_uart_ow_write_byte(dev, id[i]);
- } else {
- /* send to all devices (or a single device if it's the only one
- * on the bus)
- */
- mraa_uart_ow_write_byte(dev, MRAA_UART_OW_CMD_SKIP_ROM);
- }
-
- mraa_uart_ow_write_byte(dev, command);
-
- return MRAA_SUCCESS;
-}
-
-uint8_t
-mraa_uart_ow_crc8(uint8_t* buffer, uint16_t length)
-{
- // 0x18 = X ^ 8 + X ^ 5 + X ^ 4 + X ^ 0
- static const uint8_t CRC8POLY = 0x18;
-
- uint8_t crc = 0x00;
- uint16_t loop_count;
- uint8_t bit_counter;
- uint8_t data;
- uint8_t feedback_bit;
-
- for (loop_count = 0; loop_count != length; loop_count++) {
- data = buffer[loop_count];
- bit_counter = 8;
- do {
- feedback_bit = (crc ^ data) & 0x01;
- if (feedback_bit == 0x01)
- crc = crc ^ CRC8POLY;
- crc = (crc >> 1) & 0x7F;
- if (feedback_bit == 0x01)
- crc = crc | 0x80;
- data = data >> 1;
- bit_counter--;
- } while (bit_counter > 0);
- }
-
- return crc;
-}
diff --git a/peripheral/libmraa/src/usb/ftdi_ft4222.c b/peripheral/libmraa/src/usb/ftdi_ft4222.c
index d3183cd..5c6167e 100644
--- a/peripheral/libmraa/src/usb/ftdi_ft4222.c
+++ b/peripheral/libmraa/src/usb/ftdi_ft4222.c
@@ -335,22 +335,19 @@ mraa_ftdi_ft4222_detect_io_expander()
if (mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9672_ADDR, &data, 1) == 1) {
gpio_expander_chip = IO_EXP_PCA9672;
return PCA9672_PINS;
- } else {
- uint8_t reg = PCA9555_INPUT_REG;
+ } else if (mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9555_ADDR, &data, 1) == 1) {
+ gpio_expander_chip = IO_EXP_PCA9555;
+ uint8_t reg = PCA9555_OUTPUT_REG;
mraa_ftdi_ft4222_i2c_write_internal(ftHandleI2c, PCA9555_ADDR, &reg, 1);
- if (mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9555_ADDR, &data, 1) == 1) {
- gpio_expander_chip = IO_EXP_PCA9555;
- reg = PCA9555_OUTPUT_REG;
- mraa_ftdi_ft4222_i2c_write_internal(ftHandleI2c, PCA9555_ADDR, &reg, 1);
- mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9555_ADDR, (uint8_t*)&pca9555OutputValue, 2);
- reg = PCA9555_DIRECTION_REG;
- mraa_ftdi_ft4222_i2c_write_internal(ftHandleI2c, PCA9555_ADDR, &reg, 1);
- mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9555_ADDR, (uint8_t*)&pca9555DirectionValue, 2);
- return PCA9555_PINS;
- }
+ mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9555_ADDR, (uint8_t*)&pca9555OutputValue, 2);
+ reg = PCA9555_DIRECTION_REG;
+ mraa_ftdi_ft4222_i2c_write_internal(ftHandleI2c, PCA9555_ADDR, &reg, 1);
+ mraa_ftdi_ft4222_i2c_read_internal(ftHandleI2c, PCA9555_ADDR, (uint8_t*)&pca9555DirectionValue, 2);
+ return PCA9555_PINS;
+ } else {
+ gpio_expander_chip = IO_EXP_NONE;
+ return 0;
}
- gpio_expander_chip = IO_EXP_NONE;
- return 0;
}
@@ -553,17 +550,17 @@ mraa_ftdi_ft4222_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
return bytes_read;
}
-static int
+static uint8_t
mraa_ftdi_ft4222_i2c_read_byte(mraa_i2c_context dev)
{
uint8_t data;
pthread_mutex_lock(&ft4222_lock);
int bytes_read = mraa_ftdi_ft4222_i2c_context_read(dev, &data, 1);
pthread_mutex_unlock(&ft4222_lock);
- return bytes_read == 1 ? data : -1;
+ return bytes_read == 1 ? data : 0;
}
-static int
+static uint8_t
mraa_ftdi_ft4222_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
{
uint8_t data;
@@ -573,13 +570,10 @@ mraa_ftdi_ft4222_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
if (bytesWritten == 1)
bytes_read = mraa_ftdi_ft4222_i2c_context_read(dev, &data, 1);
pthread_mutex_unlock(&ft4222_lock);
- if (bytes_read == 1) {
- return (int) data;
- }
- return -1;
+ return (bytes_read == 1) ? data : 0;
}
-static int
+static uint16_t
mraa_ftdi_ft4222_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
{
uint8_t buf[2];
@@ -590,10 +584,8 @@ mraa_ftdi_ft4222_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
if (bytes_written == 1)
bytes_read = mraa_ftdi_ft4222_i2c_context_read(dev, buf, 2);
pthread_mutex_unlock(&ft4222_lock);
- if (bytes_read == 2) {
- return (int) data;
- }
- return -1;
+ data = (bytes_read == 2) ? *(uint16_t*)buf : 0;
+ return data;
}
static int
@@ -608,6 +600,7 @@ mraa_ftdi_ft4222_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint
return bytes_read;
}
+
static mraa_result_t
mraa_ftdi_ft4222_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWrite)
{
@@ -625,6 +618,7 @@ mraa_ftdi_ft4222_i2c_write_byte(mraa_i2c_context dev, uint8_t data)
return status;
}
+
static mraa_result_t
mraa_ftdi_ft4222_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
{
diff --git a/peripheral/libmraa/src/x86/intel_edison_fab_c.c b/peripheral/libmraa/src/x86/intel_edison_fab_c.c
index e1af114..643616b 100644
--- a/peripheral/libmraa/src/x86/intel_edison_fab_c.c
+++ b/peripheral/libmraa/src/x86/intel_edison_fab_c.c
@@ -49,14 +49,14 @@
typedef struct {
int sysfs;
int mode;
-} mraa_intel_edison_pindef_t;
+} mraa_intel_edision_pindef_t;
typedef struct {
- mraa_intel_edison_pindef_t gpio;
- mraa_intel_edison_pindef_t pwm;
- mraa_intel_edison_pindef_t i2c;
- mraa_intel_edison_pindef_t spi;
- mraa_intel_edison_pindef_t uart;
+ mraa_intel_edision_pindef_t gpio;
+ mraa_intel_edision_pindef_t pwm;
+ mraa_intel_edision_pindef_t i2c;
+ mraa_intel_edision_pindef_t spi;
+ mraa_intel_edision_pindef_t uart;
} mraa_intel_edison_pinmodes_t;
static mraa_gpio_context tristate;
@@ -76,9 +76,6 @@ static int mmap_fd = 0;
static int mmap_size;
static unsigned int mmap_count = 0;
-// PWM 0% duty workaround state array
-static int pwm_disabled[4] = { 0 };
-
mraa_result_t
mraa_intel_edison_spi_lsbmode_replace(mraa_spi_context dev, mraa_boolean_t lsb)
{
@@ -371,30 +368,6 @@ mraa_intel_edison_aio_init_post(mraa_aio_context dev)
}
mraa_result_t
-mraa_intel_edison_pwm_enable_pre(mraa_pwm_context dev, int enable) {
- // PWM 0% duty workaround: update state array
- // if someone first ran write(0) and then enable(1).
- if ((pwm_disabled[dev->pin] == 1) && (enable == 1)) { pwm_disabled[dev->pin] = 0; }
- return MRAA_SUCCESS;
-}
-
-mraa_result_t
-mraa_intel_edison_pwm_write_pre(mraa_pwm_context dev, float percentage) {
- // PWM 0% duty workaround: set the state array and enable/disable pin accordingly
- if (percentage == 0.0f) {
- syslog(LOG_INFO, "edison_pwm_write_pre (pwm%i): requested zero duty cycle, disabling PWM on the pin", dev->pin);
- pwm_disabled[dev->pin] = 1;
- return mraa_pwm_enable(dev, 0);
- } else if (pwm_disabled[dev->pin] == 1) {
- syslog(LOG_INFO, "edison_pwm_write_pre (pwm%i): Re-enabling the pin after setting non-zero duty", dev->pin);
- pwm_disabled[dev->pin] = 0;
- return mraa_pwm_enable(dev, 1);
- }
-
- return MRAA_SUCCESS;
-}
-
-mraa_result_t
mraa_intel_edison_pwm_init_pre(int pin)
{
if (miniboard == 1) {
@@ -441,7 +414,6 @@ mraa_intel_edison_pwm_init_pre(int pin)
mraa_result_t
mraa_intel_edison_pwm_init_post(mraa_pwm_context pwm)
{
- pwm_disabled[pwm->pin] = 0;
return mraa_gpio_write(tristate, 1);
}
@@ -532,6 +504,7 @@ mraa_intel_edison_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_t mode
value = 0;
break;
case MRAA_GPIO_HIZ:
+ return MRAA_SUCCESS;
break;
default:
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
@@ -553,7 +526,7 @@ mraa_intel_edison_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_t mode
}
mraa_result_t
-mraa_intel_edison_mb_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
+mraa_intel_edsion_mb_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
{
if (dev->value_fp != -1) {
if (close(dev->value_fp) != 0) {
@@ -659,7 +632,7 @@ mraa_intel_edison_uart_init_post(mraa_uart_context uart)
}
static mraa_result_t
-mraa_intel_edison_mmap_unsetup()
+mraa_intel_edsion_mmap_unsetup()
{
if (mmap_reg == NULL) {
syslog(LOG_ERR, "edison mmap: null register cant unsetup");
@@ -720,7 +693,7 @@ mraa_intel_edison_mmap_setup(mraa_gpio_context dev, mraa_boolean_t en)
dev->mmap_read = NULL;
mmap_count--;
if (mmap_count == 0) {
- return mraa_intel_edison_mmap_unsetup();
+ return mraa_intel_edsion_mmap_unsetup();
}
return MRAA_SUCCESS;
}
@@ -830,18 +803,16 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
}
b->adv_func->gpio_init_post = &mraa_intel_edison_gpio_init_post;
b->adv_func->pwm_init_pre = &mraa_intel_edison_pwm_init_pre;
- b->adv_func->pwm_enable_pre = &mraa_intel_edison_pwm_enable_pre;
- b->adv_func->pwm_write_pre = &mraa_intel_edison_pwm_write_pre;
b->adv_func->i2c_init_pre = &mraa_intel_edison_i2c_init_pre;
b->adv_func->i2c_set_frequency_replace = &mraa_intel_edison_i2c_freq;
b->adv_func->spi_init_pre = &mraa_intel_edison_spi_init_pre;
- b->adv_func->gpio_mode_replace = &mraa_intel_edison_mb_gpio_mode;
+ b->adv_func->gpio_mode_replace = &mraa_intel_edsion_mb_gpio_mode;
b->adv_func->uart_init_pre = &mraa_intel_edison_uart_init_pre;
b->adv_func->gpio_mmap_setup = &mraa_intel_edison_mmap_setup;
int pos = 0;
strncpy(b->pins[pos].name, "J17-1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 182;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 2;
@@ -928,7 +899,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 , 0};
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 13;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 1;
@@ -937,7 +908,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 165;
b->pins[pos].gpio.mux_total = 0;
pos++;
@@ -960,7 +931,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-7", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 12;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 0;
@@ -969,7 +940,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-8", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
+ b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 183;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 3;
@@ -1289,8 +1260,6 @@ mraa_intel_edison_fab_c()
b->adv_func->aio_init_post = &mraa_intel_edison_aio_init_post;
b->adv_func->pwm_init_pre = &mraa_intel_edison_pwm_init_pre;
b->adv_func->pwm_init_post = &mraa_intel_edison_pwm_init_post;
- b->adv_func->pwm_enable_pre = &mraa_intel_edison_pwm_enable_pre;
- b->adv_func->pwm_write_pre = &mraa_intel_edison_pwm_write_pre;
b->adv_func->spi_init_pre = &mraa_intel_edison_spi_init_pre;
b->adv_func->spi_init_post = &mraa_intel_edison_spi_init_post;
b->adv_func->gpio_mode_replace = &mraa_intel_edison_gpio_mode_replace;
@@ -1306,9 +1275,8 @@ mraa_intel_edison_fab_c()
}
if (mraa_gpio_read_dir(tristate, &tristate_dir) != MRAA_SUCCESS) {
- free(b->pins);
- free(b->adv_func);
- goto error;
+ free(b->adv_func);
+ goto error;
}
if (tristate_dir != MRAA_GPIO_OUT) {
@@ -1328,10 +1296,7 @@ mraa_intel_edison_fab_c()
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 130;
b->pins[0].gpio.parent_id = 0;
- b->pins[0].gpio.mux_total = 1;
- b->pins[0].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[0].gpio.mux[0].pin = 216;
- b->pins[0].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[0].gpio.mux_total = 0;
b->pins[0].uart.pinmap = 0;
b->pins[0].uart.parent_id = 0;
b->pins[0].uart.mux_total = 0;
@@ -1340,52 +1305,37 @@ mraa_intel_edison_fab_c()
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 131;
b->pins[1].gpio.parent_id = 0;
- b->pins[1].gpio.mux_total = 1;
- b->pins[1].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[1].gpio.mux[0].pin = 217;
- b->pins[1].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[1].gpio.mux_total = 0;
b->pins[1].uart.pinmap = 0;
b->pins[1].uart.parent_id = 0;
b->pins[1].uart.mux_total = 0;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[2].gpio.pinmap = 128;
b->pins[2].gpio.parent_id = 0;
- b->pins[2].gpio.mux_total = 1;
- b->pins[2].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[2].gpio.mux[0].pin = 218;
- b->pins[2].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[2].gpio.mux_total = 0;
strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
+ b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[3].gpio.pinmap = 12;
b->pins[3].gpio.parent_id = 0;
- b->pins[3].gpio.mux_total = 1;
- b->pins[3].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[3].gpio.mux[0].pin = 219;
- b->pins[3].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[3].gpio.mux_total = 0;
b->pins[3].pwm.pinmap = 0;
b->pins[3].pwm.parent_id = 0;
b->pins[3].pwm.mux_total = 0;
strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[4].gpio.pinmap = 129;
b->pins[4].gpio.parent_id = 0;
- b->pins[4].gpio.mux_total = 1;
- b->pins[4].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[4].gpio.mux[0].pin = 220;
- b->pins[4].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[4].gpio.mux_total = 0;
strncpy(b->pins[5].name, "IO5", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].gpio.pinmap = 13;
b->pins[5].gpio.parent_id = 0;
- b->pins[5].gpio.mux_total = 1;
- b->pins[5].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[5].gpio.mux[0].pin = 221;
- b->pins[5].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[5].gpio.mux_total = 0;
b->pins[5].pwm.pinmap = 1;
b->pins[5].pwm.parent_id = 0;
b->pins[5].pwm.mux_total = 0;
@@ -1394,40 +1344,28 @@ mraa_intel_edison_fab_c()
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].gpio.pinmap = 182;
b->pins[6].gpio.parent_id = 0;
- b->pins[6].gpio.mux_total = 1;
- b->pins[6].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[6].gpio.mux[0].pin = 222;
- b->pins[6].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[6].gpio.mux_total = 0;
b->pins[6].pwm.pinmap = 2;
b->pins[6].pwm.parent_id = 0;
b->pins[6].pwm.mux_total = 0;
strncpy(b->pins[7].name, "IO7", 8);
- b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 48;
b->pins[7].gpio.parent_id = 0;
- b->pins[7].gpio.mux_total = 1;
- b->pins[7].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[7].gpio.mux[0].pin = 223;
- b->pins[7].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[7].gpio.mux_total = 0;
strncpy(b->pins[8].name, "IO8", 8);
- b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 49;
b->pins[8].gpio.parent_id = 0;
- b->pins[8].gpio.mux_total = 1;
- b->pins[8].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[8].gpio.mux[0].pin = 224;
- b->pins[8].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[8].gpio.mux_total = 0;
strncpy(b->pins[9].name, "IO9", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 183;
b->pins[9].gpio.parent_id = 0;
- b->pins[9].gpio.mux_total = 1;
- b->pins[9].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[9].gpio.mux[0].pin = 225;
- b->pins[9].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[9].gpio.mux_total = 0;
b->pins[9].pwm.pinmap = 3;
b->pins[9].pwm.parent_id = 0;
b->pins[9].pwm.mux_total = 0;
@@ -1436,223 +1374,131 @@ mraa_intel_edison_fab_c()
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[10].gpio.pinmap = 41;
b->pins[10].gpio.parent_id = 0;
- b->pins[10].gpio.mux_total = 3;
- b->pins[10].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[10].gpio.mux[0].pin = 226;
- b->pins[10].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].gpio.mux[1].pin = 263;
- b->pins[10].gpio.mux[1].value = 1;
- b->pins[10].gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].gpio.mux[2].pin = 240;
- b->pins[10].gpio.mux[2].value = 0;
+ b->pins[10].gpio.mux_total = 2;
+ b->pins[10].gpio.mux[0].pin = 263;
+ b->pins[10].gpio.mux[0].value = 1;
+ b->pins[10].gpio.mux[1].pin = 240;
+ b->pins[10].gpio.mux[1].value = 0;
b->pins[10].spi.pinmap = 5;
- b->pins[10].spi.mux_total = 3;
- b->pins[10].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[10].spi.mux[0].pin = 226;
- b->pins[10].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].spi.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].spi.mux[1].pin = 263;
+ b->pins[10].spi.mux_total = 2;
+ b->pins[10].spi.mux[0].pin = 263;
+ b->pins[10].spi.mux[0].value = 1;
+ b->pins[10].spi.mux[1].pin = 240;
b->pins[10].spi.mux[1].value = 1;
- b->pins[10].spi.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].spi.mux[2].pin = 240;
- b->pins[10].spi.mux[2].value = 1;
strncpy(b->pins[11].name, "IO11", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[11].gpio.pinmap = 43;
b->pins[11].gpio.parent_id = 0;
- b->pins[11].gpio.mux_total = 3;
- b->pins[11].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[11].gpio.mux[0].pin = 227;
- b->pins[11].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[11].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].gpio.mux[1].pin = 262;
- b->pins[11].gpio.mux[1].value = 1;
- b->pins[11].gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].gpio.mux[2].pin = 241;
- b->pins[11].gpio.mux[2].value = 0;
+ b->pins[11].gpio.mux_total = 2;
+ b->pins[11].gpio.mux[0].pin = 262;
+ b->pins[11].gpio.mux[0].value = 1;
+ b->pins[11].gpio.mux[1].pin = 241;
+ b->pins[11].gpio.mux[1].value = 0;
b->pins[11].spi.pinmap = 5;
- b->pins[11].spi.mux_total = 3;
- b->pins[11].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[11].spi.mux[0].pin = 227;
- b->pins[11].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].spi.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].spi.mux[1].pin = 262;
+ b->pins[11].spi.mux_total = 2;
+ b->pins[11].spi.mux[0].pin = 262;
+ b->pins[11].spi.mux[0].value = 1;
+ b->pins[11].spi.mux[1].pin = 241;
b->pins[11].spi.mux[1].value = 1;
- b->pins[10].spi.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].spi.mux[2].pin = 241;
- b->pins[11].spi.mux[2].value = 1;
strncpy(b->pins[12].name, "IO12", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].gpio.pinmap = 42;
b->pins[12].gpio.parent_id = 0;
- b->pins[12].gpio.mux_total = 2;
- b->pins[12].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[12].gpio.mux[0].pin = 228;
- b->pins[12].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[12].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[12].gpio.mux[1].pin = 242;
- b->pins[12].gpio.mux[1].value = 0;
+ b->pins[12].gpio.mux_total = 1;
+ b->pins[12].gpio.mux[0].pin = 242;
+ b->pins[12].gpio.mux[0].value = 0;
b->pins[12].spi.pinmap = 5;
- b->pins[12].spi.mux_total = 2;
- b->pins[12].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[12].spi.mux[0].pin = 228;
- b->pins[12].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[12].spi.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[12].spi.mux[1].pin = 242;
- b->pins[12].spi.mux[1].value = 1;
+ b->pins[12].spi.mux_total = 1;
+ b->pins[12].spi.mux[0].pin = 242;
+ b->pins[12].spi.mux[0].value = 1;
strncpy(b->pins[13].name, "IO13", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].gpio.pinmap = 40;
b->pins[13].gpio.parent_id = 0;
- b->pins[13].gpio.mux_total = 2;
- b->pins[13].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[13].gpio.mux[0].pin = 229;
- b->pins[13].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[13].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[13].gpio.mux[1].pin = 243;
- b->pins[13].gpio.mux[1].value = 0;
+ b->pins[13].gpio.mux_total = 1;
+ b->pins[13].gpio.mux[0].pin = 243;
+ b->pins[13].gpio.mux[0].value = 0;
b->pins[13].spi.pinmap = 5;
- b->pins[13].spi.mux_total = 2;
- b->pins[13].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[13].spi.mux[0].pin = 229;
- b->pins[13].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[13].spi.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[13].spi.mux[1].pin = 243;
- b->pins[13].spi.mux[1].value = 1;
+ b->pins[13].spi.mux_total = 1;
+ b->pins[13].spi.mux[0].pin = 243;
+ b->pins[13].spi.mux[0].value = 1;
strncpy(b->pins[14].name, "A0", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].aio.pinmap = 0;
- b->pins[14].aio.mux_total = 2;
- b->pins[14].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[14].aio.mux[0].pin = 208;
- b->pins[14].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[14].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[14].aio.mux[1].pin = 200;
- b->pins[14].aio.mux[1].value = 1;
+ b->pins[14].aio.mux_total = 1;
+ b->pins[14].aio.mux[0].pin = 200;
+ b->pins[14].aio.mux[0].value = 1;
b->pins[14].gpio.pinmap = 44;
- b->pins[14].gpio.mux_total = 2;
- b->pins[14].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[14].gpio.mux[0].pin = 208;
- b->pins[14].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[14].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[14].gpio.mux[1].pin = 200;
- b->pins[14].gpio.mux[1].value = 0;
+ b->pins[14].gpio.mux_total = 1;
+ b->pins[14].gpio.mux[0].pin = 200;
+ b->pins[14].gpio.mux[0].value = 0;
strncpy(b->pins[15].name, "A1", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].aio.pinmap = 1;
- b->pins[15].aio.mux_total = 2;
- b->pins[15].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[15].aio.mux[0].pin = 209;
- b->pins[15].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[15].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[15].aio.mux[1].pin = 201;
- b->pins[15].aio.mux[1].value = 1;
+ b->pins[15].aio.mux_total = 1;
+ b->pins[15].aio.mux[0].pin = 201;
+ b->pins[15].aio.mux[0].value = 1;
b->pins[15].gpio.pinmap = 45;
- b->pins[15].gpio.mux_total = 2;
- b->pins[15].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[15].gpio.mux[0].pin = 209;
- b->pins[15].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[15].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[15].gpio.mux[1].pin = 201;
- b->pins[15].gpio.mux[1].value = 0;
+ b->pins[15].gpio.mux_total = 1;
+ b->pins[15].gpio.mux[0].pin = 201;
+ b->pins[15].gpio.mux[0].value = 0;
strncpy(b->pins[16].name, "A2", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].aio.pinmap = 2;
- b->pins[16].aio.mux_total = 2;
- b->pins[16].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[16].aio.mux[0].pin = 210;
- b->pins[16].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[16].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[16].aio.mux[1].pin = 202;
- b->pins[16].aio.mux[1].value = 1;
+ b->pins[16].aio.mux_total = 1;
+ b->pins[16].aio.mux[0].pin = 202;
+ b->pins[16].aio.mux[0].value = 1;
b->pins[16].gpio.pinmap = 46;
- b->pins[16].gpio.mux_total = 2;
- b->pins[16].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[16].gpio.mux[0].pin = 210;
- b->pins[16].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[16].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[16].gpio.mux[1].pin = 202;
- b->pins[16].gpio.mux[1].value = 0;
+ b->pins[16].gpio.mux_total = 1;
+ b->pins[16].gpio.mux[0].pin = 202;
+ b->pins[16].gpio.mux[0].value = 0;
strncpy(b->pins[17].name, "A3", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].aio.pinmap = 3;
- b->pins[17].aio.mux_total = 2;
- b->pins[17].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[17].aio.mux[0].pin = 211;
- b->pins[17].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[17].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[17].aio.mux[1].pin = 203;
- b->pins[17].aio.mux[1].value = 1;
+ b->pins[17].aio.mux_total = 1;
+ b->pins[17].aio.mux[0].pin = 203;
+ b->pins[17].aio.mux[0].value = 1;
b->pins[17].gpio.pinmap = 47;
- b->pins[17].gpio.mux_total = 2;
- b->pins[17].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[17].gpio.mux[0].pin = 211;
- b->pins[17].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[17].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[17].gpio.mux[1].pin = 203;
- b->pins[17].gpio.mux[1].value = 0;
+ b->pins[17].gpio.mux_total = 1;
+ b->pins[17].gpio.mux[0].pin = 203;
+ b->pins[17].gpio.mux[0].value = 0;
strncpy(b->pins[18].name, "A4", 8);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].i2c.pinmap = 1;
- b->pins[18].i2c.mux_total = 2;
- b->pins[18].i2c.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].i2c.mux[0].pin = 212;
- b->pins[18].i2c.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].i2c.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[18].i2c.mux[1].pin = 204;
- b->pins[18].i2c.mux[1].value = 0;
+ b->pins[18].i2c.mux_total = 1;
+ b->pins[18].i2c.mux[0].pin = 204;
+ b->pins[18].i2c.mux[0].value = 0;
b->pins[18].aio.pinmap = 4;
- b->pins[18].aio.mux_total = 2;
- b->pins[18].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].aio.mux[0].pin = 212;
- b->pins[18].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[18].aio.mux[1].pin = 204;
- b->pins[18].aio.mux[1].value = 1;
+ b->pins[18].aio.mux_total = 1;
+ b->pins[18].aio.mux[0].pin = 204;
+ b->pins[18].aio.mux[0].value = 1;
b->pins[18].gpio.pinmap = 14;
- b->pins[18].gpio.mux_total = 2;
- b->pins[18].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].gpio.mux[0].pin = 212;
- b->pins[18].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[18].gpio.mux[1].pin = 204;
- b->pins[18].gpio.mux[1].value = 0;
+ b->pins[18].gpio.mux_total = 1;
+ b->pins[18].gpio.mux[0].pin = 204;
+ b->pins[18].gpio.mux[0].value = 0;
strncpy(b->pins[19].name, "A5", 8);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].i2c.pinmap = 1;
- b->pins[19].i2c.mux_total = 2;
- b->pins[19].i2c.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[19].i2c.mux[0].pin = 213;
- b->pins[19].i2c.mux[0].value = MRAA_GPIO_IN;
- b->pins[19].i2c.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[19].i2c.mux[1].pin = 205;
- b->pins[19].i2c.mux[1].value = 0;
+ b->pins[19].i2c.mux_total = 1;
+ b->pins[19].i2c.mux[0].pin = 205;
+ b->pins[19].i2c.mux[0].value = 0;
b->pins[19].aio.pinmap = 5;
- b->pins[19].aio.mux_total = 2;
- b->pins[18].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].aio.mux[0].pin = 213;
- b->pins[18].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[19].aio.mux[1].pin = 205;
- b->pins[19].aio.mux[1].value = 1;
+ b->pins[19].aio.mux_total = 1;
+ b->pins[19].aio.mux[0].pin = 205;
+ b->pins[19].aio.mux[0].value = 1;
b->pins[19].gpio.pinmap = 165;
- b->pins[19].gpio.mux_total = 2;
- b->pins[19].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[19].gpio.mux[0].pin = 213;
- b->pins[19].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[19].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[19].gpio.mux[1].pin = 205;
- b->pins[19].gpio.mux[1].value = 0;
+ b->pins[19].gpio.mux_total = 1;
+ b->pins[19].gpio.mux[0].pin = 205;
+ b->pins[19].gpio.mux[0].value = 0;
// BUS DEFINITIONS
b->i2c_bus_count = 9;
@@ -1723,8 +1569,7 @@ mraa_intel_edison_fab_c()
pinmodes[6].pwm.sysfs = 182;
pinmodes[6].pwm.mode = 1;
- // 7 and 8 are provided by something on i2c, very simple
-
+ // 7 and 8 are provided by something on i2c, very simplepinmodes[3].gpio.sysfs = 12;
pinmodes[9].gpio.sysfs = 183;
pinmodes[9].gpio.mode = 0;
pinmodes[9].pwm.sysfs = 183;
@@ -1749,9 +1594,7 @@ mraa_intel_edison_fab_c()
pinmodes[13].gpio.mode = 0;
pinmodes[13].spi.sysfs = 109; // Different pin provides, switched at mux level.
pinmodes[13].spi.mode = 1;
-
// Everything else but A4 A5 LEAVE
-
pinmodes[18].gpio.sysfs = 14;
pinmodes[18].gpio.mode = 0;
pinmodes[18].i2c.sysfs = 28;
diff --git a/peripheral/libmraa/src/x86/intel_galileo_rev_d.c b/peripheral/libmraa/src/x86/intel_galileo_rev_d.c
index f9e4136..36335f1 100644
--- a/peripheral/libmraa/src/x86/intel_galileo_rev_d.c
+++ b/peripheral/libmraa/src/x86/intel_galileo_rev_d.c
@@ -179,13 +179,11 @@ mraa_intel_galileo_rev_d()
b->pins[0].gpio.pinmap = 50;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 1;
- b->pins[0].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[0].gpio.mux[0].pin = 40;
b->pins[0].gpio.mux[0].value = 1;
b->pins[0].uart.pinmap = 0;
b->pins[0].uart.parent_id = 0;
b->pins[0].uart.mux_total = 1;
- b->pins[0].uart.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[0].uart.mux[0].pin = 40;
b->pins[0].uart.mux[0].value = 0;
@@ -193,13 +191,11 @@ mraa_intel_galileo_rev_d()
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 51;
b->pins[1].gpio.mux_total = 1;
- b->pins[1].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[1].gpio.mux[0].pin = 41;
b->pins[1].gpio.mux[0].value = 1;
b->pins[1].uart.pinmap = 0;
b->pins[1].uart.parent_id = 0;
b->pins[1].uart.mux_total = 1;
- b->pins[1].uart.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[1].uart.mux[0].pin = 41;
b->pins[1].uart.mux[0].value = 0;
@@ -207,21 +203,15 @@ mraa_intel_galileo_rev_d()
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 0 };
b->pins[2].gpio.pinmap = 32;
b->pins[2].gpio.mux_total = 1;
- b->pins[2].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[2].gpio.mux[0].pin = 31;
b->pins[2].gpio.mux[0].value = 1;
b->pins[2].mmap.gpio.pinmap = 14;
strncpy(b->pins[2].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[2].mmap.gpio.mux_total = 3;
- b->pins[2].mmap.gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[2].mmap.gpio.mux[0].pin = 0;
+ b->pins[2].mmap.gpio.mux_total = 2;
+ b->pins[2].mmap.gpio.mux[0].pin = 31;
b->pins[2].mmap.gpio.mux[0].value = 0;
- b->pins[2].mmap.gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[2].mmap.gpio.mux[1].pin = 31;
+ b->pins[2].mmap.gpio.mux[1].pin = 14;
b->pins[2].mmap.gpio.mux[1].value = 0;
- b->pins[2].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[2].mmap.gpio.mux[2].pin = 14;
- b->pins[2].mmap.gpio.mux[2].value = 0;
b->pins[2].mmap.mem_sz = 0x1000;
b->pins[2].mmap.bit_pos = 6;
@@ -229,27 +219,20 @@ mraa_intel_galileo_rev_d()
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0, 0 };
b->pins[3].gpio.pinmap = 18;
b->pins[3].gpio.mux_total = 1;
- b->pins[3].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[3].gpio.mux[0].pin = 30;
b->pins[3].gpio.mux[0].value = 1;
b->pins[3].mmap.gpio.pinmap = 15;
strncpy(b->pins[3].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[3].mmap.gpio.mux_total = 3;
- b->pins[3].mmap.gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[3].mmap.gpio.mux[0].pin = 1;
+ b->pins[3].mmap.gpio.mux_total = 2;
+ b->pins[3].mmap.gpio.mux[0].pin = 30;
b->pins[3].mmap.gpio.mux[0].value = 0;
- b->pins[3].mmap.gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[3].mmap.gpio.mux[1].pin = 30;
+ b->pins[3].mmap.gpio.mux[1].pin = 15;
b->pins[3].mmap.gpio.mux[1].value = 0;
- b->pins[3].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[3].mmap.gpio.mux[2].pin = 15;
- b->pins[3].mmap.gpio.mux[2].value = 0;
b->pins[3].mmap.mem_sz = 0x1000;
b->pins[3].mmap.bit_pos = 7;
b->pins[3].pwm.pinmap = 3;
b->pins[3].pwm.parent_id = 0;
b->pins[3].pwm.mux_total = 1;
- b->pins[3].pwm.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[3].pwm.mux[0].pin = 30;
b->pins[3].pwm.mux[0].value = 1;
@@ -297,18 +280,15 @@ mraa_intel_galileo_rev_d()
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[10].gpio.pinmap = 16;
b->pins[10].gpio.mux_total = 1;
- b->pins[10].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[10].gpio.mux[0].pin = 42;
b->pins[10].gpio.mux[0].value = 1;
b->pins[10].pwm.pinmap = 7;
b->pins[10].pwm.parent_id = 0;
b->pins[10].pwm.mux_total = 1;
- b->pins[10].pwm.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[10].pwm.mux[0].pin = 42;
b->pins[10].pwm.mux[0].value = 1;
b->pins[10].spi.pinmap = 1;
b->pins[10].spi.mux_total = 1;
- b->pins[10].spi.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[10].spi.mux[0].pin = 42;
b->pins[10].spi.mux[0].value = 0;
@@ -316,18 +296,15 @@ mraa_intel_galileo_rev_d()
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[11].gpio.pinmap = 25;
b->pins[11].gpio.mux_total = 1;
- b->pins[11].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[11].gpio.mux[0].pin = 43;
b->pins[11].gpio.mux[0].value = 1;
b->pins[11].pwm.pinmap = 4;
b->pins[11].pwm.parent_id = 0;
b->pins[11].pwm.mux_total = 1;
- b->pins[11].pwm.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[11].pwm.mux[0].pin = 43;
b->pins[11].pwm.mux[0].value = 1;
b->pins[11].spi.pinmap = 1;
b->pins[11].spi.mux_total = 1;
- b->pins[11].spi.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[11].spi.mux[0].pin = 43;
b->pins[11].spi.mux[0].value = 0;
@@ -335,12 +312,10 @@ mraa_intel_galileo_rev_d()
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].gpio.pinmap = 38;
b->pins[12].gpio.mux_total = 1;
- b->pins[12].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[12].gpio.mux[0].pin = 54;
b->pins[12].gpio.mux[0].value = 1;
b->pins[12].spi.pinmap = 1;
b->pins[12].spi.mux_total = 1;
- b->pins[12].spi.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[12].spi.mux[0].pin = 54;
b->pins[12].spi.mux[0].value = 0;
@@ -348,12 +323,10 @@ mraa_intel_galileo_rev_d()
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].gpio.pinmap = 39;
b->pins[13].gpio.mux_total = 1;
- b->pins[13].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[13].gpio.mux[0].pin = 55;
b->pins[13].gpio.mux[0].value = 1;
b->pins[13].spi.pinmap = 1;
b->pins[13].spi.mux_total = 1;
- b->pins[13].spi.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[13].spi.mux[0].pin = 55;
b->pins[13].spi.mux[0].value = 0;
@@ -361,12 +334,10 @@ mraa_intel_galileo_rev_d()
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].gpio.pinmap = 44;
b->pins[14].gpio.mux_total = 1;
- b->pins[14].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[14].gpio.mux[0].pin = 37;
b->pins[14].gpio.mux[0].value = 1;
b->pins[14].aio.pinmap = 0;
b->pins[14].aio.mux_total = 1;
- b->pins[14].aio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[14].aio.mux[0].pin = 37;
b->pins[14].aio.mux[0].value = 0;
@@ -374,12 +345,10 @@ mraa_intel_galileo_rev_d()
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].gpio.pinmap = 45;
b->pins[15].gpio.mux_total = 1;
- b->pins[15].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[15].gpio.mux[0].pin = 36;
b->pins[15].gpio.mux[0].value = 1;
b->pins[15].aio.pinmap = 1;
b->pins[15].aio.mux_total = 1;
- b->pins[15].aio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[15].aio.mux[0].pin = 36;
b->pins[15].aio.mux[0].value = 0;
@@ -387,12 +356,10 @@ mraa_intel_galileo_rev_d()
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].gpio.pinmap = 46;
b->pins[16].gpio.mux_total = 1;
- b->pins[16].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[16].gpio.mux[0].pin = 23;
b->pins[16].gpio.mux[0].value = 1;
b->pins[16].aio.pinmap = 2;
b->pins[16].aio.mux_total = 1;
- b->pins[16].aio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[16].aio.mux[0].pin = 23;
b->pins[16].aio.mux[0].value = 0;
@@ -400,12 +367,10 @@ mraa_intel_galileo_rev_d()
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].gpio.pinmap = 47;
b->pins[17].gpio.mux_total = 1;
- b->pins[17].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[17].gpio.mux[0].pin = 22;
b->pins[17].gpio.mux[0].value = 1;
b->pins[17].aio.pinmap = 3;
b->pins[17].aio.mux_total = 1;
- b->pins[17].aio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[17].aio.mux[0].pin = 22;
b->pins[17].aio.mux[0].value = 0;
@@ -413,23 +378,18 @@ mraa_intel_galileo_rev_d()
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].gpio.pinmap = 48;
b->pins[18].gpio.mux_total = 2;
- b->pins[18].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[18].gpio.mux[0].pin = 29;
b->pins[18].gpio.mux[0].value = 1;
- b->pins[18].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[18].gpio.mux[1].pin = 21;
b->pins[18].gpio.mux[1].value = 1;
b->pins[18].i2c.pinmap = 1;
b->pins[18].i2c.mux_total = 1;
- b->pins[18].i2c.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[18].i2c.mux[0].pin = 29;
b->pins[18].i2c.mux[0].value = 0;
b->pins[18].aio.pinmap = 4;
b->pins[18].aio.mux_total = 2;
- b->pins[18].aio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[18].aio.mux[0].pin = 29;
b->pins[18].aio.mux[0].value = 1;
- b->pins[18].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[18].aio.mux[1].pin = 21;
b->pins[18].aio.mux[1].value = 0;
@@ -437,23 +397,18 @@ mraa_intel_galileo_rev_d()
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].gpio.pinmap = 49;
b->pins[19].gpio.mux_total = 2;
- b->pins[19].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[19].gpio.mux[0].pin = 29;
b->pins[19].gpio.mux[0].value = 1;
- b->pins[19].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[19].gpio.mux[1].pin = 20;
b->pins[19].gpio.mux[1].value = 1;
b->pins[19].i2c.pinmap = 1;
b->pins[19].i2c.mux_total = 1;
- b->pins[19].i2c.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[19].i2c.mux[0].pin = 29;
b->pins[19].i2c.mux[0].value = 0;
b->pins[19].aio.pinmap = 5;
b->pins[19].aio.mux_total = 2;
- b->pins[19].aio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[19].aio.mux[0].pin = 29;
b->pins[19].aio.mux[0].value = 1;
- b->pins[19].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
b->pins[19].aio.mux[1].pin = 20;
b->pins[19].aio.mux[1].value = 0;
diff --git a/peripheral/libmraa/src/x86/intel_galileo_rev_g.c b/peripheral/libmraa/src/x86/intel_galileo_rev_g.c
index acdee01..9c6583c 100644
--- a/peripheral/libmraa/src/x86/intel_galileo_rev_g.c
+++ b/peripheral/libmraa/src/x86/intel_galileo_rev_g.c
@@ -91,6 +91,33 @@ mraa_intel_galileo_gen2_gpio_close_pre(mraa_gpio_context dev)
}
mraa_result_t
+mraa_intel_galileo_gen2_i2c_init_pre(unsigned int bus)
+{
+ mraa_gpio_context io18 = mraa_gpio_init_raw(57);
+ int status = 0;
+
+ if (io18 == NULL) {
+ return MRAA_ERROR_UNSPECIFIED;
+ }
+ status += mraa_gpio_dir(io18, MRAA_GPIO_IN);
+ status += mraa_gpio_mode(io18, MRAA_GPIO_HIZ);
+ mraa_gpio_close(io18);
+
+ mraa_gpio_context io19 = mraa_gpio_init_raw(59);
+ if (io19 == NULL) {
+ return MRAA_ERROR_UNSPECIFIED;
+ }
+ status += mraa_gpio_dir(io19, MRAA_GPIO_IN);
+ status += mraa_gpio_mode(io19, MRAA_GPIO_HIZ);
+ mraa_gpio_close(io19);
+
+ if (status > 0) {
+ return MRAA_ERROR_UNSPECIFIED;
+ }
+ return MRAA_SUCCESS;
+}
+
+mraa_result_t
mraa_intel_galileo_gen2_pwm_period_replace(mraa_pwm_context dev, int period)
{
char bu[MAX_SIZE];
@@ -184,6 +211,35 @@ mraa_intel_galileo_gen2_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_
return MRAA_SUCCESS;
}
+mraa_result_t
+mraa_intel_galileo_gen2_uart_init_pre(int index)
+{
+ mraa_gpio_context io0_output = mraa_gpio_init_raw(32);
+ if (io0_output == NULL) {
+ return MRAA_ERROR_INVALID_RESOURCE;
+ }
+ mraa_gpio_context io1_output = mraa_gpio_init_raw(28);
+ if (io1_output == NULL) {
+ mraa_gpio_close(io0_output);
+ return MRAA_ERROR_INVALID_RESOURCE;
+ }
+
+ int status = 0;
+ status += mraa_gpio_dir(io0_output, MRAA_GPIO_OUT);
+ status += mraa_gpio_dir(io1_output, MRAA_GPIO_OUT);
+
+ status += mraa_gpio_write(io0_output, 1);
+ status += mraa_gpio_write(io1_output, 0);
+
+ mraa_gpio_close(io0_output);
+ mraa_gpio_close(io1_output);
+
+ if (status > 0) {
+ return MRAA_ERROR_UNSPECIFIED;
+ }
+ return MRAA_SUCCESS;
+}
+
static mraa_result_t
mraa_intel_galileo_g2_mmap_unsetup()
{
@@ -285,8 +341,10 @@ mraa_intel_galileo_gen2()
}
b->adv_func->gpio_close_pre = &mraa_intel_galileo_gen2_gpio_close_pre;
b->adv_func->gpio_dir_pre = &mraa_intel_galileo_gen2_dir_pre;
+ b->adv_func->i2c_init_pre = &mraa_intel_galileo_gen2_i2c_init_pre;
b->adv_func->pwm_period_replace = &mraa_intel_galileo_gen2_pwm_period_replace;
b->adv_func->gpio_mode_replace = &mraa_intel_galileo_gen2_gpio_mode_replace;
+ b->adv_func->uart_init_pre = &mraa_intel_galileo_gen2_uart_init_pre;
b->adv_func->gpio_mmap_setup = &mraa_intel_galileo_g2_mmap_setup;
b->pins = (mraa_pininfo_t*) calloc(MRAA_INTEL_GALILEO_GEN_2_PINCOUNT, sizeof(mraa_pininfo_t));
@@ -299,569 +357,376 @@ mraa_intel_galileo_gen2()
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 11;
b->pins[0].gpio.parent_id = 0;
- b->pins[0].gpio.mux_total = 1;
- b->pins[0].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[0].gpio.mux[0].pin = 33;
- b->pins[0].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[0].gpio.mux_total = 0;
b->pins[0].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[0].gpio.output_enable = 32;
+ b->pins[0].gpio.pullup_enable = 33;
b->pins[0].mmap.gpio.pinmap = 11;
strncpy(b->pins[0].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[0].mmap.gpio.mux_total = 3;
- b->pins[0].mmap.gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[0].mmap.gpio.mux[0].pin = 33;
- b->pins[0].mmap.gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[0].mmap.gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[0].mmap.gpio.mux[1].pin = 32;
+ b->pins[0].mmap.gpio.mux_total = 2;
+ b->pins[0].mmap.gpio.mux[0].pin = 32;
+ b->pins[0].mmap.gpio.mux[0].value = 0;
+ b->pins[0].mmap.gpio.mux[1].pin = 11;
b->pins[0].mmap.gpio.mux[1].value = 0;
- b->pins[0].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[0].mmap.gpio.mux[2].pin = 11;
- b->pins[0].mmap.gpio.mux[2].value = 0;
b->pins[0].mmap.mem_sz = 0x1000;
b->pins[0].mmap.bit_pos = 3;
b->pins[0].uart.parent_id = 0;
- b->pins[0].uart.mux_total = 2;
- b->pins[0].uart.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[0].uart.mux[0].pin = 33;
- b->pins[0].uart.mux[0].value = MRAA_GPIO_IN;
- b->pins[0].uart.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[0].uart.mux[1].pin = 32;
- b->pins[0].uart.mux[1].value = 1;
+ b->pins[0].uart.mux_total = 0;
strncpy(b->pins[1].name, "IO1", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 12;
b->pins[1].gpio.parent_id = 0;
- b->pins[1].gpio.mux_total = 2;
- b->pins[1].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[1].gpio.mux[0].pin = 29;
- b->pins[1].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[1].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[1].gpio.mux[1].pin = 45;
- b->pins[1].gpio.mux[1].value = 0;
+ b->pins[1].gpio.mux_total = 1;
+ b->pins[1].gpio.mux[0].pin = 45;
+ b->pins[1].gpio.mux[0].value = 0;
b->pins[1].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[1].gpio.output_enable = 28;
+ b->pins[1].gpio.pullup_enable = 29;
b->pins[1].mmap.gpio.pinmap = 12;
strncpy(b->pins[1].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[1].mmap.gpio.mux_total = 4;
- b->pins[1].mmap.gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[1].mmap.gpio.mux[0].pin = 29;
- b->pins[1].mmap.gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[1].mmap.gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[1].mmap.gpio.mux[1].pin = 45;
+ b->pins[1].mmap.gpio.mux_total = 3;
+ b->pins[1].mmap.gpio.mux[0].pin = 45;
+ b->pins[1].mmap.gpio.mux[0].value = 0;
+ b->pins[1].mmap.gpio.mux[1].pin = 28;
b->pins[1].mmap.gpio.mux[1].value = 0;
- b->pins[1].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[1].mmap.gpio.mux[2].pin = 28;
+ b->pins[1].mmap.gpio.mux[2].pin = 12;
b->pins[1].mmap.gpio.mux[2].value = 0;
- b->pins[1].mmap.gpio.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[1].mmap.gpio.mux[3].pin = 12;
- b->pins[1].mmap.gpio.mux[3].value = 0;
b->pins[1].mmap.mem_sz = 0x1000;
b->pins[1].mmap.bit_pos = 4;
b->pins[1].uart.parent_id = 0;
- b->pins[1].uart.mux_total = 3;
- b->pins[1].uart.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[1].uart.mux[0].pin = 29;
- b->pins[1].uart.mux[0].value = MRAA_GPIO_IN;
- b->pins[1].uart.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[1].uart.mux[1].pin = 45;
- b->pins[1].uart.mux[1].value = 1;
- b->pins[1].uart.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[1].uart.mux[2].pin = 28;
- b->pins[1].uart.mux[2].value = 0;
+ b->pins[1].uart.mux_total = 1;
+ b->pins[1].uart.mux[0].pin = 45;
+ b->pins[1].uart.mux[0].value = 1;
strncpy(b->pins[2].name, "IO2", 8);
- b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 0};
+ b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0 };
b->pins[2].gpio.pinmap = 13;
b->pins[2].gpio.parent_id = 0;
- b->pins[2].gpio.mux_total = 2;
- b->pins[2].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[2].gpio.mux[0].pin = 35;
- b->pins[2].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[2].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[2].gpio.mux[1].pin = 77;
- b->pins[2].gpio.mux[1].value = 0;
+ b->pins[2].gpio.mux_total = 1;
+ b->pins[2].gpio.mux[0].pin = 77;
+ b->pins[2].gpio.mux[0].value = 0;
b->pins[2].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[2].gpio.output_enable = 34;
+ b->pins[2].gpio.pullup_enable = 35;
b->pins[2].mmap.gpio.pinmap = 13;
strncpy(b->pins[2].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[2].mmap.gpio.mux_total = 4;
- b->pins[2].mmap.gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[2].mmap.gpio.mux[0].pin = 35;
- b->pins[2].mmap.gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[2].mmap.gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[2].mmap.gpio.mux[1].pin = 77;
+ b->pins[2].mmap.gpio.mux_total = 3;
+ b->pins[2].mmap.gpio.mux[0].pin = 77;
+ b->pins[2].mmap.gpio.mux[0].value = 0;
+ b->pins[2].mmap.gpio.mux[1].pin = 34;
b->pins[2].mmap.gpio.mux[1].value = 0;
- b->pins[2].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[2].mmap.gpio.mux[2].pin = 34;
+ b->pins[2].mmap.gpio.mux[2].pin = 13;
b->pins[2].mmap.gpio.mux[2].value = 0;
- b->pins[2].mmap.gpio.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[2].mmap.gpio.mux[3].pin = 13;
- b->pins[2].mmap.gpio.mux[3].value = 0;
b->pins[2].mmap.mem_sz = 0x1000;
b->pins[2].mmap.bit_pos = 5;
strncpy(b->pins[3].name, "IO3", 8);
- b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0, 0 };
+ b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0 };
b->pins[3].gpio.pinmap = 14;
b->pins[3].gpio.parent_id = 0;
- b->pins[3].gpio.mux_total = 3;
- b->pins[3].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[3].gpio.mux[0].pin = 17;
- b->pins[3].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[3].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[3].gpio.mux[1].pin = 76;
+ b->pins[3].gpio.mux_total = 2;
+ b->pins[3].gpio.mux[0].pin = 76;
+ b->pins[3].gpio.mux[0].value = 0;
+ b->pins[3].gpio.mux[1].pin = 64;
b->pins[3].gpio.mux[1].value = 0;
- b->pins[3].gpio.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[3].gpio.mux[2].pin = 64;
- b->pins[3].gpio.mux[2].value = 0;
b->pins[3].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[3].gpio.output_enable = 16;
+ b->pins[3].gpio.pullup_enable = 17;
b->pins[3].pwm.pinmap = 1;
b->pins[3].pwm.parent_id = 0;
- b->pins[3].pwm.mux_total = 4;
- b->pins[3].pwm.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[3].pwm.mux[0].pin = 17;
- b->pins[3].pwm.mux[0].value = MRAA_GPIO_IN;
- b->pins[3].pwm.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[3].pwm.mux[1].pin = 76;
- b->pins[3].pwm.mux[1].value = 0;
- b->pins[3].pwm.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[3].pwm.mux[2].pin = 64;
- b->pins[3].pwm.mux[2].value = 1;
- b->pins[3].pwm.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[3].pwm.mux[3].pin = 16;
- b->pins[3].pwm.mux[3].value = 0;
+ b->pins[3].pwm.mux_total = 3;
+ b->pins[3].pwm.mux[0].pin = 76;
+ b->pins[3].pwm.mux[0].value = 0;
+ b->pins[3].pwm.mux[1].pin = 64;
+ b->pins[3].pwm.mux[1].value = 1;
+ b->pins[3].pwm.mux[2].pin = 16;
+ b->pins[3].pwm.mux[2].value = 0;
b->pins[3].mmap.gpio.pinmap = 14;
strncpy(b->pins[3].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[3].mmap.gpio.mux_total = 5;
- b->pins[3].mmap.gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[3].mmap.gpio.mux[0].pin = 17;
- b->pins[3].mmap.gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[3].mmap.gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[3].mmap.gpio.mux[1].pin = 76;
+ b->pins[3].mmap.gpio.mux_total = 4;
+ b->pins[3].mmap.gpio.mux[0].pin = 76;
+ b->pins[3].mmap.gpio.mux[0].value = 0;
+ b->pins[3].mmap.gpio.mux[1].pin = 64;
b->pins[3].mmap.gpio.mux[1].value = 0;
- b->pins[3].mmap.gpio.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[3].mmap.gpio.mux[2].pin = 64;
+ b->pins[3].mmap.gpio.mux[2].pin = 16;
b->pins[3].mmap.gpio.mux[2].value = 0;
- b->pins[3].mmap.gpio.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[3].mmap.gpio.mux[3].pin = 16;
+ b->pins[3].mmap.gpio.mux[3].pin = 14;
b->pins[3].mmap.gpio.mux[3].value = 0;
- b->pins[3].mmap.gpio.mux[4].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[3].mmap.gpio.mux[4].pin = 14;
- b->pins[3].mmap.gpio.mux[4].value = 0;
b->pins[3].mmap.mem_sz = 0x1000;
b->pins[3].mmap.bit_pos = 6;
strncpy(b->pins[4].name, "IO4", 8);
- b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[4].gpio.pinmap = 6;
b->pins[4].gpio.parent_id = 0;
- b->pins[4].gpio.mux_total = 1;
- b->pins[4].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[4].gpio.mux[0].pin = 37;
- b->pins[4].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[4].gpio.mux_total = 0;
b->pins[4].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[4].gpio.output_enable = 36;
+ b->pins[4].gpio.pullup_enable = 37;
strncpy(b->pins[5].name, "IO5", 8);
- b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 , 0 };
+ b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[5].gpio.pinmap = 0;
b->pins[5].gpio.parent_id = 0;
- b->pins[5].gpio.mux_total = 2;
- b->pins[5].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[5].gpio.mux[0].pin = 19;
- b->pins[5].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[5].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[5].gpio.mux[1].pin = 66;
- b->pins[5].gpio.mux[1].value = 0;
+ b->pins[5].gpio.mux_total = 1;
+ b->pins[5].gpio.mux[0].pin = 66;
+ b->pins[5].gpio.mux[0].value = 0;
b->pins[5].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[5].gpio.output_enable = 18;
+ b->pins[5].gpio.pullup_enable = 19;
b->pins[5].pwm.pinmap = 3;
b->pins[5].pwm.parent_id = 0;
- b->pins[5].pwm.mux_total = 3;
- b->pins[5].pwm.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[5].pwm.mux[0].pin = 19;
- b->pins[5].pwm.mux[0].value = MRAA_GPIO_IN;
- b->pins[5].pwm.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[5].pwm.mux[1].pin = 66;
- b->pins[5].pwm.mux[1].value = 1;
- b->pins[5].pwm.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[5].pwm.mux[2].pin = 18;
- b->pins[5].pwm.mux[2].value = 0;
+ b->pins[5].pwm.mux_total = 2;
+ b->pins[5].pwm.mux[0].pin = 66;
+ b->pins[5].pwm.mux[0].value = 1;
+ b->pins[5].pwm.mux[1].pin = 18;
+ b->pins[5].pwm.mux[1].value = 0;
strncpy(b->pins[6].name, "IO6", 8);
- b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
+ b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[6].gpio.pinmap = 1;
b->pins[6].gpio.parent_id = 0;
- b->pins[6].gpio.mux_total = 2;
- b->pins[6].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[6].gpio.mux[0].pin = 21;
- b->pins[6].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[6].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[6].gpio.mux[1].pin = 68;
- b->pins[6].gpio.mux[1].value = 0;
+ b->pins[6].gpio.mux_total = 1;
+ b->pins[6].gpio.mux[0].pin = 68;
+ b->pins[6].gpio.mux[0].value = 0;
b->pins[6].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[6].gpio.output_enable = 20;
+ b->pins[6].gpio.pullup_enable = 21;
b->pins[6].pwm.pinmap = 5;
b->pins[6].pwm.parent_id = 0;
- b->pins[6].pwm.mux_total = 3;
- b->pins[6].pwm.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[6].pwm.mux[0].pin = 21;
- b->pins[6].pwm.mux[0].value = MRAA_GPIO_IN;
- b->pins[6].pwm.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[6].pwm.mux[1].pin = 68;
- b->pins[6].pwm.mux[1].value = 1;
- b->pins[6].pwm.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[6].pwm.mux[2].pin = 20;
- b->pins[6].pwm.mux[2].value = 0;
+ b->pins[6].pwm.mux_total = 2;
+ b->pins[6].pwm.mux[0].pin = 68;
+ b->pins[6].pwm.mux[0].value = 1;
+ b->pins[6].pwm.mux[1].pin = 20;
+ b->pins[6].pwm.mux[1].value = 0;
strncpy(b->pins[7].name, "IO7", 8);
- b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 38;
b->pins[7].gpio.parent_id = 0;
- b->pins[7].gpio.mux_total = 1;
- b->pins[7].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[7].gpio.mux[0].pin = 39;
- b->pins[7].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[7].gpio.mux_total = 0;
b->pins[7].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[7].gpio.pullup_enable = 39;
strncpy(b->pins[8].name, "IO8", 8);
- b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
+ b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 40;
b->pins[8].gpio.parent_id = 0;
- b->pins[8].gpio.mux_total = 1;
- b->pins[8].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[8].gpio.mux[0].pin = 41;
- b->pins[8].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[8].gpio.mux_total = 0;
b->pins[8].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[8].gpio.pullup_enable = 41;
strncpy(b->pins[9].name, "IO9", 8);
- b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
+ b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 4;
b->pins[9].gpio.parent_id = 0;
- b->pins[9].gpio.mux_total = 2;
- b->pins[9].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[9].gpio.mux[0].pin = 23;
- b->pins[9].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[9].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[9].gpio.mux[1].pin = 70;
- b->pins[9].gpio.mux[1].value = 0;
+ b->pins[9].gpio.mux_total = 1;
+ b->pins[9].gpio.mux[0].pin = 70;
+ b->pins[9].gpio.mux[0].value = 0;
b->pins[9].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[9].gpio.output_enable = 22;
+ b->pins[9].gpio.pullup_enable = 23;
b->pins[9].pwm.pinmap = 7;
b->pins[9].pwm.parent_id = 0;
- b->pins[9].pwm.mux_total = 3;
- b->pins[9].pwm.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[9].pwm.mux[0].pin = 23;
- b->pins[9].pwm.mux[0].value = MRAA_GPIO_IN;
- b->pins[9].pwm.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[9].pwm.mux[1].pin = 70;
- b->pins[9].pwm.mux[1].value = 1;
- b->pins[9].pwm.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[9].pwm.mux[2].pin = 22;
- b->pins[9].pwm.mux[2].value = 0;
+ b->pins[9].pwm.mux_total = 2;
+ b->pins[9].pwm.mux[0].pin = 70;
+ b->pins[9].pwm.mux[0].value = 1;
+ b->pins[9].pwm.mux[1].pin = 22;
+ b->pins[9].pwm.mux[1].value = 0;
strncpy(b->pins[10].name, "IO10", 8);
- b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 1, 0, 0, 0 };
+ b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 1, 0, 0 };
b->pins[10].gpio.pinmap = 10;
b->pins[10].gpio.parent_id = 0;
- b->pins[10].gpio.mux_total = 2;
- b->pins[10].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[10].gpio.mux[0].pin = 27;
- b->pins[10].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[10].gpio.mux[1].pin = 74;
- b->pins[10].gpio.mux[1].value = 0;
+ b->pins[10].gpio.mux_total = 1;
+ b->pins[10].gpio.mux[0].pin = 74;
+ b->pins[10].gpio.mux[0].value = 0;
b->pins[10].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[10].gpio.output_enable = 26;
+ b->pins[10].gpio.pullup_enable = 27;
b->pins[10].pwm.pinmap = 11;
b->pins[10].pwm.parent_id = 0;
- b->pins[10].pwm.mux_total = 3;
- b->pins[10].pwm.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[10].pwm.mux[0].pin = 27;
- b->pins[10].pwm.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].pwm.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[10].pwm.mux[1].pin = 74;
- b->pins[10].pwm.mux[1].value = 1;
- b->pins[10].pwm.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].pwm.mux[2].pin = 26;
- b->pins[10].pwm.mux[2].value = 0;
+ b->pins[10].pwm.mux_total = 2;
+ b->pins[10].pwm.mux[0].pin = 74;
+ b->pins[10].pwm.mux[0].value = 1;
+ b->pins[10].pwm.mux[1].pin = 26;
+ b->pins[10].pwm.mux[1].value = 0;
b->pins[10].mmap.gpio.pinmap = 10;
strncpy(b->pins[10].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[10].mmap.gpio.mux_total = 4;
- b->pins[10].mmap.gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[10].mmap.gpio.mux[0].pin = 27;
- b->pins[10].mmap.gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].mmap.gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[10].mmap.gpio.mux[1].pin = 74;
+ b->pins[10].mmap.gpio.mux_total = 3;
+ b->pins[10].mmap.gpio.mux[0].pin = 74;
+ b->pins[10].mmap.gpio.mux[0].value = 0;
+ b->pins[10].mmap.gpio.mux[1].pin = 26;
b->pins[10].mmap.gpio.mux[1].value = 0;
- b->pins[10].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].mmap.gpio.mux[2].pin = 26;
+ b->pins[10].mmap.gpio.mux[2].pin = 10;
b->pins[10].mmap.gpio.mux[2].value = 0;
- b->pins[10].mmap.gpio.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].mmap.gpio.mux[3].pin = 10;
- b->pins[10].mmap.gpio.mux[3].value = 0;
b->pins[10].mmap.mem_sz = 0x1000;
b->pins[10].mmap.bit_pos = 2;
b->pins[10].spi.parent_id = 1;
- b->pins[10].spi.mux_total = 3;
- b->pins[10].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[10].spi.mux[0].pin = 27;
- b->pins[10].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[10].spi.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[10].spi.mux[1].pin = 74;
- b->pins[10].spi.mux[1].value = 0;
- b->pins[10].spi.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[10].spi.mux[2].pin = 26;
- b->pins[10].spi.mux[2].value = 0;
+ b->pins[10].spi.mux_total = 1;
+ b->pins[10].spi.mux[0].pin = 74;
+ b->pins[10].spi.mux[0].value = 0;
strncpy(b->pins[11].name, "IO11", 8);
- b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
+ b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0 };
b->pins[11].gpio.pinmap = 5;
b->pins[11].gpio.parent_id = 0;
- b->pins[11].gpio.mux_total = 3;
- b->pins[11].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[11].gpio.mux[0].pin = 25;
- b->pins[11].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[11].gpio.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[11].gpio.mux[1].pin = 72;
+ b->pins[11].gpio.mux_total = 2;
+ b->pins[11].gpio.mux[0].pin = 72;
+ b->pins[11].gpio.mux[0].value = 0;
+ b->pins[11].gpio.mux[1].pin = 44;
b->pins[11].gpio.mux[1].value = 0;
- b->pins[11].gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].gpio.mux[2].pin = 44;
- b->pins[11].gpio.mux[2].value = 0;
b->pins[11].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[11].gpio.output_enable = 24;
+ b->pins[11].gpio.pullup_enable = 25;
b->pins[11].pwm.pinmap = 9;
b->pins[11].pwm.parent_id = 0;
- b->pins[11].pwm.mux_total = 4;
- b->pins[11].pwm.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[11].pwm.mux[0].pin = 25;
- b->pins[11].pwm.mux[0].value = MRAA_GPIO_IN;
- b->pins[11].pwm.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[11].pwm.mux[1].pin = 72;
- b->pins[11].pwm.mux[1].value = 1;
- b->pins[11].pwm.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].pwm.mux[2].pin = 44;
+ b->pins[11].pwm.mux_total = 3;
+ b->pins[11].pwm.mux[0].pin = 72;
+ b->pins[11].pwm.mux[0].value = 1;
+ b->pins[11].pwm.mux[1].pin = 44;
+ b->pins[11].pwm.mux[1].value = 0;
+ b->pins[11].pwm.mux[2].pin = 24;
b->pins[11].pwm.mux[2].value = 0;
- b->pins[11].pwm.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].pwm.mux[3].pin = 24;
- b->pins[11].pwm.mux[3].value = 0;
b->pins[11].spi.pinmap = 1;
- b->pins[11].spi.mux_total = 4;
- b->pins[11].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[11].spi.mux[0].pin = 25;
- b->pins[11].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[11].spi.mux[1].pincmd = PINCMD_SET_VALUE;
- b->pins[11].spi.mux[1].pin = 72;
- b->pins[11].spi.mux[1].value = 0;
- b->pins[11].spi.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].spi.mux[2].pin = 44;
- b->pins[11].spi.mux[2].value = 1;
- b->pins[11].spi.mux[3].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[11].spi.mux[3].pin = 24;
- b->pins[11].spi.mux[3].value = 0;
+ b->pins[11].spi.mux_total = 3;
+ b->pins[11].spi.mux[0].pin = 72;
+ b->pins[11].spi.mux[0].value = 0;
+ b->pins[11].spi.mux[1].pin = 44;
+ b->pins[11].spi.mux[1].value = 1;
+ b->pins[11].spi.mux[2].pin = 24;
+ b->pins[11].spi.mux[2].value = 0;
strncpy(b->pins[12].name, "IO12", 8);
- b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 1, 0, 0, 0 };
+ b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 1, 0, 0 };
b->pins[12].gpio.pinmap = 15;
b->pins[12].gpio.parent_id = 0;
- b->pins[12].gpio.mux_total = 1;
- b->pins[12].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[12].gpio.mux[0].pin = 43;
- b->pins[12].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[12].gpio.mux_total = 0;
b->pins[12].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[12].gpio.output_enable = 42;
+ b->pins[12].gpio.pullup_enable = 43;
b->pins[12].spi.pinmap = 1;
- b->pins[12].spi.mux_total = 2;
- b->pins[12].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[12].spi.mux[0].pin = 43;
- b->pins[12].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[12].spi.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[12].spi.mux[1].pin = 42;
- b->pins[12].spi.mux[1].value = 1;
+ b->pins[12].spi.mux_total = 1;
+ b->pins[12].spi.mux[0].pin = 42;
+ b->pins[12].spi.mux[0].value = 1;
b->pins[12].mmap.gpio.pinmap = 15;
strncpy(b->pins[12].mmap.mem_dev, "/dev/uio0", 12);
- b->pins[12].mmap.gpio.mux_total = 3;
- b->pins[12].mmap.gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[12].mmap.gpio.mux[0].pin = 43;
- b->pins[12].mmap.gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[12].mmap.gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[12].mmap.gpio.mux[1].pin = 42;
+ b->pins[12].mmap.gpio.mux_total = 2;
+ b->pins[12].mmap.gpio.mux[0].pin = 42;
+ b->pins[12].mmap.gpio.mux[0].value = 0;
+ b->pins[12].mmap.gpio.mux[1].pin = 15;
b->pins[12].mmap.gpio.mux[1].value = 0;
- b->pins[12].mmap.gpio.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[12].mmap.gpio.mux[2].pin = 15;
- b->pins[12].mmap.gpio.mux[2].value = 0;
b->pins[12].mmap.mem_sz = 0x1000;
b->pins[12].mmap.bit_pos = 7;
strncpy(b->pins[13].name, "IO13", 8);
- b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
+ b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0 };
b->pins[13].gpio.pinmap = 7;
b->pins[13].gpio.parent_id = 0;
- b->pins[13].gpio.mux_total = 2;
- b->pins[13].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[13].gpio.mux[0].pin = 31;
- b->pins[13].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[13].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[13].gpio.mux[1].pin = 46;
- b->pins[13].gpio.mux[1].value = 0;
+ b->pins[13].gpio.mux_total = 1;
+ b->pins[13].gpio.mux[0].pin = 46;
+ b->pins[13].gpio.mux[0].value = 0;
b->pins[13].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 1, 0, 1, 1 };
b->pins[13].gpio.output_enable = 30;
+ b->pins[13].gpio.pullup_enable = 31;
b->pins[13].spi.pinmap = 1;
- b->pins[13].spi.mux_total = 3;
- b->pins[13].spi.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[13].spi.mux[0].pin = 31;
- b->pins[13].spi.mux[0].value = MRAA_GPIO_IN;
- b->pins[13].spi.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[13].spi.mux[1].pin = 46;
- b->pins[13].spi.mux[1].value = 1;
- b->pins[13].spi.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[13].spi.mux[2].pin = 30;
- b->pins[13].spi.mux[2].value = 0;
+ b->pins[13].spi.mux_total = 2;
+ b->pins[13].spi.mux[0].pin = 46;
+ b->pins[13].spi.mux[0].value = 1;
+ b->pins[13].spi.mux[1].pin = 30;
+ b->pins[13].spi.mux[1].value = 0;
// ANALOG
strncpy(b->pins[14].name, "A0", 8);
- b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
+ b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1 };
b->pins[14].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[14].gpio.pullup_enable = 49;
b->pins[14].aio.pinmap = 0;
- b->pins[14].aio.mux_total = 2;
- b->pins[14].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
+ b->pins[14].aio.mux_total = 1;
b->pins[14].aio.mux[0].pin = 49;
- b->pins[14].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[14].aio.mux[1].pincmd = PINCMD_SET_DIRECTION;
- b->pins[14].aio.mux[1].pin = 48;
- b->pins[14].aio.mux[1].value = MRAA_GPIO_IN;
+ b->pins[14].aio.mux[0].value = 1;
b->pins[14].gpio.pinmap = 48;
- b->pins[14].gpio.mux_total = 1;
- b->pins[14].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[14].gpio.mux[0].pin = 49;
- b->pins[14].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[14].gpio.mux_total = 0;
strncpy(b->pins[15].name, "A1", 8);
- b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
+ b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1 };
b->pins[15].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[15].gpio.pullup_enable = 51;
b->pins[15].aio.pinmap = 1;
- b->pins[15].aio.mux_total = 2;
- b->pins[15].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
b->pins[15].aio.mux[0].pin = 51;
- b->pins[15].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[15].aio.mux[1].pincmd = PINCMD_SET_DIRECTION;
- b->pins[15].aio.mux[1].pin = 50;
- b->pins[15].aio.mux[1].value = MRAA_GPIO_IN;
+ b->pins[15].aio.mux[0].value = 1;
+ b->pins[15].aio.mux_total = 0;
b->pins[15].gpio.pinmap = 50;
- b->pins[15].gpio.mux_total = 1;
- b->pins[15].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[15].gpio.mux[0].pin = 51;
- b->pins[15].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[15].gpio.mux_total = 0;
strncpy(b->pins[16].name, "A2", 8);
- b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
+ b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1 };
b->pins[16].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[16].gpio.pullup_enable = 53;
b->pins[16].aio.pinmap = 2;
- b->pins[16].aio.mux_total = 2;
- b->pins[16].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
+ b->pins[16].aio.mux_total = 1;
b->pins[16].aio.mux[0].pin = 53;
- b->pins[16].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[16].aio.mux[1].pincmd = PINCMD_SET_DIRECTION;
- b->pins[16].aio.mux[1].pin = 52;
- b->pins[16].aio.mux[1].value = MRAA_GPIO_IN;
+ b->pins[16].aio.mux[0].value = 1;
b->pins[16].gpio.pinmap = 52;
- b->pins[16].gpio.mux_total = 1;
- b->pins[16].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[16].gpio.mux[0].pin = 53;
- b->pins[16].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[16].gpio.mux_total = 0;
strncpy(b->pins[17].name, "A3", 8);
- b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
+ b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1 };
b->pins[17].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[17].gpio.pullup_enable = 55;
b->pins[17].aio.pinmap = 3;
- b->pins[17].aio.mux_total = 2;
- b->pins[17].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
+ b->pins[17].aio.mux_total = 1;
b->pins[17].aio.mux[0].pin = 55;
- b->pins[17].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[17].aio.mux[1].pincmd = PINCMD_SET_DIRECTION;
- b->pins[17].aio.mux[1].pin = 54;
- b->pins[17].aio.mux[1].value = MRAA_GPIO_IN;
+ b->pins[17].aio.mux[0].value = 1;
b->pins[17].gpio.pinmap = 54;
- b->pins[17].gpio.mux_total = 1;
- b->pins[17].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[17].gpio.mux[0].pin = 55;
- b->pins[17].gpio.mux[0].value = MRAA_GPIO_IN;
+ b->pins[17].gpio.mux_total = 0;
strncpy(b->pins[18].name, "A4", 8);
- b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
+ b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1 };
b->pins[18].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[18].gpio.pullup_enable = 57;
b->pins[18].i2c.pinmap = 1;
- b->pins[18].i2c.mux_total = 3;
- b->pins[18].i2c.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].i2c.mux[0].pin = 57;
- b->pins[18].i2c.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].i2c.mux[1].pincmd = PINCMD_SET_MODE;
- b->pins[18].i2c.mux[1].pin = 57;
- b->pins[18].i2c.mux[1].value = MRAA_GPIO_HIZ;
- b->pins[18].i2c.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[18].i2c.mux[2].pin = 60;
- b->pins[18].i2c.mux[2].value = 0;
+ b->pins[18].i2c.mux_total = 1;
+ b->pins[18].i2c.mux[0].pin = 60;
+ b->pins[18].i2c.mux[0].value = 0;
b->pins[18].aio.pinmap = 4;
b->pins[18].aio.mux_total = 3;
- b->pins[18].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].aio.mux[0].pin = 57;
- b->pins[18].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[18].aio.mux[1].pin = 60;
- b->pins[18].aio.mux[1].value = 1;
- b->pins[18].aio.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[18].aio.mux[2].pin = 78;
+ b->pins[18].aio.mux[0].pin = 60;
+ b->pins[18].aio.mux[0].value = 1;
+ b->pins[18].aio.mux[1].pin = 78;
+ b->pins[18].aio.mux[1].value = 0;
+ b->pins[18].aio.mux[2].pin = 57;
b->pins[18].aio.mux[2].value = 0;
b->pins[18].gpio.pinmap = 56;
- b->pins[18].gpio.mux_total = 3;
- b->pins[18].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[18].gpio.mux[0].pin = 57;
- b->pins[18].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[18].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[18].gpio.mux[1].pin = 60;
+ b->pins[18].gpio.mux_total = 2;
+ b->pins[18].gpio.mux[0].pin = 60;
+ b->pins[18].gpio.mux[0].value = 1;
+ b->pins[18].gpio.mux[1].pin = 78;
b->pins[18].gpio.mux[1].value = 1;
- b->pins[18].gpio.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[18].gpio.mux[2].pin = 78;
- b->pins[18].gpio.mux[2].value = 1;
strncpy(b->pins[19].name, "A5", 8);
- b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
+ b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1 };
b->pins[19].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
+ b->pins[19].gpio.pullup_enable = 59;
b->pins[19].i2c.pinmap = 1;
- b->pins[19].i2c.mux_total = 3;
- b->pins[19].i2c.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[19].i2c.mux[0].pin = 59;
- b->pins[19].i2c.mux[0].value = MRAA_GPIO_IN;
- b->pins[19].i2c.mux[1].pincmd = PINCMD_SET_MODE;
- b->pins[19].i2c.mux[1].pin = 59;
- b->pins[19].i2c.mux[1].value = MRAA_GPIO_HIZ;
- b->pins[19].i2c.mux[2].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[19].i2c.mux[2].pin = 60;
- b->pins[19].i2c.mux[2].value = 0;
+ b->pins[19].i2c.mux_total = 1;
+ b->pins[19].i2c.mux[0].pin = 60;
+ b->pins[19].i2c.mux[0].value = 0;
b->pins[19].aio.pinmap = 5;
b->pins[19].aio.mux_total = 3;
- b->pins[19].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[19].aio.mux[0].pin = 59;
- b->pins[19].aio.mux[0].value = MRAA_GPIO_IN;
- b->pins[19].aio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[19].aio.mux[1].pin = 60;
- b->pins[19].aio.mux[1].value = 1;
- b->pins[19].aio.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[19].aio.mux[2].pin = 79;
- b->pins[19].aio.mux[2].value = 0;
+ b->pins[19].aio.mux[0].pin = 60;
+ b->pins[19].aio.mux[0].value = 1;
+ b->pins[19].aio.mux[1].pin = 79;
+ b->pins[19].aio.mux[1].value = 0;
+ b->pins[19].aio.mux[2].pin = 59;
+ b->pins[19].aio.mux[2].value = 1;
b->pins[19].gpio.pinmap = 58;
- b->pins[19].gpio.mux_total = 3;
- b->pins[19].gpio.mux[0].pincmd = PINCMD_SET_DIRECTION;
- b->pins[19].gpio.mux[0].pin = 59;
- b->pins[19].gpio.mux[0].value = MRAA_GPIO_IN;
- b->pins[19].gpio.mux[1].pincmd = PINCMD_SET_OUT_VALUE;
- b->pins[19].gpio.mux[1].pin = 60;
+ b->pins[19].gpio.mux_total = 2;
+ b->pins[19].gpio.mux[0].pin = 60;
+ b->pins[19].gpio.mux[0].value = 1;
+ b->pins[19].gpio.mux[1].pin = 79;
b->pins[19].gpio.mux[1].value = 1;
- b->pins[19].gpio.mux[2].pincmd = PINCMD_SET_VALUE;
- b->pins[19].gpio.mux[2].pin = 79;
- b->pins[19].gpio.mux[2].value = 1;
// BUS DEFINITIONS
b->i2c_bus_count = 1;
diff --git a/peripheral/libmraa/src/x86/intel_gt_tuchuck.c b/peripheral/libmraa/src/x86/intel_gt_tuchuck.c
deleted file mode 100644
index 772c724..0000000
--- a/peripheral/libmraa/src/x86/intel_gt_tuchuck.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "common.h"
-#include "x86/intel_gt_tuchuck.h"
-
-#define PLATFORM_NAME "Intel GT Tuchuck"
-
-mraa_board_t*
-mraa_gt_tuchuck_board()
-{
- mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
- if (b == NULL) {
- return NULL;
- }
-
- b->platform_name = PLATFORM_NAME;
- b->phy_pin_count = MRAA_INTEL_GT_TUCHUCK_PINCOUNT;
- b->aio_count = 0;
- b->adc_raw = 0;
- b->adc_supported = 0;
-
- b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_INTEL_GT_TUCHUCK_PINCOUNT);
- if (b->pins == NULL) {
- goto error;
- }
-
- b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
- if (b->adv_func == NULL) {
- free(b->pins);
- goto error;
- }
-
- b->pwm_default_period = 5000;
- b->pwm_max_period = 218453;
- b->pwm_min_period = 1;
-
- b->i2c_bus_count = 3;
- b->i2c_bus[0].bus_id = 0;
- b->i2c_bus[0].sda = 11;
- b->i2c_bus[0].scl = 13;
- b->i2c_bus[1].bus_id = 5;
- b->i2c_bus[1].sda = 15;
- b->i2c_bus[1].scl = 17;
- b->i2c_bus[1].bus_id = 6;
- b->i2c_bus[1].sda = 19;
- b->i2c_bus[1].scl = 21;
- b->def_i2c_bus = b->i2c_bus[0].bus_id;
-
-#if 0
- b->spi_bus_count = 6;
- b->def_spi_bus = 0;
- b->spi_bus[0].bus_id = 32764;
- b->spi_bus[0].slave_s = 1;
- b->spi_bus[1].bus_id = 32764;
- b->spi_bus[1].slave_s = 2;
- b->spi_bus[2].bus_id = 32765;
- b->spi_bus[2].slave_s = 0;
- b->spi_bus[3].bus_id = 32765;
- b->spi_bus[3].slave_s = 1;
- b->spi_bus[4].bus_id = 32766;
- b->spi_bus[4].slave_s = 0;
- b->spi_bus[5].bus_id = 32766;
- b->spi_bus[5].slave_s = 1;
-#endif
-
- int pos = 0;
-
- strncpy(b->pins[pos].name, "INVALID", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GPIO", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 446;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP1RX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 421;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "PMICRST", 8);
- // disabled as this pin causes a reset
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 366;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP1TX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 422;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "19.2mhz", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 356;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP1FS0", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 417;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART0TX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
- // not configured as GPIO
- //b->pins[pos].gpio.pinmap = 462;
- //b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP1FS2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 419;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "PWRGD", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- // not configured as GPI0 - does read work?
- //b->pins[pos].gpio.pinmap = 365;
- //b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP1CLK", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 416;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- // pin 11
- strncpy(b->pins[pos].name, "I2C0SDA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 315;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S1SDI", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 381;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C0SCL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 316;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S1SDO", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 382;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C1SDA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 331;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S1WS", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 380;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C1SCL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 332;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- b->pins[pos].i2c.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S1CLK", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 379;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C2SDA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 333;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- b->pins[pos].i2c.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S1MCL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 378;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C2SCL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 334;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART1TX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
- //b->pins[pos].gpio.pinmap = 472;
- //b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S4SDO", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- // doesn't work so disable
- //b->pins[pos].gpio.pinmap = 396;
- //b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART1RX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
- //b->pins[pos].gpio.pinmap = 471;
- //b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S4SDI", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- // doesnt work
- //b->pins[pos].gpio.pinmap = 395;
- //b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "PWM0", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 463;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].pwm.pinmap = 0;
- b->pins[pos].pwm.parent_id = 0;
- b->pins[pos].pwm.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S4BLK", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- // this pin has a voltage of 0.34V in 'low' mode - beware!
- b->pins[pos].gpio.pinmap = 397;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "PWM1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 464;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].pwm.pinmap = 1;
- b->pins[pos].pwm.parent_id = 0;
- b->pins[pos].pwm.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S4WS", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- // not working
- //b->pins[pos].gpio.pinmap = 398;
- //b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "PWM2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 465;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].pwm.pinmap = 2;
- b->pins[pos].pwm.parent_id = 0;
- b->pins[pos].pwm.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S3SDO", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- //b->pins[pos].gpio.pinmap = 400;
- //b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "PWM3", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 466;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].pwm.pinmap = 3;
- b->pins[pos].pwm.parent_id = 0;
- b->pins[pos].pwm.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2S3SDI", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- //b->pins[pos].gpio.pinmap = 399;
- //b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "1.8V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "I2S4BLK", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 393;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "3.3V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- // second header
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "5V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "5V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "3.3V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "3.3V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "1.8V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "GPIO", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 456;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "1.8V", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "PANEL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 270;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "GND", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "PANEL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 271;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "CAMERA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "PANEL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 272;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "CAMERA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "SPP0FS0", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 411;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "CAMERA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
-
- strncpy(b->pins[pos].name, "SPP0FS1", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 412;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPI_DAT", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 385;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP0FS2", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 411;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPICLKB", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 384;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP0FS3", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 410;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPICLKA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 383;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP0TX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 414;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART0RX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 467;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "SPP0RX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 415;
- b->pins[pos].gpio.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART0RT", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 469;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C1SDA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 317;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- b->pins[pos].i2c.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART0CT", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 412;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C1SCL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 318;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- b->pins[pos].i2c.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART1TX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 484;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C2SDA", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 319;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- b->pins[pos].i2c.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART1RX", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 483;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "I2C1SCL", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
- b->pins[pos].gpio.pinmap = 320;
- b->pins[pos].gpio.mux_total = 0;
- b->pins[pos].i2c.pinmap = 0;
- b->pins[pos].i2c.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "UART1RT", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 485;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- strncpy(b->pins[pos].name, "RTC_CLK", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 367;
- pos++;
-
- strncpy(b->pins[pos].name, "UART1CT", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
- b->pins[pos].gpio.pinmap = 486;
- b->pins[pos].uart.pinmap = 0;
- b->pins[pos].uart.parent_id = 0;
- b->pins[pos].uart.mux_total = 0;
- pos++;
-
- while (pos != 100) {
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
- pos++;
- }
-
- strncpy(b->pins[pos].name, "LED100", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 337;
- pos++;
-
- strncpy(b->pins[pos].name, "LED101", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- // if BIOS is pre-L then this is 338
- b->pins[pos].gpio.pinmap = 395;
- pos++;
-
- strncpy(b->pins[pos].name, "LED102", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 339;
- pos++;
-
- strncpy(b->pins[pos].name, "LED103", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 340;
- pos++;
-
- strncpy(b->pins[pos].name, "LEDWIFI", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 438;
- pos++;
-
- strncpy(b->pins[pos].name, "LEDBT", 8);
- b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
- b->pins[pos].gpio.pinmap = 439;
- pos++;
-
- return b;
-
-error:
- syslog(LOG_CRIT, "GT Tuchuck: Platform failed to initialise");
- free(b);
- return NULL;
-}
diff --git a/peripheral/libmraa/src/x86/intel_nuc5.c b/peripheral/libmraa/src/x86/intel_nuc5.c
index 4930364..840dd98 100644
--- a/peripheral/libmraa/src/x86/intel_nuc5.c
+++ b/peripheral/libmraa/src/x86/intel_nuc5.c
@@ -126,8 +126,8 @@ mraa_intel_nuc5()
}
b->i2c_bus_count++;
b->i2c_bus[i].bus_id = i2c_num;
- b->i2c_bus[i].sda = 12 + (i*2);
- b->i2c_bus[i].scl = 13 + (i*2);
+ b->i2c_bus[i].sda = 12 + i;
+ b->i2c_bus[i].scl = 13 + i;
}
if (b->i2c_bus_count > 0) {
diff --git a/peripheral/libmraa/src/x86/up.c b/peripheral/libmraa/src/x86/up.c
index 556c1c3..24b269d 100644
--- a/peripheral/libmraa/src/x86/up.c
+++ b/peripheral/libmraa/src/x86/up.c
@@ -1,3 +1,4 @@
+
/*
* Author: Dan O'Donovan <dan@emutex.com>
* Copyright (c) 2015 Emutex Ltd.
@@ -163,14 +164,14 @@ mraa_up_board()
// Configure i2c adaptor #0 (default)
// (For consistency with Raspberry Pi 2, use I2C1 as our primary I2C bus)
b->i2c_bus[0].bus_id = 1;
- get_pin_index(b, "I2C1_SDA", (int*) &(b->i2c_bus[0].sda));
- get_pin_index(b, "I2C1_SCL", (int*) &(b->i2c_bus[0].scl));
+ get_pin_index(b, "I2C1_SDA", &(b->i2c_bus[0].sda));
+ get_pin_index(b, "I2C1_SCL", &(b->i2c_bus[0].scl));
// Configure i2c adaptor #1
// (normally reserved for accessing HAT EEPROM)
b->i2c_bus[1].bus_id = 0;
- get_pin_index(b, "I2C0_SDA", (int*) &(b->i2c_bus[1].sda));
- get_pin_index(b, "I2C0_SCL", (int*) &(b->i2c_bus[1].scl));
+ get_pin_index(b, "I2C0_SDA", &(b->i2c_bus[1].sda));
+ get_pin_index(b, "I2C0_SCL", &(b->i2c_bus[1].scl));
b->def_i2c_bus = 0;
// Configure PWM
@@ -182,18 +183,18 @@ mraa_up_board()
b->spi_bus_count = 2;
b->spi_bus[0].bus_id = 2;
b->spi_bus[0].slave_s = 0;
- get_pin_index(b, "SPI_CS0", (int*) &(b->spi_bus[0].cs));
- get_pin_index(b, "SPI_MOSI", (int*) &(b->spi_bus[0].mosi));
- get_pin_index(b, "SPI_MISO", (int*) &(b->spi_bus[0].miso));
- get_pin_index(b, "SPI_CLK", (int*) &(b->spi_bus[0].sclk));
+ get_pin_index(b, "SPI_CS0", &(b->spi_bus[0].cs));
+ get_pin_index(b, "SPI_MOSI", &(b->spi_bus[0].mosi));
+ get_pin_index(b, "SPI_MISO", &(b->spi_bus[0].miso));
+ get_pin_index(b, "SPI_CLK", &(b->spi_bus[0].sclk));
b->def_spi_bus = 0;
// Configure SPI #0 CS1
b->spi_bus[1].bus_id = 2;
b->spi_bus[1].slave_s = 1;
- get_pin_index(b, "SPI_CS1", (int*) &(b->spi_bus[1].cs));
- get_pin_index(b, "SPI_MOSI", (int*) &(b->spi_bus[1].mosi));
- get_pin_index(b, "SPI_MISO", (int*) &(b->spi_bus[1].miso));
- get_pin_index(b, "SPI_CLK", (int*) &(b->spi_bus[1].sclk));
+ get_pin_index(b, "SPI_CS1", &(b->spi_bus[1].cs));
+ get_pin_index(b, "SPI_MOSI", &(b->spi_bus[1].mosi));
+ get_pin_index(b, "SPI_MISO", &(b->spi_bus[1].miso));
+ get_pin_index(b, "SPI_CLK", &(b->spi_bus[1].sclk));
// Configure UART #1 (default)
b->uart_dev_count = 2;
diff --git a/peripheral/libmraa/src/x86/x86.c b/peripheral/libmraa/src/x86/x86.c
index b3a0ae5..2f1be3a 100644
--- a/peripheral/libmraa/src/x86/x86.c
+++ b/peripheral/libmraa/src/x86/x86.c
@@ -37,7 +37,6 @@
#include "x86/intel_sofia_3gr.h"
#include "x86/intel_cherryhills.h"
#include "x86/up.h"
-#include "x86/intel_gt_tuchuck.h"
mraa_platform_t
mraa_x86_platform()
@@ -87,12 +86,6 @@ mraa_x86_platform()
} else if (strncasecmp(line, "UP-CHT01", 8) == 0) {
platform_type = MRAA_UP;
plat = mraa_up_board();
- } else if (strncasecmp(line, "RVP", 3) == 0) {
- platform_type = MRAA_INTEL_GT_TUCHUCK;
- plat = mraa_gt_tuchuck_board();
- } else if (strncasecmp(line, "SDS", 3) == 0) {
- platform_type = MRAA_INTEL_GT_TUCHUCK;
- plat = mraa_gt_tuchuck_board();
} else {
syslog(LOG_ERR, "Platform not supported, not initialising");
platform_type = MRAA_UNKNOWN_PLATFORM;
@@ -133,8 +126,6 @@ mraa_x86_platform()
plat = mraa_intel_cherryhills();
#elif defined(xMRAA_UP)
plat = mraa_up_board();
- #elif defined(xMRAA_INTEL_GT_TUCHUCK)
- plat = mraa_gt_tuchuck_board();
#else
#error "Not using a valid platform value from mraa_platform_t - cannot compile"
#endif
diff --git a/peripheral/libmraa/tests/CMakeLists.txt b/peripheral/libmraa/tests/CMakeLists.txt
index df3baf8..6ebb8bd 100644
--- a/peripheral/libmraa/tests/CMakeLists.txt
+++ b/peripheral/libmraa/tests/CMakeLists.txt
@@ -9,17 +9,12 @@ if (BUILDSWIGJAVA)
endif()
if (BUILDSWIGPYTHON)
- if (PYTHON2INTERP_FOUND)
- set (PYTHON_DEFAULT_PYTHONPATH "${CMAKE_BINARY_DIR}/src/python/python2")
- elseif (PYTHON3INTERP_FOUND)
- set (PYTHON_DEFAULT_PYTHONPATH "${CMAKE_BINARY_DIR}/src/python/python3")
- endif ()
- add_test (NAME py_general COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
- set_tests_properties(py_general PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
+ add_test (NAME py_general COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
+ set_tests_properties(py_general PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
- add_test (NAME py_platform COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
- set_tests_properties(py_platform PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
+ add_test (NAME py_platform COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
+ set_tests_properties(py_platform PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
- add_test (NAME py_gpio COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
- set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
+ add_test (NAME py_gpio COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
+ set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/python/")
endif()
diff --git a/peripheral/libmraa/tests/platform_checks.py b/peripheral/libmraa/tests/platform_checks.py
index 0ffec4d..fffa7fa 100755
--- a/peripheral/libmraa/tests/platform_checks.py
+++ b/peripheral/libmraa/tests/platform_checks.py
@@ -27,7 +27,7 @@ from __future__ import print_function
import mraa as m
import unittest as u
-@u.skipIf(m.getPlatformName() == "Unknown platform", "Not valid platform loaded")
+@u.skipIf(m.init() != m.ERROR_PLATFORM_ALREADY_INITIALISED, "mraa_init() not valid")
class PlatformChecks(u.TestCase):
def test_mraa_check_platform_no_of_pins(self):
pinCount = m.getPinCount()