diff options
author | Constantin Musca <constantin.musca@intel.com> | 2016-02-08 12:26:52 +0200 |
---|---|---|
committer | Constantin Musca <constantin.musca@intel.com> | 2016-02-08 16:01:47 +0200 |
commit | 4412c4d08c53fda2dae942547b61c8f384e1541d (patch) | |
tree | 18571fcdefc887d5ee8940da17502844acd91303 | |
parent | 30688bbe0fe1b07407c033d07ed7e3d49a9fb22c (diff) | |
download | intel-4412c4d08c53fda2dae942547b61c8f384e1541d.tar.gz |
libmraa: sync wih upstream (SHA1: 9202eb1)
URL: https://github.com/intel-iot-devkit/mraa
Branch: master
SHA1: 9202eb172dbb067ab7917339a5e74dc7305027b6
BUG=26065307
Change-Id: I331e66ea17420959c200e5f872000f96221cabb6
Tracked-On: https://jira01.devtools.intel.com/browse/BP-265
Signed-off-by: Constantin Musca <constantin.musca@intel.com>
26 files changed, 362 insertions, 37 deletions
diff --git a/peripheral/libmraa/.travis.yml b/peripheral/libmraa/.travis.yml index 89eb5f7..2d22386 100644 --- a/peripheral/libmraa/.travis.yml +++ b/peripheral/libmraa/.travis.yml @@ -1,8 +1,12 @@ language: cpp -compiler: - - gcc - - clang +env: + - CC=gcc CXX=gcc + - CC=clang CXX=clang++ + - NODE4=true + - NODE5=true + - 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 @@ -10,7 +14,19 @@ install: - sudo ln -s /usr/bin/swig3.0 /usr/bin/swig - sudo update-java-alternatives -s java-8-oracle before_script: + - 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: - - mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include .. && make && 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 + packages: + - clang-3.6 + - g++-4.8 diff --git a/peripheral/libmraa/Android.mk b/peripheral/libmraa/Android.mk index 43bc38d..24ca1d6 100644 --- a/peripheral/libmraa/Android.mk +++ b/peripheral/libmraa/Android.mk @@ -35,7 +35,8 @@ LOCAL_SRC_FILES := \ src/x86/intel_de3815.c \ src/x86/intel_nuc5.c \ src/x86/intel_sofia_3gr.c \ - src/x86/intel_minnow_byt_compatible.c + src/x86/intel_minnow_byt_compatible.c \ + src/x86/intel_cherryhills.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 490d720..8f7c74f 100644 --- a/peripheral/libmraa/CMakeLists.txt +++ b/peripheral/libmraa/CMakeLists.txt @@ -25,10 +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 "v0.9.0-dirty") + set (VERSION "v0.9.1-dirty") endif () 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}") diff --git a/peripheral/libmraa/docs/contributing.md b/peripheral/libmraa/CONTRIBUTING.md index f4bf41a..b623e76 100644 --- a/peripheral/libmraa/docs/contributing.md +++ b/peripheral/libmraa/CONTRIBUTING.md @@ -1,4 +1,4 @@ -Contributing to libmraa {#contributing} +Contributing to libmraa {#contributing} ====================== libmraa is an opensource project and we are actively looking for people to help diff --git a/peripheral/libmraa/Doxyfile.in b/peripheral/libmraa/Doxyfile.in index 9cf9263..e702b8c 100644 --- a/peripheral/libmraa/Doxyfile.in +++ b/peripheral/libmraa/Doxyfile.in @@ -755,7 +755,8 @@ WARN_LOGFILE = INPUT = @CMAKE_CURRENT_SOURCE_DIR@/api/ \ @CMAKE_CURRENT_SOURCE_DIR@/api/mraa/ \ - @CMAKE_CURRENT_SOURCE_DIR@/docs/ + @CMAKE_CURRENT_SOURCE_DIR@/docs/ \ + @CMAKE_CURRENT_SOURCE_DIR@/CONTRIBUTING.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/peripheral/libmraa/Doxyfile.java.in b/peripheral/libmraa/Doxyfile.java.in index a76ead0..db86d33 100644 --- a/peripheral/libmraa/Doxyfile.java.in +++ b/peripheral/libmraa/Doxyfile.java.in @@ -756,6 +756,7 @@ WARN_LOGFILE = INPUT = @CMAKE_CURRENT_SOURCE_DIR@/api/ \ @CMAKE_CURRENT_SOURCE_DIR@/api/mraa/ \ @CMAKE_CURRENT_SOURCE_DIR@/docs/ \ + @CMAKE_CURRENT_SOURCE_DIR@/docs/CONTRIBUTING.md \ @CMAKE_BINARY_DIR@/src/ \ @CMAKE_CURRENT_SOURCE_DIR@/docs/index.java.md \ @CMAKE_CURRENT_SOURCE_DIR@/README.md diff --git a/peripheral/libmraa/api/mraa/common.hpp b/peripheral/libmraa/api/mraa/common.hpp index 832cedb..26f4a60 100644 --- a/peripheral/libmraa/api/mraa/common.hpp +++ b/peripheral/libmraa/api/mraa/common.hpp @@ -240,8 +240,6 @@ hasSubPlatform() return static_cast<bool>(mraa_has_sub_platform()); } - - /** * Check if pin or bus id includes sub platform mask. * @@ -280,4 +278,16 @@ getSubPlatformIndex(int pin_or_bus_id) { return mraa_get_sub_platform_index(pin_or_bus_id); } + +/** + * Get default i2c bus, board must be initialised. + * + * @param optional subplatform identifier + * @return default i2c bus for paltform + */ +inline int +getDefaultI2cBus(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET) +{ + return mraa_get_default_i2c_bus(platform_offset); +} } diff --git a/peripheral/libmraa/api/mraa/gpio.h b/peripheral/libmraa/api/mraa/gpio.h index 2168f50..2287c0c 100644 --- a/peripheral/libmraa/api/mraa/gpio.h +++ b/peripheral/libmraa/api/mraa/gpio.h @@ -155,6 +155,15 @@ mraa_result_t 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); /** + * Read Gpio direction + * + * @param dev The Gpio context + * @param dir The address where to store the Gpio direction + * @return Result of operation + */ +mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir); + +/** * Close the Gpio context * - Will free the memory for the context and unexport the Gpio * diff --git a/peripheral/libmraa/api/mraa/gpio.hpp b/peripheral/libmraa/api/mraa/gpio.hpp index ec9c43a..86ac1ad 100644 --- a/peripheral/libmraa/api/mraa/gpio.hpp +++ b/peripheral/libmraa/api/mraa/gpio.hpp @@ -235,6 +235,23 @@ class Gpio { return (Result )mraa_gpio_dir(m_gpio, (mraa_gpio_dir_t) dir); } + + /** + * Read Gpio direction + * + * @throw std::runtime_error in case of failure + * @return Result of operation + */ + Dir + readDir() + { + mraa_gpio_dir_t dir; + if (mraa_gpio_read_dir(m_gpio, &dir) != MRAA_SUCCESS) { + throw std::runtime_error("Failed to read direction"); + } + return (Dir) dir; + } + /** * Read value from Gpio * diff --git a/peripheral/libmraa/api/mraa/spi.hpp b/peripheral/libmraa/api/mraa/spi.hpp index 19316dc..e5ffb09 100644 --- a/peripheral/libmraa/api/mraa/spi.hpp +++ b/peripheral/libmraa/api/mraa/spi.hpp @@ -70,6 +70,15 @@ class Spi } } + Spi(int bus, int cs) + { + m_spi = mraa_spi_init_raw(bus, cs); + + if (m_spi == NULL) { + throw std::invalid_argument("Error initialising SPI bus"); + } + } + /** * Closes spi bus */ diff --git a/peripheral/libmraa/api/mraa/types.h b/peripheral/libmraa/api/mraa/types.h index 27c489d..9311e60 100644 --- a/peripheral/libmraa/api/mraa/types.h +++ b/peripheral/libmraa/api/mraa/types.h @@ -48,6 +48,7 @@ typedef enum { MRAA_INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */ MRAA_96BOARDS = 9, /**< Linaro 96boards */ MRAA_INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */ + MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */ // USB platform extenders start at 256 MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */ diff --git a/peripheral/libmraa/cmake/modules/FindNodejs.cmake b/peripheral/libmraa/cmake/modules/FindNodejs.cmake index b586024..5030768 100644 --- a/peripheral/libmraa/cmake/modules/FindNodejs.cmake +++ b/peripheral/libmraa/cmake/modules/FindNodejs.cmake @@ -1,4 +1,12 @@ -find_program (NODE_EXECUTABLE NAMES node nodejs + # Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include + macro(add_include_dir dir) + if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include") + set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir}) + endif() +endmacro() + + +find_program (NODEJS_EXECUTABLE NAMES node nodejs HINTS $ENV{NODE_DIR} PATH_SUFFIXES bin @@ -7,26 +15,50 @@ find_program (NODE_EXECUTABLE NAMES node nodejs include (FindPackageHandleStandardArgs) +# If compat-libuv package exists, it must be at start of include path +find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH) +if (UV_ROOT_DIR) + # set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR}) + add_include_dir(${UV_ROOT_DIR}) +endif() + +# Now look for node. Flag an error if not found 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}/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") +endif() -set (NODE_INCLUDE_DIRS - ${NODE_ROOT_DIR}/src - ${NODE_ROOT_DIR}/node - ${NODE_ROOT_DIR}/deps/v8/include - ${NODE_ROOT_DIR}/deps/uv/include -) +# Check that v8.h is in NODEJS_INCLUDE_DIRS +find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS}) +if (NOT V8_ROOT_DIR) + unset(NODEJS_INCLUDE_DIRS) + message(ERROR " - v8.h not found") +endif() + +# Check that uv.h is in NODEJS_INCLUDE_DIRS +find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS}) +if (NOT UV_ROOT_DIR) + unset(NODEJS_INCLUDE_DIRS) + message(ERROR " - uv.h not found") +endif() -find_package_handle_standard_args (Node DEFAULT_MSG - NODE_EXECUTABLE - NODE_INCLUDE_DIRS +find_package_handle_standard_args (Nodejs DEFAULT_MSG + NODEJS_EXECUTABLE + NODEJS_INCLUDE_DIRS ) -if (NODE_EXECUTABLE) - execute_process(COMMAND ${NODE_EXECUTABLE} --version +if (NODEJS_EXECUTABLE) + execute_process(COMMAND ${NODEJS_EXECUTABLE} --version OUTPUT_VARIABLE _VERSION RESULT_VARIABLE _NODE_VERSION_RESULT) - execute_process(COMMAND ${NODE_EXECUTABLE} -e "console.log(process.versions.v8)" + execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)" OUTPUT_VARIABLE _V8_VERSION RESULT_VARIABLE _V8_RESULT) if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT) @@ -53,7 +85,10 @@ if (NODE_EXECUTABLE) set (V8_VERSION_STRING "3.28.72") message ("defaulted to node 0.10.30") endif () - message ("INFO - Node version is " ${NODE_VERSION_STRING} "INFO - Node using v8 " ${V8_VERSION_STRING}) + string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING}) + string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING}) + message ("INFO - Node version is " ${NODE_VERSION_STRING}) + message ("INFO - Node using v8 " ${V8_VERSION_STRING}) + mark_as_advanced (NODEJS_EXECUTABLE) endif () -mark_as_advanced (NODE_EXECUTABLE) diff --git a/peripheral/libmraa/docs/building.md b/peripheral/libmraa/docs/building.md index 208ad37..fbd46b8 100644 --- a/peripheral/libmraa/docs/building.md +++ b/peripheral/libmraa/docs/building.md @@ -12,7 +12,7 @@ what you'll need: * [git](http://git-scm.com) * [python](http://python.org) 2.7 or 3.4+ (you'll need not just the interpreter but python-dev) * [node.js](http://nodejs.org) 0.10.x or 0.12.x (you'll need not just the interpreter but nodejs-dev) -* [CMake](http://cmake.org) 2.8.8+ +* [CMake](http://cmake.org) 2.8.8+ (3.1+ is recommended for node.js version 2+) For Debian-like distros the below command installs the basic set: diff --git a/peripheral/libmraa/docs/changelog.md b/peripheral/libmraa/docs/changelog.md index 77e2601..8ee325a 100644 --- a/peripheral/libmraa/docs/changelog.md +++ b/peripheral/libmraa/docs/changelog.md @@ -5,6 +5,15 @@ 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. +**0.9.1** + * Minnowboard Turbot support + * Change to java runables for ISR support + * New platform version call + * Default i2c bus on edison miniboard is now i2c-1 + * More compatibility with node.js versions > 0.10 + * New C++ get i2c default bus call + * Various bug fixes & optimisations + **0.9.0** * Beta iio API in C & C++ (no SWIG support) * Added 96Board support diff --git a/peripheral/libmraa/include/x86/intel_cherryhills.h b/peripheral/libmraa/include/x86/intel_cherryhills.h new file mode 100644 index 0000000..09bddcf --- /dev/null +++ b/peripheral/libmraa/include/x86/intel_cherryhills.h @@ -0,0 +1,41 @@ +/* + * Author: Karena Anum Kamaruzaman <karena.anum.kamaruzaman@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" +#define MRAA_INTEL_CHERRYHILLS_PINCOUNT (5 + 1) + +mraa_board_t* +mraa_intel_cherryhills(); + +#ifdef __cplusplus +} +#endif diff --git a/peripheral/libmraa/src/CMakeLists.txt b/peripheral/libmraa/src/CMakeLists.txt index 199c045..14410a6 100644 --- a/peripheral/libmraa/src/CMakeLists.txt +++ b/peripheral/libmraa/src/CMakeLists.txt @@ -28,6 +28,7 @@ set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/intel_nuc5.c ${PROJECT_SOURCE_DIR}/src/x86/intel_minnow_byt_compatible.c ${PROJECT_SOURCE_DIR}/src/x86/intel_sofia_3gr.c + ${PROJECT_SOURCE_DIR}/src/x86/intel_cherryhills.c ) message (INFO " - Adding support for platform ${MRAAPLATFORMFORCE}") @@ -49,6 +50,8 @@ if (NOT ${MRAAPLATFORMFORCE} STREQUAL "ALL") set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_nuc5.c) elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_SOFIA_3GR") set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_sofia_3gr.c) + elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_CHERRYHILLS") + set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_cherryhills.c) else () message (ERROR " - Unknown x86 platform enabled!") endif () @@ -130,7 +133,6 @@ macro (mraa_CREATE_INSTALL_PKGCONFIG generated_file install_location) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location}) endmacro (mraa_CREATE_INSTALL_PKGCONFIG) mraa_create_install_pkgconfig (mraa.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -mraa_create_install_pkgconfig (mraajava.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/peripheral/libmraa/src/gpio/gpio.c b/peripheral/libmraa/src/gpio/gpio.c index b1a757c..f67f1ab 100644 --- a/peripheral/libmraa/src/gpio/gpio.c +++ b/peripheral/libmraa/src/gpio/gpio.c @@ -654,6 +654,38 @@ mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir) return MRAA_SUCCESS; } +mraa_result_t +mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir) +{ + char value[5]; + char filepath[MAX_SIZE]; + int fd, rc; + mraa_result_t result = MRAA_SUCCESS; + + snprintf(filepath, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/direction", dev->pin); + fd = open(filepath, O_RDONLY); + if (fd == -1) { + return MRAA_ERROR_INVALID_RESOURCE; + } + + memset(value, '\0', sizeof(value)); + rc = read(fd, value, sizeof(value)); + close(fd); + if (rc <= 0) { + return MRAA_ERROR_INVALID_RESOURCE; + } + + if (strcmp(value, "out\n") == 0) { + *dir = MRAA_GPIO_OUT; + } else if (strcmp(value, "in\n") == 0) { + *dir = MRAA_GPIO_IN; + } else { + result = MRAA_ERROR_INVALID_RESOURCE; + } + + return result; +} + int mraa_gpio_read(mraa_gpio_context dev) { diff --git a/peripheral/libmraa/src/java/CMakeLists.txt b/peripheral/libmraa/src/java/CMakeLists.txt index c8b0056..1df9cb1 100644 --- a/peripheral/libmraa/src/java/CMakeLists.txt +++ b/peripheral/libmraa/src/java/CMakeLists.txt @@ -41,12 +41,12 @@ if (DOXYGEN_FOUND) endforeach () endif () +mraa_create_install_pkgconfig (mraajava.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libmraajava.so + ${CMAKE_CURRENT_BINARY_DIR}/mraa.jar DESTINATION lib/java ) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/../libmraajava.so DESTINATION lib/ ) -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.jar - DESTINATION lib/java -) diff --git a/peripheral/libmraa/src/mraajava.pc.cmake b/peripheral/libmraa/src/java/mraajava.pc.cmake index e234153..e234153 100644 --- a/peripheral/libmraa/src/mraajava.pc.cmake +++ b/peripheral/libmraa/src/java/mraajava.pc.cmake diff --git a/peripheral/libmraa/src/javascript/CMakeLists.txt b/peripheral/libmraa/src/javascript/CMakeLists.txt index adfc82c..7885dad 100644 --- a/peripheral/libmraa/src/javascript/CMakeLists.txt +++ b/peripheral/libmraa/src/javascript/CMakeLists.txt @@ -1,7 +1,7 @@ -find_package (Nodejs) +find_package (Nodejs REQUIRED) include_directories ( - ${NODE_INCLUDE_DIRS} + ${NODEJS_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/.. ) @@ -22,21 +22,37 @@ set_property (SOURCE mraajs.i PROPERTY SWIG_FLAGS "-node" set_source_files_properties (mraajs.i PROPERTIES CPLUSPLUS ON) swig_add_module (mraajs javascript mraajs.i ${mraa_LIB_SRCS}) -swig_link_libraries (mraajs ${NODE_LIBRARIES} ${mraa_LIBS}) +swig_link_libraries (mraajs ${mraa_LIBS}) set_target_properties (mraajs PROPERTIES - COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -DBUILDING_NODE_EXTENSION -DSWIGJAVASCRIPT=${SWIG_FOUND}" + COMPILE_FLAGS " -DBUILDING_NODE_EXTENSION -DSWIGJAVASCRIPT=${SWIG_FOUND}" PREFIX "" OUTPUT_NAME mraa SUFFIX ".node" ) +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 (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(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 () macro (mraa_CREATE_INSTALL_PACKAGE_JSON generated_file install_location) diff --git a/peripheral/libmraa/src/mraa.i b/peripheral/libmraa/src/mraa.i index 7a2d03e..5259951 100644 --- a/peripheral/libmraa/src/mraa.i +++ b/peripheral/libmraa/src/mraa.i @@ -46,7 +46,7 @@ %ignore Gpio::v8isr(uv_work_t* req); %ignore Gpio::v8isr(uv_work_t* req, int status); %ignore Gpio::uvwork(void *ctx); -%ignore Gpio::isr(Edge mode, void (*fptr)(void*), void* args); +%ignore isr(Edge mode, void (*fptr)(void*), void* args); %include "gpio.hpp" diff --git a/peripheral/libmraa/src/pwm/pwm.c b/peripheral/libmraa/src/pwm/pwm.c index ae7685e..f8decce 100644 --- a/peripheral/libmraa/src/pwm/pwm.c +++ b/peripheral/libmraa/src/pwm/pwm.c @@ -186,6 +186,10 @@ mraa_pwm_init(int pin) syslog(LOG_NOTICE, "pwm: Using sub platform is not supported"); return NULL; } + if (pin < 0 || pin > plat->phy_pin_count) { + syslog(LOG_ERR, "pwm: pin %i beyond platform definition", pin); + return NULL; + } if (plat->pins[pin].capabilites.pwm != 1) { syslog(LOG_ERR, "pwm: pin not capable of pwm"); return NULL; diff --git a/peripheral/libmraa/src/uart/uart.c b/peripheral/libmraa/src/uart/uart.c index 6d3973a..0f8a2e3 100644 --- a/peripheral/libmraa/src/uart/uart.c +++ b/peripheral/libmraa/src/uart/uart.c @@ -29,10 +29,15 @@ #include <unistd.h> #include <string.h> #include <termios.h> +#include <sys/select.h> #include "uart.h" #include "mraa_internal.h" +#ifndef CMSPAR +#define CMSPAR 010000000000 +#endif + // This function takes an unsigned int and converts it to a B* speed_t // that can be used with linux/posix termios static speed_t diff --git a/peripheral/libmraa/src/x86/intel_cherryhills.c b/peripheral/libmraa/src/x86/intel_cherryhills.c new file mode 100644 index 0000000..b797c94 --- /dev/null +++ b/peripheral/libmraa/src/x86/intel_cherryhills.c @@ -0,0 +1,99 @@ +/* + * Author: Karena Anum Kamaruzaman <karena.anum.kamaruzaman@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_cherryhills.h" + +#define PLATFORM_NAME "Braswell Cherry Hill" + +mraa_board_t* +mraa_intel_cherryhills() +{ + 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_CHERRYHILLS_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_CHERRYHILLS_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; + } + + int pos = 0; + //Physical header where these pins are: J3E5 + strncpy(b->pins[pos].name, "GSUS6", 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++; + + strncpy(b->pins[pos].name, "GSUS8", 8); + b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; + b->pins[pos].gpio.pinmap = 409; + b->pins[pos].gpio.mux_total = 0; + pos++; + + strncpy(b->pins[pos].name, "GSUS7", 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++; + + //Physical header where these pins are: J3E3 + strncpy(b->pins[pos].name, "GSUS0", 8); + b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; + b->pins[pos].gpio.pinmap = 406; + b->pins[pos].gpio.mux_total = 0; + pos++; + + strncpy(b->pins[pos].name, "GSUS1", 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++; + + return b; +error: + syslog(LOG_CRIT, "Cherryhills(Braswell): Platform failed to initialise"); + free(b); + return NULL; +} diff --git a/peripheral/libmraa/src/x86/intel_edison_fab_c.c b/peripheral/libmraa/src/x86/intel_edison_fab_c.c index 27ce531..b8738f2 100644 --- a/peripheral/libmraa/src/x86/intel_edison_fab_c.c +++ b/peripheral/libmraa/src/x86/intel_edison_fab_c.c @@ -425,6 +425,9 @@ mraa_intel_edison_spi_init_pre(int bus) mraa_intel_edison_pinmode_change(109, 1); return MRAA_SUCCESS; } + + mraa_intel_edison_misc_spi(); + mraa_gpio_write(tristate, 0); mraa_gpio_context io10_out = mraa_gpio_init_raw(258); @@ -1154,6 +1157,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b) mraa_board_t* mraa_intel_edison_fab_c() { + mraa_gpio_dir_t tristate_dir; mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t)); if (b == NULL) { return NULL; @@ -1205,8 +1209,14 @@ mraa_intel_edison_fab_c() goto error; } - mraa_gpio_dir(tristate, MRAA_GPIO_OUT); - mraa_intel_edison_misc_spi(); + if (mraa_gpio_read_dir(tristate, &tristate_dir) != MRAA_SUCCESS) { + free(b->adv_func); + goto error; + } + + if (tristate_dir != MRAA_GPIO_OUT) { + mraa_gpio_dir(tristate, MRAA_GPIO_OUT); + } b->adc_raw = 12; b->adc_supported = 10; diff --git a/peripheral/libmraa/src/x86/x86.c b/peripheral/libmraa/src/x86/x86.c index 57c4daf..50cf210 100644 --- a/peripheral/libmraa/src/x86/x86.c +++ b/peripheral/libmraa/src/x86/x86.c @@ -35,6 +35,7 @@ #include "x86/intel_nuc5.h" #include "x86/intel_minnow_byt_compatible.h" #include "x86/intel_sofia_3gr.h" +#include "x86/intel_cherryhills.h" mraa_platform_t mraa_x86_platform() @@ -78,6 +79,9 @@ mraa_x86_platform() } else if (strncasecmp(line, "MinnowBoard Turbot", 18) == 0) { platform_type = MRAA_INTEL_MINNOWBOARD_MAX; plat = mraa_intel_minnowboard_byt_compatible(1); + } else if (strncasecmp(line, "Braswell Cherry Hill", 20) == 0) { + platform_type = MRAA_INTEL_CHERRYHILLS; + plat = mraa_intel_cherryhills(); } else { syslog(LOG_ERR, "Platform not supported, not initialising"); platform_type = MRAA_UNKNOWN_PLATFORM; @@ -114,6 +118,8 @@ mraa_x86_platform() plat = mraa_intel_nuc5(); #elif defined(xMRAA_INTEL_SOFIA_3GR) plat = mraa_intel_sofia_3gr(); + #elif defined(xMRAA_INTEL_CHERRYHILLS) + plat = mraa_intel_cherryhills(); #else #error "Not using a valid platform value from mraa_platform_t - cannot compile" #endif |