Compare commits
226 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e9af63d9db | ||
|
ef79bc3786 | ||
|
e52d52ac66 | ||
|
49aa09f0db | ||
|
ab91db2b17 | ||
|
b75605479b | ||
|
e66c8568b4 | ||
|
eb8225e5a9 | ||
|
000746c20d | ||
|
4109b8b454 | ||
|
c36e4add5a | ||
|
32340f6819 | ||
|
bb3584fcdb | ||
|
ff03b2de1d | ||
|
79da382832 | ||
|
131ff46a0d | ||
|
f927bffb16 | ||
|
8133de0cc0 | ||
|
ecb53c8501 | ||
|
1d37d3b162 | ||
|
722b83b95c | ||
|
822160b7de | ||
|
98e755d147 | ||
|
2980e211db | ||
|
69f7d09103 | ||
|
56d5666ae9 | ||
|
a6f2464bb1 | ||
|
d6edf76680 | ||
|
b7e8d96945 | ||
|
04c5593cef | ||
|
818ae995c2 | ||
|
47c21e0b6c | ||
|
816be65ba0 | ||
|
b73fdff00d | ||
|
398b851144 | ||
|
5ef3f3ea29 | ||
|
9479843cde | ||
|
dc1255ad75 | ||
|
9545a2e320 | ||
|
0654183b9a | ||
|
918e2b18e2 | ||
|
e7b0a3e809 | ||
|
8ddbcde84e | ||
|
a0332b14b5 | ||
|
def0a6aed1 | ||
|
9d65d6e0f0 | ||
|
4b08887c54 | ||
|
e0a0dac47b | ||
|
6d5b2c0642 | ||
|
075a7b1225 | ||
|
43d9f6c400 | ||
|
1379c1fe33 | ||
|
80335b18b6 | ||
|
be2bd63223 | ||
|
35e17ee25a | ||
|
ef2fddc1e1 | ||
|
ce0edf0f62 | ||
|
038a7c542a | ||
|
aeb293a163 | ||
|
87fda62759 | ||
|
3e19a58710 | ||
|
380d2cf638 | ||
|
1d200840f4 | ||
|
34b4d4a97b | ||
|
913eaf2440 | ||
|
7bc069a8fd | ||
|
beaba463f7 | ||
|
567a92fde5 | ||
|
4270e7a743 | ||
|
a2ee056c7d | ||
|
e607beedda | ||
|
c4555bc4e5 | ||
|
1cec6705d1 | ||
|
9a306fc1f5 | ||
|
8a1c58bc7f | ||
|
76850eb0f4 | ||
|
0ec90a3138 | ||
|
60ca81a3e1 | ||
|
533517a864 | ||
|
69fcd861a7 | ||
|
4c7616fe91 | ||
|
d7fb6c5af9 | ||
|
9cb0440955 | ||
|
2f51627d18 | ||
|
05d4a917e5 | ||
|
0d6700fe50 | ||
|
791fe0c05a | ||
|
ecc64da418 | ||
|
6d004ca80d | ||
|
f911e0620e | ||
|
bf548a3377 | ||
|
cac8f7a47a | ||
|
65f7d2a250 | ||
|
b937c521f6 | ||
|
48fe5cebbb | ||
|
d2bbfe376d | ||
|
a3f5db1d84 | ||
|
2a1590fdf1 | ||
|
5e34a5cd3b | ||
|
6f4b333a31 | ||
|
dd19634889 | ||
|
21e0ff7c02 | ||
|
b24e90db0c | ||
|
1c4b1fc329 | ||
|
f6f124a35f | ||
|
c7a4a6db34 | ||
|
0004dfeefb | ||
|
0470aebee6 | ||
|
23fd11c4f7 | ||
|
875289ab94 | ||
|
c69b6312fa | ||
|
b20fe9163a | ||
|
b453f6633b | ||
|
06359e39cd | ||
|
68c6a8df49 | ||
|
03fb882ce2 | ||
|
ff2eba732e | ||
|
694e6eab23 | ||
|
4264aa5a3b | ||
|
0092e13f57 | ||
|
2c529689ed | ||
|
fc03ea4816 | ||
|
caabca37be | ||
|
2ea68105f0 | ||
|
6fabccf131 | ||
|
19d69b71da | ||
|
e606d1d615 | ||
|
4472ff1629 | ||
|
72261d61bd | ||
|
e38630097e | ||
|
c3332f5542 | ||
|
3bd590c18c | ||
|
17b147ba82 | ||
|
4b22a923cf | ||
|
af051d820a | ||
|
2558866d4a | ||
|
c1017bb6ea | ||
|
1c180e393c | ||
|
250590e1ed | ||
|
68e9399c4c | ||
|
ad6eb53f81 | ||
|
d2f1b068b7 | ||
|
a0332a13b0 | ||
|
a63ad7e10d | ||
|
9de294b389 | ||
|
61d20c7266 | ||
|
d043faf687 | ||
|
6f9b470d8d | ||
|
92188ab950 | ||
|
3d790a8278 | ||
|
dbcba5cbeb | ||
|
ef8102deb1 | ||
|
7b7b11415b | ||
|
5a3f73731c | ||
|
e466d1f890 | ||
|
ae127b19a5 | ||
|
fe76260837 | ||
|
bf4d14ef02 | ||
|
d602196bd6 | ||
|
e387946208 | ||
|
fa35855bb6 | ||
|
4a33aca8fd | ||
|
9d365ce0d6 | ||
|
23e871c5bb | ||
|
3bb17bb7b9 | ||
|
8218e42d41 | ||
|
3971d27f8a | ||
|
c69d1884c9 | ||
|
cada819c39 | ||
|
0b5130335d | ||
|
b4cf93f1f8 | ||
|
c7ff9a5173 | ||
|
c993cf10b4 | ||
|
623fef670e | ||
|
bb5ec8bd10 | ||
|
a3c717553c | ||
|
6ce1b1c4ce | ||
|
9f03afbcbc | ||
|
8a9efd1bcc | ||
|
1b3a9371a1 | ||
|
ccc4185eff | ||
|
6fda865af7 | ||
|
dd33a32744 | ||
|
7d1ee0c6fe | ||
|
19791be2f5 | ||
|
49ef1623b2 | ||
|
37deb5003b | ||
|
980dfce80e | ||
|
08e270818a | ||
|
6bac8594a5 | ||
|
11bbd05533 | ||
|
1d4b19dc4b | ||
|
02a7fbf191 | ||
|
ae15b10997 | ||
|
be22844922 | ||
|
92fdb8aa01 | ||
|
def454e33c | ||
|
122cab1f1e | ||
|
6c85b61daa | ||
|
139d42d084 | ||
|
8e38c762f0 | ||
|
590f733ff9 | ||
|
045ceb084f | ||
|
ff3b3004da | ||
|
5cb2bd220e | ||
|
8ec4fcb333 | ||
|
bf2a504774 | ||
|
9bc91f4b12 | ||
|
6180ddaa8e | ||
|
8a93351f0e | ||
|
1591b92605 | ||
|
22b0f63238 | ||
|
2832909856 | ||
|
636c9feb4f | ||
|
0292c960b3 | ||
|
9ff47aa64a | ||
|
a704a956ea | ||
|
94b7477212 | ||
|
1589389c3f | ||
|
bdbbfd03dd | ||
|
9030ae2eeb | ||
|
3a638caf01 | ||
|
07f6181c91 | ||
|
0630c5f505 | ||
|
4277a3ee23 | ||
|
c976e9f982 |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Dockerfile
|
||||
docker-compose.yaml
|
103
.travis.yml
103
.travis.yml
@@ -1,55 +1,62 @@
|
||||
language: cpp
|
||||
sudo: required
|
||||
dist: trusty
|
||||
env:
|
||||
- NODE010=true
|
||||
- NODE012=true
|
||||
- NODE4=true
|
||||
- NODE5=true
|
||||
- JSONPLAT=true NODE010=true
|
||||
- JSONPLAT=true NODE012=true
|
||||
- JSONPLAT=true NODE4=true
|
||||
- JSONPLAT=true NODE5=true
|
||||
# node010 npm builds don't work in clang and anyone using npm should want to
|
||||
# use something newer
|
||||
- NPM=true NODE4=true
|
||||
- NPM=true NODE5=true
|
||||
|
||||
language: cpp
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
env:
|
||||
- TARGET=doc
|
||||
- TARGET=python2
|
||||
- TARGET=python3
|
||||
- TARGET=java
|
||||
- TARGET=node4
|
||||
- TARGET=node5
|
||||
- TARGET=python2 JSONPLAT=ON
|
||||
- TARGET=python3 JSONPLAT=ON
|
||||
- TARGET=java JSONPLAT=ON
|
||||
- TARGET=node4 JSONPLAT=ON
|
||||
- TARGET=node5 JSONPLAT=ON
|
||||
- TARGET=python2 BUILDARCH=MOCK
|
||||
- TARGET=python3 BUILDARCH=MOCK
|
||||
- TARGET=java BUILDARCH=MOCK
|
||||
- TARGET=node4 BUILDARCH=MOCK
|
||||
- TARGET=node5 BUILDARCH=MOCK
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- compiler: clang
|
||||
env: TARGET=java
|
||||
- compiler: clang
|
||||
env: TARGET=java JSONPLAT=ON
|
||||
- compiler: clang
|
||||
env: TARGET=java BUILDARCH=MOCK
|
||||
allow_failures:
|
||||
- compiler: gcc
|
||||
env: TARGET=node4 JSONPLAT=ON
|
||||
- compiler: clang
|
||||
env: TARGET=node4 JSONPLAT=ON
|
||||
- compiler: gcc
|
||||
env: TARGET=node5 JSONPLAT=ON
|
||||
- compiler: clang
|
||||
env: TARGET=node5 JSONPLAT=ON
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
# Via https://github.com/travis-ci/travis-ci/issues/5326
|
||||
- export PATH="$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")"
|
||||
install:
|
||||
- if [ "${NODE4}" ]; then export CC=gcc-4.8 CXX=g++-4.8; fi
|
||||
- sudo rm /usr/local/bin/docker-compose
|
||||
- curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
|
||||
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 [ "${JSONPLAT}" ]; then export JSONPLAT=ON; else export JSONPLAT=OFF; fi
|
||||
- if [ "${NODE010}" ]; then nvm install 0.10; fi
|
||||
- if [ "${NODE012}" ]; then nvm install 0.12; fi
|
||||
- if [ "${NODE4}" ]; then nvm install 4.1; fi
|
||||
- if [ "${NODE5}" ]; then nvm install 5; fi
|
||||
- npm install node-gyp && export NODE_GYP="/home/travis/build/intel-iot-devkit/mraa/node_modules/node-gyp/bin/node-gyp.js"
|
||||
# Handle 0.10 NODE_ROOT_DIR differently than other versions
|
||||
- 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 ..
|
||||
- if [ "$CC" == "gcc" ]; then export CC=gcc-4.8; fi
|
||||
- if [ "$CXX" == "g++" ]; then export CXX=g++-4.8; fi
|
||||
- if [ "$CC" == "clang" ]; then export CC=clang-3.8; fi
|
||||
- if [ "$CXX" == "clang++" ]; then export CXX=clang++-3.8; fi
|
||||
- docker-compose build ${TARGET}
|
||||
|
||||
script:
|
||||
- echo "CC=$CC BUILDJAVA=$BUILDJAVA JSONPLAT=$JSONPLAT NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
|
||||
- if [ -z ${NPM} ]; then mkdir build && cd build && cmake -DBUILDSWIGJAVA="$BUILDJAVA" -DJSONPLAT=$JSONPLAT -DNODE_ROOT_DIR:PATH="${NVM_BIN}/.." -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; else mkdir build && cd build && cmake -DBUILDSWIGJAVA="$BUILDJAVA" -DJSONPLAT=$JSONPLAT -DNODE_ROOT_DIR:PATH="${NVM_BIN}/.." -DCMAKE_INSTALL_PREFIX:PATH=../install -DSWIG_EXECUTABLE=/home/travis/bin/swig -DSWIG_DIR:PATH=/home/travis/share/swig/3.0.10/ .. && make npmpkg && cd .. && ${NODE_GYP} configure && ${NODE_GYP} build; fi
|
||||
# simple test to see if we can load our node module
|
||||
- if [ ${NPM} ]; then cd build/Release/obj.target/ && node -e "var m = require('./mraa.node'); m.getVersion()";fi
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- kalakris-cmake
|
||||
packages:
|
||||
- g++-4.8
|
||||
- cmake
|
||||
- python
|
||||
- python-dev
|
||||
- python3
|
||||
- python3-dev
|
||||
- git
|
||||
- libjson0
|
||||
- libjson0-dev
|
||||
- docker-compose run ${TARGET}
|
||||
|
62
Android.mk
62
Android.mk
@@ -1,62 +0,0 @@
|
||||
# Copyright (C) 2015 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libmraa
|
||||
LOCAL_CFLAGS += -Wno-unused-parameter -DX86PLAT=1
|
||||
LOCAL_SHARED_LIBRARIES := libcutils libutils libdl libc
|
||||
LOCAL_SRC_FILES := \
|
||||
src/mraa.c \
|
||||
src/gpio/gpio.c \
|
||||
src/i2c/i2c.c \
|
||||
src/pwm/pwm.c \
|
||||
src/spi/spi.c \
|
||||
src/aio/aio.c \
|
||||
src/uart/uart.c \
|
||||
src/x86/x86.c \
|
||||
src/iio/iio.c \
|
||||
src/x86/intel_galileo_rev_d.c \
|
||||
src/x86/intel_galileo_rev_g.c \
|
||||
src/x86/intel_edison_fab_c.c \
|
||||
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_cherryhills.c \
|
||||
src/x86/up.c \
|
||||
src/x86/intel_gt_tuchuck.c
|
||||
|
||||
# glob.c pulled in from NetBSD project (BSD 3-clause License)
|
||||
LOCAL_SRC_FILES += \
|
||||
src/glob/glob.c
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/include \
|
||||
$(LOCAL_PATH)/include/linux \
|
||||
$(LOCAL_PATH)/include/x86 \
|
||||
$(LOCAL_PATH)/api \
|
||||
$(LOCAL_PATH)/api/mraa \
|
||||
$(LOCAL_PATH)/src/glob
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := \
|
||||
$(LOCAL_PATH)/api \
|
||||
$(LOCAL_PATH)/api/mraa
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@@ -1,10 +1,70 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
project (mraa C)
|
||||
project (mraa C CXX)
|
||||
|
||||
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 ")
|
||||
###############################################################################
|
||||
# Detect supported warning flags
|
||||
# Modified from work By Dan Liew (fpbench - MIT)
|
||||
# https://github.com/delcypher/fp-bench/blob/master/CMakeLists.txt
|
||||
###############################################################################
|
||||
# Warnings for both the C and C++ compiler
|
||||
|
||||
set (MRAA_BOTH_WARNING_FLAGS
|
||||
-Wall
|
||||
-Werror=main
|
||||
-Wformat
|
||||
-Wmain
|
||||
-Wuninitialized
|
||||
-Winit-self
|
||||
)
|
||||
|
||||
# Warning flags for the C compiler only
|
||||
set (MRAA_C_WARNING_FLAGS
|
||||
-Werror=implicit
|
||||
-Werror=missing-parameter-type
|
||||
)
|
||||
|
||||
# Warning flags for the C++ compiler only
|
||||
set (MRAA_CXX_WARNING_FLAGS
|
||||
-Wnon-virtual-dtor
|
||||
-Woverloaded-virtual
|
||||
-Wreorder
|
||||
)
|
||||
|
||||
include (CheckCCompilerFlag)
|
||||
include (CheckCXXCompilerFlag)
|
||||
function (MRAA_SANITIZE_FLAG_NAME OUTPUT_VAR FLAG)
|
||||
string (REPLACE "-" "_" SANITIZED_FLAG_NAME "${FLAG}")
|
||||
string (REPLACE "/" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
||||
string (REPLACE "=" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
||||
string (REPLACE " " "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
|
||||
set (${OUTPUT_VAR} "${SANITIZED_FLAG_NAME}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Globally set C compiler warning flags that are supported and emit
|
||||
# a warning about unsupported flags
|
||||
foreach (flag ${MRAA_BOTH_WARNING_FLAGS} ${MRAA_C_WARNING_FLAGS})
|
||||
MRAA_SANITIZE_FLAG_NAME(SANITIZED_FLAG_NAME "${flag}")
|
||||
CHECK_C_COMPILER_FLAG("${flag}" HAS_C_${SANITIZED_FLAG_NAME})
|
||||
if (HAS_C_${SANITIZED_FLAG_NAME})
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
||||
else ()
|
||||
message (WARNING "C compiler does not support flag \"${flag}\"")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Globally set C++ compiler warning flags that are supported and emit
|
||||
# a warning about unsupported flags
|
||||
foreach (flag ${MRAA_BOTH_WARNING_FLAGS} ${MRAA_CXX_WARNING_FLAGS})
|
||||
MRAA_SANITIZE_FLAG_NAME (SANITIZED_FLAG_NAME "${flag}")
|
||||
CHECK_CXX_COMPILER_FLAG ("${flag}" HAS_CXX_${SANITIZED_FLAG_NAME})
|
||||
if (HAS_CXX_${SANITIZED_FLAG_NAME})
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
else ()
|
||||
message (WARNING "C++ compiler does not support flag \"${flag}\"")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Set CMAKE_INSTALL_LIBDIR if not defined
|
||||
include(GNUInstallDirs)
|
||||
@@ -31,7 +91,7 @@ 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.2.3-dirty")
|
||||
set (VERSION "v1.7.0")
|
||||
endif ()
|
||||
|
||||
message (STATUS "INFO - libmraa Version ${VERSION}")
|
||||
@@ -78,8 +138,9 @@ option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
option (ENABLEEXAMPLES "Disable building of examples" ON)
|
||||
option (INSTALLGPIOTOOL "Install gpio tool" OFF)
|
||||
option (INSTALLTOOLS "Install all tools" OFF)
|
||||
option (INSTALLTOOLS "Install all tools" ON)
|
||||
option (BUILDTESTS "Override the addition of tests" ON)
|
||||
option (USEPYTHON3TESTS "Force tests to run with python3" OFF)
|
||||
|
||||
set (BUILDARCH "" CACHE STRING "Override architecture to build for")
|
||||
|
||||
@@ -107,8 +168,10 @@ elseif (DETECTED_ARCH MATCHES "arm.*")
|
||||
set (ARMPLAT ON)
|
||||
elseif (DETECTED_ARCH STREQUAL "MOCK")
|
||||
set (MOCKPLAT ON)
|
||||
elseif (DETECTED_ARCH STREQUAL "PERIPHERALMAN")
|
||||
set (PERIPHERALMAN ON)
|
||||
else ()
|
||||
message (FATAL_ERROR "Only x86, arm and mock platforms currently supported")
|
||||
message (FATAL_ERROR "Only x86, arm, PERIPHERALMAN and mock platforms currently supported")
|
||||
endif()
|
||||
|
||||
if (BUILDSWIGPYTHON OR BUILDTESTS)
|
||||
|
@@ -10,7 +10,8 @@ with:
|
||||
|
||||
The recommended method to contribute is to fork on github, and then send pull
|
||||
requests to the main project. You can open issues if you find any bugs/have
|
||||
questions.
|
||||
questions. If you want to work on a large feature then we suggest you file an
|
||||
issue first so we can avoid dissapointments come merging time!
|
||||
|
||||
If you'd rather not use github you are more than welcome to send git formatted
|
||||
patches to our mailing list mraa@lists.01.org which you can register for access
|
||||
@@ -42,6 +43,16 @@ job. Few exceptions to coding styles:
|
||||
|
||||
Use common sense and don't be afraid to challenge something if it doesn't make sense!
|
||||
|
||||
Author Rules
|
||||
------------
|
||||
|
||||
If you create a file, then add yourself as the Author at the top. If you did a
|
||||
large contribution to it (or if you want to ;-)), then fee free to add yourself
|
||||
to the contributors list in that file. You can also add your own copyright
|
||||
statement to the file but cannot add a license of your own. If you're borrowing
|
||||
code that comes from a project with another license, make sure to explicitly
|
||||
note this in your PR.
|
||||
|
||||
Code signing
|
||||
------------
|
||||
|
||||
|
102
Dockerfile
Normal file
102
Dockerfile
Normal file
@@ -0,0 +1,102 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# Update apt-get
|
||||
RUN apt-get -y update && \
|
||||
# Install apt-utils
|
||||
apt-get -y --no-install-recommends install apt-utils && \
|
||||
# Main Build Dependencies
|
||||
apt-get -y --no-install-recommends install git build-essential cmake clang-3.8 g++-4.8 wget libpcre3 libpcre3-dev \
|
||||
# Docs Build Dependencies
|
||||
python-sphinx doxygen graphviz \
|
||||
# Python Build Dependencies
|
||||
python python-dev python3 python3-dev \
|
||||
# Java Build Dependencies
|
||||
default-jre default-jdk \
|
||||
# Json Platform Build Dependencies
|
||||
pkg-config libjson0 libjson0-dev
|
||||
|
||||
# Swig Build Dependencies
|
||||
RUN wget http://iotdk.intel.com/misc/tr/swig-3.0.10.tar.gz && \
|
||||
tar xf swig-3.0.10.tar.gz && cd swig-3.0.10 && \
|
||||
./configure --prefix=/usr/ && make && make install && cd ..
|
||||
|
||||
# Node.js Build Dependencies
|
||||
RUN wget -q -O - https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
|
||||
|
||||
# Set Workdir
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Configure Build Arguments
|
||||
ARG BUILDARCH
|
||||
ARG BUILDDOC
|
||||
ARG BUILDSWIG
|
||||
ARG BUILDSWIGPYTHON
|
||||
ARG BUILDSWIGNODE
|
||||
ARG BUILDSWIGJAVA
|
||||
ARG USBPLAT=OFF
|
||||
ARG FIRMATA=OFF
|
||||
ARG ONEWIRE=OFF
|
||||
ARG JSONPLAT
|
||||
ARG IMRAA=OFF
|
||||
ARG FTDI4222=OFF
|
||||
ARG IPK=OFF
|
||||
ARG RPM=OFF
|
||||
ARG ENABLEEXAMPLES
|
||||
ARG INSTALLGPIOTOOL=OFF
|
||||
ARG INSTALLTOOLS=OFF
|
||||
ARG BUILDTESTS
|
||||
ARG CC
|
||||
ARG CXX
|
||||
ARG NODE_VERSION
|
||||
ARG USEPYTHON3TESTS
|
||||
|
||||
# Configure Build Environment
|
||||
ENV NVM_DIR /root/.nvm
|
||||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
|
||||
ENV CC $CC
|
||||
ENV CXX $CXX
|
||||
RUN . $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use $NODE_VERSION && \
|
||||
npm install -g node-gyp && node-gyp install
|
||||
|
||||
# Copy sources
|
||||
COPY . .
|
||||
|
||||
# Update Submodule
|
||||
RUN git submodule update --init --recursive
|
||||
|
||||
# Fix line ending issue in src/doxy2swig.py and do it executable
|
||||
RUN tr -d "\r" < src/doxy2swig.py > src/_doxy2swig.py && \
|
||||
mv src/_doxy2swig.py src/doxy2swig.py && \
|
||||
chmod u+x src/doxy2swig.py
|
||||
|
||||
# Change Workdir to build directory
|
||||
WORKDIR /usr/src/app/build
|
||||
|
||||
# Run cmake
|
||||
RUN . $NVM_DIR/nvm.sh && cmake \
|
||||
-DSWIG_EXECUTABLE=/usr/bin/swig \
|
||||
-DSWIG_DIR:PATH=/usr/share/swig/3.0.10/ \
|
||||
-DBUILDARCH=$BUILDARCH \
|
||||
-DBUILDDOC=$BUILDDOC \
|
||||
-DBUILDSWIG=$BUILDSWIG \
|
||||
-DBUILDSWIGPYTHON=$BUILDSWIGPYTHON \
|
||||
-DBUILDSWIGNODE=$BUILDSWIGNODE \
|
||||
-DBUILDSWIGJAVA=$BUILDSWIGJAVA \
|
||||
-DUSBPLAT=$USBPLAT \
|
||||
-DFIRMATA=$FIRMATA \
|
||||
-DONEWIRE=$ONEWIRE \
|
||||
-DJSONPLAT=$JSONPLAT \
|
||||
-DIMRAA=$IMRAA \
|
||||
-DFTDI4222=$FTDI4222 \
|
||||
-DIPK=$IPK \
|
||||
-DRPM=$RPM \
|
||||
-DENABLEEXAMPLES=$ENABLEEXAMPLES \
|
||||
-DINSTALLGPIOTOOL=$INSTALLGPIOTOOL \
|
||||
-DINSTALLTOOLS=$INSTALLTOOLS \
|
||||
-DBUILDTESTS=$BUILDTESTS \
|
||||
-DUSEPYTHON3TESTS=$USEPYTHON3TESTS \
|
||||
..
|
||||
|
||||
CMD make
|
@@ -154,7 +154,7 @@ FULL_PATH_NAMES = YES
|
||||
# will be relative from the directory where doxygen is started.
|
||||
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
|
||||
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
|
||||
|
||||
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
|
||||
# path mentioned in the documentation of a class, which tells the reader which
|
||||
|
89
README.md
89
README.md
@@ -1,8 +1,9 @@
|
||||
<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
|
||||
@@ -26,34 +27,100 @@ X86
|
||||
* [Galileo Gen 2 - Rev H](../master/docs/galileorevh.md)
|
||||
* [Edison](../master/docs/edison.md)
|
||||
* [Intel DE3815](../master/docs/intel_de3815.md)
|
||||
* [Minnowboard Max](../master/docs/minnow_max.md)
|
||||
* [Minnowboard](../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)
|
||||
* [Intel Joule](../master/docs/joule.md)
|
||||
|
||||
ARM
|
||||
---
|
||||
* [Raspberry Pi](../master/docs/raspberry_pi.md)
|
||||
* [Bannana Pi](../master/docs/banana_pi.md)
|
||||
* [Banana Pi](../master/docs/banana_pi.md)
|
||||
* [Beaglebone Black](../master/docs/beaglebone.md)
|
||||
* [phyBOARD-Wega](../master/docs/phyboard-wega.md)
|
||||
* [96Boards](../master/docs/96boards.md)
|
||||
|
||||
FPGA
|
||||
----
|
||||
* [DE10-Nano](../master/docs/de_nano_soc.md)
|
||||
|
||||
USB
|
||||
---
|
||||
* [FT4222](../master/docs/ftdi_ft4222.md)
|
||||
* [Firmata](../master/docs/firmata.md)
|
||||
|
||||
Mock
|
||||
----
|
||||
* [Generic simulated board](../master/docs/mock.md)
|
||||
|
||||
JSON platform
|
||||
----
|
||||
* [Platform loading](../master/docs/jsonplatform.md)
|
||||
|
||||
Installing on your board
|
||||
========
|
||||
========================
|
||||
|
||||
Installing on Ubuntu
|
||||
--------------------
|
||||
|
||||
Here is a PPA for installing on ubuntu:
|
||||
https://launchpad.net/~mraa/+archive/ubuntu/mraa
|
||||
|
||||
```bash
|
||||
sudo add-apt-repository ppa:mraa/mraa
|
||||
sudo apt-get update
|
||||
sudo apt-get install libmraa1 libmraa-dev mraa-tools python-mraa python3-mraa
|
||||
```
|
||||
|
||||
Node.js package is available separately.
|
||||
|
||||
Install on Arch Linux
|
||||
---------------------
|
||||
|
||||
There is an AUR package for mraa here: https://aur.archlinux.org/packages/mraa
|
||||
|
||||
Install on openSUSE
|
||||
-------------------
|
||||
|
||||
```bash
|
||||
REPO="openSUSE_Tumbleweed"
|
||||
if test "$(arch)" == "aarch64"; then
|
||||
REPO="openSUSE_Factory_ARM"
|
||||
fi
|
||||
sudo zypper ar http://download.opensuse.org/repositories/hardware/$REPO/hardware.repo
|
||||
sudo zypper in mraa
|
||||
```
|
||||
|
||||
Installing for Node.js only
|
||||
---------------------------
|
||||
|
||||
> Note: Node.js 7.0.0+ is not supported. You'll have to downgrade to 6.x.x.
|
||||
|
||||
You can also install just the node.js mraa module by using npm. You will need a
|
||||
C++ compiler and the node development headers, however it's not required to
|
||||
have SWIG installed.
|
||||
|
||||
```bash
|
||||
npm install mraa
|
||||
```
|
||||
|
||||
Note that installing mraa in this way builds mraa without json-c so you cannot
|
||||
use mraa_init_json_platform(). Also building this way means the mraa.node
|
||||
includes a static version of libmraa rather than relying on a dynamic library
|
||||
in /usr/lib.
|
||||
|
||||
Subplatforms (i.e. Firmata) have to be added manually with this kind of install
|
||||
from your application, as shown in [this example](examples/javascript/firmata.js).
|
||||
|
||||
Installing on Intel 32bit Yocto based opkg image
|
||||
------------------------------------------------
|
||||
|
||||
See the section below on compiling or use our repository to install on a glibc
|
||||
based yocto poky image that supports opkg. Adding this repository is as simple
|
||||
as and you'll have the latest stable tagged build of mraa installed!
|
||||
|
||||
``` bash
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
|
||||
opkg update
|
||||
opkg install mraa
|
||||
```
|
||||
@@ -62,19 +129,11 @@ If you would like to get the latest & greatest builds from master HEAD you can
|
||||
use our -dev repository
|
||||
|
||||
```bash
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/3.5/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf
|
||||
opkg update
|
||||
opkg install mraa
|
||||
```
|
||||
|
||||
You can also install just the node.js mraa module by using npm. You will need a
|
||||
C++ compiler and the node development headers, however it's not required to
|
||||
have SWIG installed.
|
||||
|
||||
```bash
|
||||
npm install mraa
|
||||
```
|
||||
|
||||
Compiling
|
||||
=========
|
||||
|
||||
|
@@ -51,7 +51,9 @@ extern "C" {
|
||||
typedef struct _aio* mraa_aio_context;
|
||||
|
||||
/**
|
||||
* Initialise an Analog input device, connected to the specified pin
|
||||
* Initialise an Analog input device, connected to the specified pin. Aio pins
|
||||
* are always 0 indexed reguardless of their position. Check your board mapping
|
||||
* for details. An arduino style layout will have A0 as pin14 but AIO0.
|
||||
*
|
||||
* @param pin Channel number to read ADC inputs
|
||||
* @returns aio context or NULL
|
||||
|
@@ -56,7 +56,9 @@ class Aio
|
||||
}
|
||||
/**
|
||||
* Aio Constructor, takes a pointer to the AIO context and initialises
|
||||
* the AIO class
|
||||
* the AIO class. Aio pins are always 0 indexed reguardless of their
|
||||
* position. Check your board mapping for details. An arduino style layout
|
||||
* will have A0 as pin14 but AIO0.
|
||||
*
|
||||
* @param void * to an AIO context
|
||||
*/
|
||||
|
@@ -85,7 +85,7 @@ mraa_result_t mraa_init() __attribute__((constructor));
|
||||
* people who like super clean code. If dynamically loading & unloading
|
||||
* libmraa you need to call this before unloading the library.
|
||||
*/
|
||||
void mraa_deinit();
|
||||
void mraa_deinit() __attribute__((destructor));
|
||||
|
||||
/**
|
||||
* Checks if a pin is able to use the passed in mode.
|
||||
@@ -201,6 +201,41 @@ int mraa_get_platform_combined_type();
|
||||
*/
|
||||
unsigned int mraa_get_pin_count();
|
||||
|
||||
/**
|
||||
* Get the number of usable UARTs, board must be initialised.
|
||||
*
|
||||
* @return number of usable UARTs on the platform, returns -1 on failure.
|
||||
*/
|
||||
int mraa_get_uart_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable SPI buses, board must be initialised.
|
||||
*
|
||||
* @return number of usable SPI buses on the platform, returns -1 on failure.
|
||||
*/
|
||||
int mraa_get_spi_bus_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable PWM pins, board must be initialised.
|
||||
*
|
||||
* @return number of PWMs on the current platform, -1 on failure.
|
||||
*/
|
||||
int mraa_get_pwm_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable GPIOs, board must be initialised.
|
||||
*
|
||||
* @return number of usable external GPIO pins on the board, -1 on failure.
|
||||
*/
|
||||
int mraa_get_gpio_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable analog pins, board must be initialised.
|
||||
*
|
||||
* @return number of usable ADC inputs on the platform and -1 on failure.
|
||||
*/
|
||||
int mraa_get_aio_bus_count(void);
|
||||
|
||||
/**
|
||||
* Get platform usable I2C bus count, board must be initialised.
|
||||
*
|
||||
@@ -233,6 +268,46 @@ unsigned int mraa_get_platform_pin_count(uint8_t platform_offset);
|
||||
*/
|
||||
char* mraa_get_pin_name(int pin);
|
||||
|
||||
/**
|
||||
* Get GPIO index by pin name, board must be initialised.
|
||||
*
|
||||
* @param pin_name: GPIO pin name. Eg: IO0
|
||||
* @return int of MRAA index for GPIO or -1 if not found.
|
||||
*/
|
||||
int mraa_gpio_lookup(const char* pin_name);
|
||||
|
||||
/**
|
||||
* Get I2C bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param i2c_name: I2C bus name. Eg: I2C6
|
||||
* @return int of MRAA index for I2C bus or -1 if not found.
|
||||
*/
|
||||
int mraa_i2c_lookup(const char* i2c_name);
|
||||
|
||||
/**
|
||||
* Get SPI bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param spi_name: Name of SPI bus. Eg: SPI2
|
||||
* @return int of MRAA index for SPI bus or -1 if not found.
|
||||
*/
|
||||
int mraa_spi_lookup(const char* spi_name);
|
||||
|
||||
/**
|
||||
* Get PWM index by PWM name, board must be initialised.
|
||||
*
|
||||
* @param pwm_name: Name of PWM. Eg:PWM0
|
||||
* @return int of MRAA index for PWM or -1 if not found.
|
||||
*/
|
||||
int mraa_pwm_lookup(const char* pwm_name);
|
||||
|
||||
/**
|
||||
* Get UART index by name, board must be initialised.
|
||||
*
|
||||
* @param uart_name: Name of UART. Eg:UART1
|
||||
* @return int of MRAA index for UART, or -1 if not found.
|
||||
*/
|
||||
int mraa_uart_lookup(const char* uart_name);
|
||||
|
||||
/**
|
||||
* Get default i2c bus, board must be initialised.
|
||||
*
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include "common.h"
|
||||
#include "types.hpp"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
/**
|
||||
* @namespace mraa namespace
|
||||
@@ -176,6 +178,18 @@ getPinCount()
|
||||
return mraa_get_pin_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform usable UART count, board must be initialised.
|
||||
*
|
||||
* @return number of usable UARTs on the current platform. Function will
|
||||
* return -1 on failure
|
||||
*/
|
||||
inline int
|
||||
getUartCount()
|
||||
{
|
||||
return mraa_get_uart_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform usable I2C bus count, board must be initialised.
|
||||
*
|
||||
@@ -214,6 +228,111 @@ getPinName(int pin)
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GPIO index by pin name, board must be initialised.
|
||||
*
|
||||
* @param pin_name: GPIO pin name. Eg: IO0
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for GPIO
|
||||
*/
|
||||
inline int
|
||||
getGpioLookup(std::string pin_name)
|
||||
{
|
||||
int index = mraa_gpio_lookup(pin_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "Gpio name " << pin_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get I2C bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param i2c_name: I2C bus name. Eg: I2C6
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for I2C bus
|
||||
*/
|
||||
inline int
|
||||
getI2cLookup(std::string i2c_name)
|
||||
{
|
||||
int index = mraa_i2c_lookup(i2c_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "i2c name " << i2c_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SPI bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param spi_name: Name of SPI bus. Eg: SPI2
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for SPI bus
|
||||
*/
|
||||
inline int
|
||||
getSpiLookup(std::string spi_name)
|
||||
{
|
||||
int index = mraa_spi_lookup(spi_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "Spi name " << spi_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PWM index by PWM name, board must be initialised.
|
||||
*
|
||||
* @param pwm_name: Name of PWM. Eg:PWM0
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for PWM
|
||||
*/
|
||||
inline int
|
||||
getPwmLookup(std::string pwm_name)
|
||||
{
|
||||
int index = mraa_pwm_lookup(pwm_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "PWM name " << pwm_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get UART index by UART name, board must be initialised.
|
||||
*
|
||||
* @param pwm_name: Name of the UART. Eg: UART2
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return MRAA index for the UART
|
||||
*/
|
||||
inline int
|
||||
getUartLookup(std::string uart_name)
|
||||
{
|
||||
int index = mraa_uart_lookup(uart_name.c_str());
|
||||
|
||||
if (index < 0) {
|
||||
std::ostringstream oss;
|
||||
oss << "UART name " << uart_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
|
||||
* syslog log levels, see syslog(3) for more information on the levels.
|
||||
|
@@ -46,9 +46,7 @@ extern "C" {
|
||||
|
||||
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
|
||||
#include <jni.h>
|
||||
extern "C" {
|
||||
void mraa_java_isr_callback(void *args);
|
||||
}
|
||||
void mraa_java_isr_callback(void *args);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@@ -45,7 +45,7 @@ class I2c
|
||||
public:
|
||||
/**
|
||||
* Instantiates an i2c bus. Multiple instances of the same bus can
|
||||
* exist and the bus is not guarranteed to be on the correct address
|
||||
* exist and the bus is not guaranteed to be on the correct address
|
||||
* before read/write.
|
||||
*
|
||||
* @param bus The i2c bus to use
|
||||
@@ -76,7 +76,7 @@ class I2c
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the I2c Bus used. This does not guarrantee the bus will not
|
||||
* Closes the I2c Bus used. This does not guarantee the bus will not
|
||||
* be usable by anyone else or communicates this disconnect to any
|
||||
* slaves.
|
||||
*/
|
||||
|
@@ -47,6 +47,7 @@ class IioHandler
|
||||
{
|
||||
public:
|
||||
virtual void onIioEvent(const IioEventData& eventData) = 0;
|
||||
virtual ~IioHandler() {}; // add an empty destructor to get rid of warning
|
||||
};
|
||||
|
||||
|
||||
|
@@ -70,6 +70,12 @@ class Spi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise SPI object using 'raw' mode. Mraa will go and grab the spidev device lablled /dev/spidev<bus>.<cs>
|
||||
*
|
||||
* @param bus to use
|
||||
* @param cs to use
|
||||
*/
|
||||
Spi(int bus, int cs)
|
||||
{
|
||||
m_spi = mraa_spi_init_raw(bus, cs);
|
||||
|
@@ -46,11 +46,16 @@ typedef enum {
|
||||
MRAA_BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
|
||||
MRAA_BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
|
||||
MRAA_INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */
|
||||
MRAA_96BOARDS = 9, /**< Linaro 96boards */
|
||||
MRAA_96BOARDS = 9, /**< Linaro 96boards */
|
||||
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 */
|
||||
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
|
||||
MRAA_UP = 12, /**< The UP Board */
|
||||
MRAA_INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
MRAA_INTEL_GT_TUCHUCK = MRAA_INTEL_JOULE_EXPANSION, // deprecated
|
||||
#endif
|
||||
MRAA_PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
|
||||
MRAA_DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
|
||||
|
||||
// USB platform extenders start at 256
|
||||
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
|
||||
@@ -58,6 +63,7 @@ typedef enum {
|
||||
// contains bit 9 so is subplatform
|
||||
MRAA_GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
|
||||
|
||||
MRAA_ANDROID_PERIPHERALMANAGER = 95, /**< Android Things peripheral manager platform */
|
||||
MRAA_MOCK_PLATFORM = 96, /**< Mock platform, which requires no real hardware */
|
||||
MRAA_JSON_PLATFORM = 97, /**< User initialised platform from json*/
|
||||
MRAA_NULL_PLATFORM = 98, /**< Platform with no capabilities that hosts a sub platform */
|
||||
@@ -240,11 +246,11 @@ typedef enum {
|
||||
} mraa_i2c_mode_t;
|
||||
|
||||
typedef enum {
|
||||
MRAA_UART_PARITY_NONE = 0,
|
||||
MRAA_UART_PARITY_EVEN = 1,
|
||||
MRAA_UART_PARITY_ODD = 2,
|
||||
MRAA_UART_PARITY_MARK = 3,
|
||||
MRAA_UART_PARITY_SPACE = 4
|
||||
MRAA_UART_PARITY_NONE = 0,
|
||||
MRAA_UART_PARITY_EVEN = 1,
|
||||
MRAA_UART_PARITY_ODD = 2,
|
||||
MRAA_UART_PARITY_MARK = 3,
|
||||
MRAA_UART_PARITY_SPACE = 4
|
||||
} mraa_uart_parity_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -51,12 +51,15 @@ typedef enum {
|
||||
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 */
|
||||
INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
|
||||
PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
|
||||
DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
|
||||
|
||||
FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
|
||||
|
||||
GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
|
||||
|
||||
ANDROID_PERIPHERALMANAGER = 95, /**< Android Things peripheral manager platform */
|
||||
NULL_PLATFORM = 98,
|
||||
UNKNOWN_PLATFORM =
|
||||
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
|
@@ -72,6 +72,18 @@ mraa_uart_context mraa_uart_init_raw(const char* path);
|
||||
*/
|
||||
mraa_result_t mraa_uart_flush(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Send a break to the device.
|
||||
* Blocks until complete.
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param duration When 0, send a break lasting at least 250
|
||||
* milliseconds, and not more than 500 milliseconds. When non zero,
|
||||
* the break duration is implementation specific.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_sendbreak(mraa_uart_context dev, int duration);
|
||||
|
||||
/**
|
||||
* Set the baudrate.
|
||||
* Takes an int and will attempt to decide what baudrate is
|
||||
@@ -136,6 +148,41 @@ mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t n
|
||||
*/
|
||||
const char* mraa_uart_get_dev_path(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Get the current settings of an UART. This is an unintrusive function. Meaning
|
||||
* it intends not to change anything, only read the values without disturbing.
|
||||
*
|
||||
* All but the first index parameter are "outparameters". That means they can
|
||||
* contain values on return. If any parameter is not interesting, a null pointer
|
||||
* can be sent instead as a placeholder.
|
||||
* The devpath parameter can be either in or out parameter. In case of a negative
|
||||
* index, the UART is identified using *devpath instead. This functionality is
|
||||
* intended for and needed by for instance USB serial adapters.
|
||||
*
|
||||
* In case of a non-success return value, the outparameters are undefined.
|
||||
*
|
||||
* @param index uart index to look up, if negative, *devpath will be used instead
|
||||
* @param devpath points to the device path of the UART, eg: /dev/ttyS0
|
||||
* @param name outparameter that on return will point to the name of the UART
|
||||
* @param baudrate pointer to an integer to contain the current baudrate (0--4M)
|
||||
* @param databits pointer to an integer to contain the number databits (5--8)
|
||||
* @param stopbits pointer to an integer to contain the number stopbits (1--2)
|
||||
* @param parity will contain the current parity mode
|
||||
* @param rtscts will point to non-zero if CTS/RTS flow control is enabled, zero otherwise
|
||||
* @param xonxoff will point to a non-zero value if xon/xoff flow control is enabled
|
||||
* @return result
|
||||
*/
|
||||
mraa_result_t
|
||||
mraa_uart_settings(int index,
|
||||
const char **devpath,
|
||||
const char **name,
|
||||
int* baudrate,
|
||||
int* databits,
|
||||
int* stopbits,
|
||||
mraa_uart_parity_t* parity,
|
||||
unsigned int* rtscts,
|
||||
unsigned int* xonxoff);
|
||||
|
||||
/**
|
||||
* Destroy a mraa_uart_context
|
||||
*
|
||||
|
@@ -124,7 +124,7 @@ class Uart
|
||||
}
|
||||
|
||||
/**
|
||||
* Write bytes in String object to a device
|
||||
* Write bytes in char* buffer to a device
|
||||
*
|
||||
* @param data buffer pointer
|
||||
* @param length maximum size of buffer
|
||||
@@ -197,6 +197,21 @@ class Uart
|
||||
return (Result) mraa_uart_flush(m_uart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a break to the device.
|
||||
* Blocks until complete.
|
||||
*
|
||||
* @param duration When 0, send a break lasting at least 250
|
||||
* milliseconds, and not more than 500 milliseconds. When non zero,
|
||||
* the break duration is implementation specific.
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
sendBreak(int duration)
|
||||
{
|
||||
return (Result) mraa_uart_sendbreak(m_uart, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the baudrate.
|
||||
* Takes an int and will attempt to decide what baudrate is
|
||||
@@ -263,7 +278,7 @@ class Uart
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
SetNonBlocking(bool nonblock)
|
||||
setNonBlocking(bool nonblock)
|
||||
{
|
||||
return (Result) mraa_uart_set_non_blocking(m_uart, nonblock);
|
||||
}
|
||||
|
@@ -64,19 +64,19 @@ extern "C" {
|
||||
#include "common.h"
|
||||
#include "uart.h"
|
||||
|
||||
/* 8 bytes (64 bits) for a device rom code */
|
||||
#define MRAA_UART_OW_ROMCODE_SIZE 8
|
||||
|
||||
/* 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 */
|
||||
unsigned char ROM_NO[MRAA_UART_OW_ROMCODE_SIZE]; /* 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
|
||||
*/
|
||||
|
@@ -233,7 +233,7 @@ class UartOW
|
||||
mraa::Result
|
||||
command(uint8_t command, std::string id)
|
||||
{
|
||||
if (id.empty() == 0)
|
||||
if (id.empty())
|
||||
return (mraa::Result) mraa_uart_ow_command(m_uart, command, NULL);
|
||||
else {
|
||||
if (id.size() != 8) {
|
||||
@@ -241,7 +241,7 @@ class UartOW
|
||||
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());
|
||||
return (mraa::Result) mraa_uart_ow_command(m_uart, command, (uint8_t*) id.data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ class UartOW
|
||||
uint8_t
|
||||
crc8(std::string buffer)
|
||||
{
|
||||
return mraa_uart_ow_crc8((uint8_t*) buffer.c_str(), buffer.size());
|
||||
return mraa_uart_ow_crc8((uint8_t*) buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -23,13 +23,16 @@ 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 "include/node/node.h" "include/src/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}/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}/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
|
||||
else()
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - node.h not found")
|
||||
|
84
docker-compose.yaml
Normal file
84
docker-compose.yaml
Normal file
@@ -0,0 +1,84 @@
|
||||
version: '2.1'
|
||||
|
||||
services:
|
||||
|
||||
main:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- http_proxy
|
||||
- https_proxy
|
||||
- no_proxy
|
||||
- BUILDDOC=${BUILDDOC:-OFF}
|
||||
- BUILDSWIG=${BUILDSWIG:-OFF}
|
||||
- BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF}
|
||||
- BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF}
|
||||
- BUILDSWIGNODE=${BUILDSWIGNODE:-OFF}
|
||||
- USBPLAT=${USBPLAT:-OFF}
|
||||
- FIRMATA=${FIRMATA:-OFF}
|
||||
- ONEWIRE=${ONEWIRE:-OFF}
|
||||
- JSONPLAT=${JSONPLAT:-OFF}
|
||||
- IMRAA=${IMRAA:-OFF}
|
||||
- FTDI4222=${FTDI4222:-OFF}
|
||||
- IPK=${IPK:-OFF}
|
||||
- RPM=${RPM:-OFF}
|
||||
- ENABLEEXAMPLES=${ENABLEEXAMPLES:-ON}
|
||||
- INSTALLGPIOTOOL=${INSTALLGPIOTOOL:-OFF}
|
||||
- INSTALLTOOLS=${INSTALLTOOLS:-OFF}
|
||||
- BUILDTESTS=${BUILDTESTS:-ON}
|
||||
- CC=${CC:-clang-3.8}
|
||||
- CXX=${CXX:-clang++-3.8}
|
||||
- NODE_VERSION=${NODE_VERSION:-v4.4.7}
|
||||
- BUILDARCH=${BUILDARCH}
|
||||
environment:
|
||||
- http_proxy
|
||||
- https_proxy
|
||||
- no_proxy
|
||||
|
||||
doc:
|
||||
extends: main
|
||||
build:
|
||||
args:
|
||||
- BUILDDOC=ON
|
||||
command: bash -c "make doc"
|
||||
|
||||
python2:
|
||||
extends: main
|
||||
build:
|
||||
args:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGPYTHON=ON
|
||||
command: bash -c "make _python2-mraa && ctest --output-on-failure"
|
||||
|
||||
python3:
|
||||
extends: python2
|
||||
build:
|
||||
args:
|
||||
- USEPYTHON3TESTS=ON
|
||||
command: bash -c "make _python3-mraa && ctest --output-on-failure"
|
||||
|
||||
java:
|
||||
extends: main
|
||||
build:
|
||||
args:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- CC=gcc-4.8
|
||||
- CXX=g++-4.8
|
||||
command: bash -c "make mraajava && ctest --output-on-failure"
|
||||
|
||||
node4:
|
||||
extends: main
|
||||
build:
|
||||
args:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- NODE_VERSION=v4.4.7
|
||||
command: bash -c "source /root/.nvm/nvm.sh && make npmpkg && cd .. && node-gyp configure && node-gyp build && npm test"
|
||||
|
||||
node5:
|
||||
extends: node4
|
||||
build:
|
||||
args:
|
||||
- NODE_VERSION=v5.12.0
|
56
docs/96boards.md
Normal file
56
docs/96boards.md
Normal file
@@ -0,0 +1,56 @@
|
||||
96Boards Development Platform {#96boards}
|
||||
=============================
|
||||
|
||||
96Boards is a range of hardware specifications created by Linaro to make the latest ARM-based processors available to developers at a reasonable cost. The specifications are open and define a standard board layout for SoC-agnostic (processor independent) development platforms that can be used by software application, hardware device, kernel and other system software developers. Boards produced to the 96Boards specifications are suitable for rapid prototyping, hobbyist projects or incorporation into new systems for a wide range of applications including desktop and laptop computing, the digital home, digital signage, point of sale (POS), high-end audio, robotics and drones, artificial intelligence, virtual reality, IoT and industrial control.
|
||||
|
||||
Standardized expansion buses for peripheral I/O have led to a wide range of compatible add-on mezzanine boards that will work across a variety of 96Boards products. Users have access to a wide range of boards with different features at various price points. In addition, some SoC vendors have announced long term availability of the SoC to encourage their use in products with long life cycles.
|
||||
|
||||
Board Support
|
||||
-------------
|
||||
|
||||
- [DragonBoard 410c](http://www.96boards.org/product/dragonboard410c/)
|
||||
- [HiKey](http://www.96boards.org/product/hikey/)
|
||||
- [Bubblegum-96](http://www.96boards.org/product/bubblegum-96/)
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
- **GPIO**: Pin 28 / GPIO-F is a Multi-Purpose pin
|
||||
- **UART**: UART1 can be used for serial access
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
Pin mapping table shows signals pertaining to 40-pin low speed expansion header based on [96Boards Consumer Edition Specification](https://github.com/96boards/documentation/blob/master/Specifications/96Boards-CE-Specification.pdf).
|
||||
|
||||
| 96Boards Signals | PIN | PIN | 96Boards Signals |
|
||||
|:------------------|:------|------:|:-------------------|
|
||||
| GND | 1 | 2 | GND |
|
||||
| UART0_CTS | 3 | 4 | PWR_BTN_N |
|
||||
| UART0_TxD | 5 | 6 | RST_BTN_N |
|
||||
| UART0_RxD | 7 | 8 | SPI0_SCLK |
|
||||
| UART1_RTS | 9 | 10 | SPI0_DIN |
|
||||
| UART1_TxD | 11 | 12 | SPI0_CS |
|
||||
| UART1_RxD | 13 | 14 | SPI0_DOUT |
|
||||
| I2C0_SCL | 15 | 16 | PCM_FS |
|
||||
| I2C0_SDA | 17 | 18 | PCM_CLK |
|
||||
| I2C1_SCL | 19 | 20 | PCM_DO |
|
||||
| I2C1_SDA | 21 | 22 | PCM_DI |
|
||||
| GPIO-A | 23 | 24 | GPIO-B |
|
||||
| GPIO-C | 25 | 26 | GPIO-D |
|
||||
| GPIO-E | 27 | 28 | GPIO-F |
|
||||
| GPIO-G | 29 | 30 | GPIO-H |
|
||||
| GPIO-I | 31 | 32 | GPIO-J |
|
||||
| GPIO-K | 33 | 34 | GPIO-L |
|
||||
| +1V8 | 35 | 36 | SYS_DCIN |
|
||||
| +5V | 37 | 38 | SYC_DCIN |
|
||||
| GND | 39 | 40 | GND |
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
The following links will take you to addition 96Boards resources
|
||||
|
||||
- [Website](http://www.96boards.org/)
|
||||
- [Forums](https://discuss.96boards.org/)
|
||||
- [Documentation Repo](https://github.com/96boards/documentation)
|
@@ -11,13 +11,14 @@ what you'll need:
|
||||
* [SWIG](http://swig.org) 3.0.5+
|
||||
* [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)
|
||||
* [node.js](http://nodejs.org) 4.x recommended (you'll need not just the interpreter but nodejs-dev)
|
||||
* [CMake](http://cmake.org) 2.8.8+ (3.1+ is recommended for node.js version 2+)
|
||||
* [json-c](https://github.com/json-c/json-c) 0.12+ (0.10+ probably works in reality)
|
||||
|
||||
For Debian-like distros the below command installs the basic set:
|
||||
|
||||
```bash
|
||||
sudo apt-get install git build-essential swig3.0 python-dev nodejs-dev cmake
|
||||
sudo apt-get install git build-essential swig3.0 python-dev nodejs-dev cmake libjson-c-dev
|
||||
```
|
||||
|
||||
To build the documentation you'll also need:
|
||||
@@ -52,8 +53,9 @@ Currently our install logic puts Python bindings into standard paths, which
|
||||
do not work on Debian due to their
|
||||
[policy](http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-paths).
|
||||
|
||||
We are working on a permanent solution, in the meanwhile please use this command
|
||||
after `make install` to link installed modules where Debian's Python expects them:
|
||||
We are working on a permanent solution, in the meantime please use this command
|
||||
after `make install` to link installed modules where Debian's Python expects
|
||||
them:
|
||||
|
||||
```bash
|
||||
sudo ln -s <your install prefix, e.g. /usr>/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages
|
||||
@@ -91,30 +93,35 @@ Disabling Python module building:
|
||||
Building doc, this will require [SPHINX](http://sphinx-doc.org) &
|
||||
[Doxygen](http://doxygen.org):
|
||||
`-DBUILDDOC=ON`
|
||||
You will also require clone git submodules from your existing checkout:
|
||||
`git submodule update --init --recursive`
|
||||
The from doxygen2jsdoc dir:
|
||||
`npm install mkdirp commander lodash bluebird pegjs`
|
||||
|
||||
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`
|
||||
|
||||
You can also enable -Wall for gcc before running cmake by exporting your wanted
|
||||
CC flags to the CC env var
|
||||
`export CC="gcc -Wall"`
|
||||
|
||||
Sometimes it's nice to build a static libary, on Linux systems just set
|
||||
`-DBUILD_SHARED_LIBS=OFF`
|
||||
|
||||
## Dependencies continued
|
||||
|
||||
You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
|
||||
JavaScript & Python modules. If your version of SWIG is older than this then
|
||||
please see above for disabling `SWIGNODE`. Otherwise you will get a weird build
|
||||
failure when building the JavaScript module. The Python module builds with SWIG
|
||||
2.x.
|
||||
2.x but we don't test it.
|
||||
|
||||
During the build, we'll assume you're building from git, note that if you
|
||||
compile with `git` installed your version of mraa will be tagged `-dirty`. This
|
||||
simply means `git` wasn't installed or that you where building from a tarball.
|
||||
You can modify `build/src/version.c` before running `make` if this is incorrect.
|
||||
The instructions listed here all assume that `build/` is an empty dir that lives
|
||||
inside the cloned repository of mraa.
|
||||
|
||||
If you have multiple versions of Python then mraa can get confused, we
|
||||
recommend using virtualenv to select which version of Python you want. We test
|
||||
2.7 the most but SWIG will generate valid 3.x Python code but we do not
|
||||
generally support building both at once.
|
||||
compile with `git` installed your version of mraa will be versioned with `git
|
||||
desribe --tag` to make it easy for intentification. You can easily modify
|
||||
version.c in build/src. If you don't build from a git tree then you will simply
|
||||
have a version which matches the latest released version of mraa.
|
||||
|
||||
## Using a Yocto/OE toolchain
|
||||
|
||||
@@ -131,7 +138,6 @@ make
|
||||
|
||||
## Using Coverity
|
||||
|
||||
Static analysis is routinely performed using Coverity on libmraa's codebase.
|
||||
This is the procedure to submit a build to Coverity. You'll need to install
|
||||
`coverity-submit` for your OS.
|
||||
|
||||
@@ -178,3 +184,18 @@ build machine.
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
cmake -DRPM=ON -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
## Building for the Android Things Peripheralmanager Client
|
||||
|
||||
Requirements:
|
||||
* Android [Things Native Library](https://github.com/androidthings/native-libandroidthings)
|
||||
* Android NDK >= 14b
|
||||
|
||||
The [Things Native Library](https://github.com/androidthings/native-libandroidthings) contains a CMake find_package module
|
||||
[FindAndroidThings.cmake](https://github.com/androidthings/native-libandroidthings/blob/master/FindAndroidThings.cmake). Make sure the directory containing this module is
|
||||
added to the CMAKE_MODULE_PATH.
|
||||
|
||||
#### NDK r14b
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
cmake -DBUILDSWIG=OFF -DBUILDARCH=PERIPHERALMAN -DANDROID_TOOLCHAIN_NAME=x86-i686 -DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk-r14b/build/cmake/android.toolchain.cmake -DCMAKE_MODULE_PATH=/path/to/native-libandroidthings ..
|
||||
~~~~~~~~~~~~~
|
||||
|
@@ -5,6 +5,48 @@ 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.7.0**
|
||||
* Peripheral I/O support for Android Things
|
||||
* Deprecation of node v0.10.x and 0.12.x
|
||||
* Documetnatino improvements
|
||||
|
||||
**1.6.1**
|
||||
* mraa-deinit bug fix
|
||||
* rpi3 fix
|
||||
* ALTERA_SOCFPGA -> DE_NANO_SOC
|
||||
|
||||
**1.6.0**
|
||||
* de-10 nano board support
|
||||
* Improved Intel Joule support & renamed from GT_TUCHUCK to Joule
|
||||
* Improved RPI3 support
|
||||
* Fixes for UP, 96boards & phyboard-wega
|
||||
* Call mraa_deinit with a gcc destructor attribute
|
||||
|
||||
**1.5.1**
|
||||
* Small memleaks plugged
|
||||
* imraa useless arp statements removed
|
||||
* NPM 1.5.0 did not 100% match real 1.5.0 tag, this resolves this
|
||||
|
||||
**1.5.0**
|
||||
* imraa now uses argp, slight option changes, you need to use -a to flash a 101
|
||||
* Joule i2c enumeration much improved, uses pci id
|
||||
* Firmata add a spinlock to remove possible race condition
|
||||
* Mock Uart functionality
|
||||
|
||||
**1.4.0**
|
||||
* Add support for Siemens SIMATIC IOT2000
|
||||
* Cmake now enables much more error detection depending on compiler support
|
||||
* Mraa Maven packages now enabled
|
||||
* Galileo Gen2 AIO fix using pincmd
|
||||
* Adding an already added firmata platform now returns MRAA_SUCCESS
|
||||
* Cmake no longer tags builds without git as '-dirty' version.c for easier
|
||||
packaging support
|
||||
|
||||
**1.3.0**
|
||||
* Fix GT GPIO bugs
|
||||
* Mock SPI and travis now uses mock and tests it
|
||||
* RPI zero support
|
||||
|
||||
**1.2.3**
|
||||
* Revert 1.2.1 binding.gyp changed that had side effect of enabling JSONPLAT in mraa.c
|
||||
* improve travis.ci to load mraa.node as compiled from make npmpkg target
|
||||
@@ -19,25 +61,25 @@ they are listed here. Anything pre 0.2.x is ignored.
|
||||
**1.2.0**
|
||||
* JSON platform support
|
||||
* mock I2c functionality
|
||||
* Intel Grosse Tete PWM fix
|
||||
* Intel Joule PWM fix
|
||||
* AIO firmata bug fix
|
||||
|
||||
**1.1.2**
|
||||
* Mock platform support
|
||||
* mraa-i2c treats i2c buses by default as linux
|
||||
* grosse tete i2c fixes
|
||||
* Intel Joule i2c fixes
|
||||
* travis now uses 14.04 instead of 12.04
|
||||
|
||||
**1.1.1**
|
||||
* IIO 4.6 kernel matrix support
|
||||
* Intel Grosse Tete radio led support
|
||||
* Intel Joule radio led support
|
||||
* mraa_init_io() examples
|
||||
* MRAAPLATFORMFORCE fixes
|
||||
* fix python documentation
|
||||
|
||||
**1.1.0**
|
||||
* build python2 & python3 bindings
|
||||
* Intel Grosse Tete support
|
||||
* Intel Joule support
|
||||
* mraa_init_io() generic funtion
|
||||
* mraa-gpio fixes
|
||||
* edison PWM 0% improvements
|
||||
|
153
docs/de_nano_soc.md
Normal file
153
docs/de_nano_soc.md
Normal file
@@ -0,0 +1,153 @@
|
||||
Terasic DE10-Nano {#de10-nano}
|
||||
=================
|
||||
|
||||
The DE10-Nano Development Kit presents a robust hardware design platform built around the Intel
|
||||
System-on-Chip (SoC) FPGA, which combines the latest dual-core Cortex-A9 embedded cores with
|
||||
industry-leading programmable logic for ultimate design flexibility. Users can now leverage the
|
||||
power of tremendous re-configurability paired with a high-performance, low-power processor system.
|
||||
Altera’s SoC integrates an ARM-based hard processor system (HPS) consisting of processor,
|
||||
peripherals and memory interfaces tied seamlessly with the FPGA fabric using a high-bandwidth
|
||||
interconnect backbone. The DE10-Nano development board is equipped with high-speed DDR3 memory,
|
||||
analog to digital capabilities, Ethernet networking, and much more that promise many exciting
|
||||
applications.
|
||||
|
||||
Board Support
|
||||
-------------
|
||||
|
||||
* Terasic DE10-Nano
|
||||
* Terasic DE0-Nano-SoC
|
||||
|
||||
Protocol Notes
|
||||
---------------
|
||||
|
||||
* **GPIO** Fully supported through sysfs (both FPGA + HPC). Mmap not yet supported. Static map.
|
||||
* **PWM** Currently not supported.
|
||||
* **I2C** Fully supported with i2cdev. Default bus 2 is exposed on Arduino header, 3 buses total.
|
||||
* **SPI** Supported with spidev on Arduino header.
|
||||
* **UART** Working, default bus is on Arduino header. Console also accessible as `ttyS0` in raw mode.
|
||||
* **ADC** Currently not supported.
|
||||
|
||||
No muxes available for multi-function pins yet (e.g. you won't be able to use D0 & D1 on Arduino
|
||||
header as GPIOs).
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
**Arduino Header**
|
||||
|
||||
| MRAA Number | Arduino Name | Board Pin | Function |
|
||||
|-------------|--------------|-----------|----------|
|
||||
| 0 | D0 | JP3-8 | UART RX |
|
||||
| 1 | D1 | JP3-7 | UART TX |
|
||||
| 2 | D2 | JP3-6 | GPIO |
|
||||
| 3 | D3 | JP3-5 | GPIO |
|
||||
| 4 | D4 | JP3-4 | GPIO |
|
||||
| 5 | D5 | JP3-3 | GPIO |
|
||||
| 6 | D6 | JP3-2 | GPIO |
|
||||
| 7 | D7 | JP3-1 | GPIO |
|
||||
| 8 | D8 | JP2-10 | GPIO |
|
||||
| 9 | D9 | JP2-9 | GPIO |
|
||||
| 10 | D10 | JP2-8 | SPI SS |
|
||||
| 11 | D11 | JP2-7 | SPI MOSI |
|
||||
| 12 | D12 | JP2-6 | SPI MISO |
|
||||
| 13 | D13 | JP2-5 | SPI SCK |
|
||||
| 14 | GND | JP2-4 | - |
|
||||
| 15 | AREF | JP2-3 | - |
|
||||
| 16 | SDA | JP2-2 | I2C SDA |
|
||||
| 17 | SCL | JP2-1 | I2C SCL |
|
||||
| 18 | AREF | JP5-1 | - |
|
||||
| 19 | IOREF | JP5-2 | - |
|
||||
| 20 | RESET | JP5-3 | - |
|
||||
| 21 | 3V3 | JP5-4 | - |
|
||||
| 22 | 5V | JP5-5 | - |
|
||||
| 23 | GND | JP5-6 | - |
|
||||
| 24 | GND | JP5-7 | - |
|
||||
| 25 | VIN | JP5-8 | - |
|
||||
| 26 | A0 | JP6-1 | AIO |
|
||||
| 27 | A1 | JP6-2 | AIO |
|
||||
| 28 | A2 | JP6-3 | AIO |
|
||||
| 29 | A3 | JP6-4 | AIO |
|
||||
| 30 | A4 | JP6-5 | AIO |
|
||||
| 31 | A5 | JP6-6 | AIO |
|
||||
|
||||
**GPIO0 (JP1) Side Header**
|
||||
|
||||
| MRAA Number | Board Pin | Function |
|
||||
|-------------|-----------|----------|
|
||||
| 32 | JP1-1 | GPIO |
|
||||
| ... | ... | GPIO |
|
||||
| 41 | JP1-10 | GPIO |
|
||||
| 42 | JP1-11 | 5V |
|
||||
| 43 | JP1-12 | GND |
|
||||
| 44 | JP1-13 | GPIO |
|
||||
| ... | ... | GPIO |
|
||||
| 59 | JP1-28 | GPIO |
|
||||
| 60 | JP1-29 | 3V3 |
|
||||
| 61 | JP1-30 | GND |
|
||||
| 62 | JP1-31 | GPIO |
|
||||
| ... | ... | GPIO |
|
||||
| 71 | JP1-40 | GPIO |
|
||||
|
||||
**GPIO1 (JP7) Side Header**
|
||||
|
||||
| MRAA Number | Board Pin | Function |
|
||||
|-------------|-----------|----------|
|
||||
| 72 | JP7-1 | GPIO |
|
||||
| ... | ... | GPIO |
|
||||
| 81 | JP7-10 | GPIO |
|
||||
| 82 | JP7-11 | 5V |
|
||||
| 83 | JP7-12 | GND |
|
||||
| 84 | JP7-13 | GPIO |
|
||||
| ... | ... | GPIO |
|
||||
| 99 | JP7-28 | GPIO |
|
||||
| 100 | JP7-29 | 3V3 |
|
||||
| 101 | JP7-30 | GND |
|
||||
| 102 | JP7-31 | GPIO |
|
||||
| ... | ... | GPIO |
|
||||
| 111 | JP7-40 | GPIO |
|
||||
|
||||
**Switches, Buttons, LEDs**
|
||||
|
||||
These are already in use by kernel drivers with the default image, except for KEY0 and KEY1.
|
||||
To use them with MRAA remove them from the device tree.
|
||||
|
||||
To enable the switches temporarily (until reboot):
|
||||
|
||||
```sh
|
||||
echo ff204000.gpio >/sys/bus/platform/drivers/altera_gpio/unbind
|
||||
echo ff204000.gpio >/sys/bus/platform/drivers/altera_gpio/bind
|
||||
```
|
||||
|
||||
And for LEDs:
|
||||
|
||||
```sh
|
||||
echo ff203000.gpio >/sys/bus/platform/drivers/altera_gpio/unbind
|
||||
echo ff203000.gpio >/sys/bus/platform/drivers/altera_gpio/bind
|
||||
```
|
||||
|
||||
| MRAA Number | Board Pin | Function |
|
||||
|-------------|-----------|----------|
|
||||
| 112 | SW0 | GPIO |
|
||||
| 113 | SW1 | GPIO |
|
||||
| 114 | SW2 | GPIO |
|
||||
| 115 | SW3 | GPIO |
|
||||
| 116 | LED0 | GPIO |
|
||||
| 117 | LED1 | GPIO |
|
||||
| 118 | LED2 | GPIO |
|
||||
| 119 | LED3 | GPIO |
|
||||
| 120 | LED4 | GPIO |
|
||||
| 121 | LED5 | GPIO |
|
||||
| 122 | LED6 | GPIO |
|
||||
| 123 | LED7 | GPIO |
|
||||
| 124 | HPS_LED | GPIO |
|
||||
| 125 | HPS_KEY | GPIO |
|
||||
| 126 | KEY0 | GPIO |
|
||||
| 127 | KEY1 | GPIO |
|
||||
|
||||
**Built-in ADXL345**
|
||||
|
||||
Exposed on I2C bus 0. To use you will have to unbind the device driver first:
|
||||
|
||||
```sh
|
||||
echo 0-0053 > /sys/bus/i2c/drivers/adxl34x/unbind
|
||||
```
|
@@ -1,112 +1,5 @@
|
||||
Grosse Tete {#grossetete}
|
||||
===========
|
||||
{#grossetete}
|
||||
|
||||
The Grosse Tete with the Tuchuck board is supported by Mraa
|
||||
You probably meant to go here: @joule.
|
||||
|
||||
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
|
||||
Note: This page will be deleted in the future, don't link to it!
|
||||
|
@@ -30,7 +30,6 @@ 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).
|
||||
|
@@ -45,9 +45,10 @@ Specific platform information for supported platforms is documented here:
|
||||
- @ref rasppi
|
||||
- @ref bananapi
|
||||
- @ref beaglebone
|
||||
- @ref phyboard-wega
|
||||
- @ref nuc5
|
||||
- @ref up
|
||||
- @ref grossetete
|
||||
- @ref joule
|
||||
- @ref ft4222
|
||||
|
||||
## DEBUGGING
|
||||
|
@@ -45,9 +45,10 @@ Specific platform information for supported platforms is documented here:
|
||||
- @ref rasppi
|
||||
- @ref bananapi
|
||||
- @ref beaglebone
|
||||
- @ref phyboard-wega
|
||||
- @ref nuc5
|
||||
- @ref up
|
||||
- @ref grossetete
|
||||
- @ref joule
|
||||
- @ref ft4222
|
||||
|
||||
## DEBUGGING
|
||||
|
142
docs/joule.md
Normal file
142
docs/joule.md
Normal file
@@ -0,0 +1,142 @@
|
||||
Intel Joule {#joule}
|
||||
===========
|
||||
|
||||
[http://www.intel.com/joule](http://www.intel.com/joule)
|
||||
|
||||
The Intel Joule expansion board is supported by Mraa
|
||||
|
||||
Revision Support
|
||||
----------------
|
||||
Intel Joule expansion board
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**SPI**
|
||||
|
||||
Two SPI buses are available, with one chipselect each. Pins listed are MRAA
|
||||
numbered pins. Other chip selects are available if enabled in BIOS/EEPROM but
|
||||
cannot be enabled as BIOS options. You will need the spidev kernel module
|
||||
loaded, Ostro-XT and ref-os-iot does this by default.
|
||||
|
||||
Bus 0 (32765)
|
||||
MOSI = 4
|
||||
MISO = 2
|
||||
CS = 6
|
||||
CLK = 10
|
||||
|
||||
Bus 1 (32766)
|
||||
MOSI = 67
|
||||
MISO = 69
|
||||
CS0 = 59
|
||||
CS1 = 61
|
||||
CLK = 65
|
||||
|
||||
(remove 40 from numbers to get pin header number for pins on low speed header
|
||||
2)
|
||||
|
||||
**UART** Some pins are labelled as UARTs but are not configured in BIOS as UART
|
||||
so only available UART is on the FTDI header. Disable the getty on ttyS2 and
|
||||
use mraa's uart raw mode to initialise on ttyS2. The Jumper J8 can be used to
|
||||
switch between using the FTDI 6 pin header and the micro USB output.
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
The Intel Joule expansion board has two breakouts, breakout #1 is 1-40 whilst breakout2 is 41-80. The
|
||||
LEDs are numbered from 100-103.
|
||||
|
||||
ISH UART are named as: IURT.
|
||||
ISH I2C are named as:IIC.
|
||||
|
||||
| MRAA Number | Physical Pin | Function |
|
||||
|-------------|--------------|----------|
|
||||
| 1 | GPIO | GPIO |
|
||||
| 2 | SPP1RX | GPIO SPI |
|
||||
| 3 | PMICRST | NONE |
|
||||
| 4 | SPP1TX | GPIO SPI |
|
||||
| 5 | 19.2mhz | GPIO |
|
||||
| 6 | SPP1FS0 | GPIO SPI |
|
||||
| 7 | UART0TX | GPIO |
|
||||
| 8 | SPP1FS2 | GPIO SPI |
|
||||
| 9 | PWRGD | NONE |
|
||||
| 10 | SPP1CLK | GPIO SPI |
|
||||
| 11 | I2C0SDA | I2C |
|
||||
| 12 | I2S1SDI | GPIO |
|
||||
| 13 | I2C0SCL | I2C |
|
||||
| 14 | I2S1SDO | GPIO |
|
||||
| 15 | IIC0SDA | I2C |
|
||||
| 16 | I2S1WS | GPIO |
|
||||
| 17 | IIC0SCL | I2C |
|
||||
| 18 | I2S1CLK | GPIO |
|
||||
| 19 | IIC1SDA | I2C |
|
||||
| 20 | I2S1MCL | GPIO |
|
||||
| 21 | IIC1SCL | I2C |
|
||||
| 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 SPI |
|
||||
| 60 | CAMERA | NONE |
|
||||
| 61 | SPP0FS1 | GPIO SPI |
|
||||
| 62 | SPI_DAT | SPI |
|
||||
| 63 | SPP0FS2 | GPIO SPI |
|
||||
| 64 | SPICLKB | GPIO |
|
||||
| 65 | SPI0CLK | GPIO SPI |
|
||||
| 66 | SPICLKA | GPIO |
|
||||
| 67 | SPP0TX | GPIO SPI |
|
||||
| 68 | UART0RX | GPIO UART|
|
||||
| 69 | SPP0RX | GPIO SPI |
|
||||
| 70 | UART0RT | GPIO UART|
|
||||
| 71 | I2C1SDA | I2C |
|
||||
| 72 | UART0CT | GPIO UART|
|
||||
| 73 | I2C1SCL | I2C |
|
||||
| 74 | IURT0TX | GPIO UART|
|
||||
| 75 | I2C2SDA | I2C |
|
||||
| 76 | IURT0RX | GPIO UART|
|
||||
| 77 | I2C2SCL | I2C |
|
||||
| 78 | IURT0RT | GPIO UART|
|
||||
| 79 | RTC_CLK | GPIO |
|
||||
| 80 | IURT0CT | GPIO UART|
|
||||
| 100 | LED100 | GPIO |
|
||||
| 101 | LED101 | GPIO |
|
||||
| 102 | LED102 | GPIO |
|
||||
| 103 | LED103 | GPIO |
|
||||
| 104 | LEDWIFI | GPIO |
|
||||
| 105 | LEDBT | GPIO |
|
||||
|
||||
To see a live pin mapping use the command:
|
||||
$ mraa-gpio list
|
127
docs/jsonplatform.md
Normal file
127
docs/jsonplatform.md
Normal file
@@ -0,0 +1,127 @@
|
||||
JSON platform {#jsonplat}
|
||||
=============
|
||||
|
||||
JSON platform loading allows libmraa users who work with **simple** and unsupported
|
||||
boards to create JSON configuration files which libmraa understands, allowing
|
||||
libmraa to just 'work' with the unsupported platform. JSON platform **does not work**
|
||||
with boards which require advanced functions which overwrite default functionality or
|
||||
boards that require the mux functionality.
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
The JSON file that libmraa reads needs specific values to be set by default, they
|
||||
are required in every JSON file intended to be used to load the platform.
|
||||
The keywords are case sensitive so be aware when writing the JSON file.
|
||||
Each heading is a top level key in the JSON file, each key's type is Array
|
||||
|
||||
### platform
|
||||
|Key |Type |Required |Description |
|
||||
|-------------|-------|-----------|-----------------------------------------------|
|
||||
|id |int |no | An ID that can be assigned |
|
||||
|name |string |yes | The platform name |
|
||||
|pin_count |int |yes | The total pin count |
|
||||
|gpio_count |int |no | The subset of pincount which able to do GPIO |
|
||||
|i2c_count |int |no | The number of usable I2C ports |
|
||||
|aio_count |int |no | The number of usable AIO ports |
|
||||
|spi_count |int |no | The number of usable SPI ports |
|
||||
|uart_count |int |no | The total UART ports |
|
||||
|pwmDefPeriod |int |no | The default PWM period |
|
||||
|pwmMaxPeriod |int |no | The max PWM period |
|
||||
|pwmMinPeriod |int |no | The min PWM period |
|
||||
|
||||
### layout
|
||||
|
||||
**THIS INDEX'S THE PIN ARRAY**
|
||||
Each available pin specified using pin_count requires a label. There is no need to use an
|
||||
index identifier as the json objects are indexed as they are read, starting with the first
|
||||
json object being treated as index 0.
|
||||
|
||||
The number of json objects in layout should be equal to the pin_count.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|-----------------------------------------------|
|
||||
|label |string |yes | The label used to describe the pin |
|
||||
|invalid |boolean|no | Sets the labeled pin as an invalid pin |
|
||||
|
||||
### GPIO
|
||||
|
||||
**THIS INDEX'S THE PIN ARRAY**
|
||||
For the supported GPIO pins here is where we set the raw linux pin it needs to use, the
|
||||
index cannot exceed the total pin_count and the number of JSON ojects cannot exceed the
|
||||
gpio_count total. The index is also used to set the specified pin's capabilities. Each set
|
||||
of keys should be enclosed in a json object.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|-------------------------------------|
|
||||
|index |int |yes | used to index the pin array |
|
||||
|rawpin |int |yes | used to reference the actual IO pin |
|
||||
|
||||
### I2C
|
||||
|
||||
**THIS INDEX'S THE I2C ARRAY**
|
||||
This is used to setup the I2C functionality. The total number of json objects and the index
|
||||
cannot exceed the i2c_count. Each set of keys should be enclosed in a json object.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|-------------------------------------|
|
||||
|index |int |yes | Used to index the I2C array |
|
||||
|rawpin |int |yes | The sysfs pin |
|
||||
|sclpin |int |no | The clock pin |
|
||||
|sdapin |int |no | The data pin |
|
||||
|default |boolean|no | Sets the default I2C device used |
|
||||
|
||||
### AIO
|
||||
|
||||
**THIS INDEX'S THE PIN ARRAY**
|
||||
This is used to setup which pins are able to perform AIO. Each set of keys should be
|
||||
enclosed in a json object.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|-------------------------------------|
|
||||
|index |int |yes | Used to index the pin array |
|
||||
|rawpin |int |yes | The sysfs pin |
|
||||
|
||||
### PWM
|
||||
|
||||
**THIS INDEX'S THE PIN ARRAY**
|
||||
This is used to setup which IO pins can do PWM Each set of keys should be enclosed in a
|
||||
json object.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|-------------------------------|
|
||||
|index |int |yes | Used to index the pin array |
|
||||
|rawpin |int |yes | The sysfs pin |
|
||||
|chipID |int |yes | The parent ID |
|
||||
|
||||
## SPI
|
||||
|
||||
**THIS INDEX'S THE SPI ARRAY**
|
||||
This is used to setup the SPI functionality. The total number of json objects and the index
|
||||
cannot exceed the spi_count. Each set of keys should be enclosed in a json object.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|--------------------------------------------|
|
||||
|index |int |yes | The index into the SPI array |
|
||||
|chipID |int |yes | The parent ID |
|
||||
|clock |int |no | The clock used for transmissions |
|
||||
|miso |int |no | Pin used for incoming data from the slave |
|
||||
|mosi |int |no | Pin used for outgoing data from the master |
|
||||
|chipselect |int |no | Pin used to select the slave device |
|
||||
|default |boolean|no | Sets the default SPI device |
|
||||
|
||||
### UART
|
||||
|
||||
**THIS INDEX'S THE UART ARRAY**
|
||||
This is used to setup the UART functionality. The total number of json objects and the index
|
||||
cannot exceed the uart_count. Each set of keys should be enclosed in a json object.
|
||||
|
||||
|Key |Type |Required |Description |
|
||||
|-----------|-------|-----------|-----------------------------------------|
|
||||
|index |int |yes | Used to index the UART array |
|
||||
|chipID |int |yes | Parent ID |
|
||||
|rawpin |int |yes | Sysfs pin |
|
||||
|rx |int |no | Read pin |
|
||||
|tx |int |no | Transmit pin |
|
||||
|path |string |yes | Used to talk to a connected UART device |
|
||||
|default |boolean|no | Sets the default UART device |
|
@@ -1,12 +1,14 @@
|
||||
Intel(R) Minnowboard Max {#minnowmax}
|
||||
========================
|
||||
Intel(R) MinnowBoard Max / MinnowBoard Turbot {#minnowmax}
|
||||
=============================================
|
||||
MinnowBoard MAX is an open hardware embedded board designed with the Intel(R)
|
||||
Atom(TM) E38xx series SOC (Fromerly Bay Trail).
|
||||
Atom(TM) E38xx series SOC (formely Bay Trail). The MinnowBoard Turbot is a
|
||||
backward compatible revision with performance and hardware improvements.
|
||||
https://www.minnowboard.org/learn-more/minnowboard-max-compatible-with-upgrades
|
||||
|
||||
For product overview and faq see
|
||||
http://www.minnowboard.org/faq-minnowboard-max/
|
||||
For product overview and faq see https://www.minnowboard.org/faq
|
||||
|
||||
For technical details see http://www.elinux.org/Minnowboard:MinnowMax
|
||||
For technical details see https://www.minnowboard.org/board-viewer or the
|
||||
legacy board https://www.minnowboard.org/minnowboard-max
|
||||
|
||||
Supported Firmware
|
||||
------------------
|
||||
@@ -55,4 +57,6 @@ bus #7.
|
||||
| 23 | 23 | GPIO_S5_1 | 83 | GPIO |
|
||||
| 24 | 24 | PWM1 | 249 | PWM Chip 1 Channel 0 |
|
||||
| 25 | 25 | S5_4 | 84 | GPIO |
|
||||
| 26 | 26 | IBL_8254 | 208 | GPIO |
|
||||
| 26 | 26 | IBL_8254 | 208 | GPIO / I2S MCLK (tb) |
|
||||
|
||||
*(tb) New assignment on the MinnowBoard Turbot
|
||||
|
12
docs/mock.md
12
docs/mock.md
@@ -19,6 +19,12 @@ Right now we simulate a single generic board with:
|
||||
which can be read or written in bytes or words (big-endian). Technically those
|
||||
registers are just an array of `uint8_t`, so you can treat them as 10 single-byte
|
||||
registers or 5 single-word ones or a mix thereof.
|
||||
* Single SPI bus with one Chip Select. All write functions are supported, received
|
||||
data items (words or bytes) are calculated from the sent ones using
|
||||
`sent_byte (or word) XOR constant` formula.
|
||||
See [SPI mock header](../include/mock/mock_board_spi.h#L38-L39) for constant values.
|
||||
* Single UART port. All functions are supported, but many are simple stubs. Write
|
||||
always succeeds, read returns 'Z' symbol as many times as `read()` requested.
|
||||
|
||||
We plan to develop it further and all [contributions](../CONTRIBUTING.md) are more than welcome.
|
||||
|
||||
@@ -30,6 +36,12 @@ See the table below for pin layout and features
|
||||
| 1 | ADC0 | AIO pin, returns random value on read |
|
||||
| 2 | I2C0SDA | SDA pin for I2C0 bus |
|
||||
| 3 | I2C0SCL | SCL pin for I2C0 bus |
|
||||
| 4 | SPI0CS | CS pin for SPI0 bus |
|
||||
| 5 | SPI0MOSI | MOSI pin for SPI0 bus |
|
||||
| 6 | SPI0MISO | MISO pin for SPI0 bus |
|
||||
| 7 | SPI0SCLK | SCLK pin for SPI0 bus |
|
||||
| 8 | UART0RX | RX pin for UART0 port |
|
||||
| 9 | UART0TX | TX pin for UART0 port |
|
||||
|
||||
Building
|
||||
--------
|
||||
|
@@ -24,12 +24,16 @@ dir which matches the npm pkg name so we create one with a symlink and add the
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILDSWIGNODE=ON ..
|
||||
cmake -DBUILDSWIGNODE=ON -DJSONPLAT=OFF ..
|
||||
make npmpkg
|
||||
ln -s ../ mraa
|
||||
tar hczv --exclude='build*' --exclude='.gitignore' --exclude='.git' --exclude='build*/*' --exclude='.git/*' -f mraa.tar.gz mraa
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
You need to disable jsonplatform otherwise you will need to change the
|
||||
binding.gyp file to include those sources and make sure target platform has
|
||||
json-c headers & libs.
|
||||
|
||||
Building with node-gyp
|
||||
----------------------
|
||||
|
||||
|
237
docs/phyboard-wega.md
Normal file
237
docs/phyboard-wega.md
Normal file
@@ -0,0 +1,237 @@
|
||||
phyBOARD-Wega {#phyboard-wega}
|
||||
=============
|
||||
|
||||
The phyBOARD-Wega for phyCORE-AM335x is a low-cost, feature-rich software
|
||||
development platform supporting the Texas Instruments AM335x microcontroller.
|
||||
|
||||
Moreover, due to the numerous standard interfaces the phyBOARD-Wega AM335x can
|
||||
serve as bedrock for your application. At the core of the phyBOARD-Wega is the
|
||||
PCL-051/phyCORE-AM335x System on Module (SOM) in a direct solder form factor,
|
||||
containing the processor, DRAM, NAND Flash, power regulation, supervision,
|
||||
transceivers, and other core functions required to support the AM335x
|
||||
processor. Surrounding the SOM is the PBA-CD-02/phyBOARD-Wega carrier board,
|
||||
adding power input, buttons, connectors, signal breakout, and Ethernet
|
||||
connectivity amongst other things.
|
||||
|
||||
There are (for example) some expansion boards available for the phyBOARD-Wega:
|
||||
- Power Module (PEB-POW-01)
|
||||
- Evaluation Board (PEB-EVAL-01)
|
||||
- HDMI Adapter (PEB-AV-01)
|
||||
|
||||
For further information and instruction please visit:
|
||||
www.phytec.de/produkt/system-on-modules/single-board-computer/phyboard-wega
|
||||
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**SPI**
|
||||
Spi0 can be used over pins on X69 connector. There are no more spi-devices.
|
||||
Independent of the given index in mraa_phyboard_spi_init_pre() function,
|
||||
it will be always initialized spi0.
|
||||
|
||||
**I2C**
|
||||
/* TODO */
|
||||
|
||||
**UART**
|
||||
Uart0 can be used over pins on X69 connector or serial port on Evaluation Board.
|
||||
The other Uarts not have been tested yet. This is a small TODO for future.
|
||||
|
||||
|
||||
Pin Assignment of X69 Expansion Connector
|
||||
-----------------------------------------
|
||||
|
||||
| Physical Pin | Signal Name | Type | SL | Description |
|
||||
|--------------|---------------------|------|-------|-------------------------|
|
||||
| 1 | VCC3V3 | OUT | 3.3 V | 3.3V power supply |
|
||||
| 2 | VCC5V | OUT | 5.0 V | 5V power supply |
|
||||
| 3 | VDIG1_1P8V | OUT | 1.8 V | 1.8V power supply |
|
||||
| | | | | (max. 300mA) |
|
||||
| 4 | GND | - | - | Ground |
|
||||
| 5 | X_SPIO_CS0 | OUT | 3.3 V | SPI 0 chip select 0 |
|
||||
| 6 | X_SPIO_MOSI | OUT | 3.3 V | SPI 0 master output / |
|
||||
| | | | | slave input |
|
||||
| 7 | X_SPIO_MISO | IN | 3.3 V | SPI 0 master input / |
|
||||
| | | | | slave output |
|
||||
| 8 | X_SPIO_CLK | OUT | 3.3 V | SPI 0 clock output |
|
||||
| 9 | GND | - | - | Ground |
|
||||
| 10 | X_UART0_RXD | IN | 3.3 V | UART 0 receive data |
|
||||
| | | | | (std. debug iface) |
|
||||
| 11 | X_I2C0_SDA | I/O | 3.3 V | I2C0 Data |
|
||||
| 12 | X_UART0_TXD | OUT | 3.3 V | UART 0 transmit data |
|
||||
| | | | | (std. debug iface) |
|
||||
| 13 | X_I2C0_SCL | I/O | 3.3 V | I2C0 Clock |
|
||||
| 14 | GND | - | - | Ground |
|
||||
| 15 | X_JTAG_TMS | IN | 3.3 V | JTAG Chain Test |
|
||||
| | | | | Mode Select signal |
|
||||
| 16 | X_nJTAG_TRST | IN | 3.3 V | JTAG Chain Test Reset |
|
||||
| 17 | X_JTAG_TDI | IN | 3.3 V | JTAG Chain Test |
|
||||
| | | | | Data Input |
|
||||
| 18 | X_JTAG_TDO | OUT | 3.3 V | JTAG Chain Test |
|
||||
| | | | | Data Output |
|
||||
| 19 | GND | - | - | Ground |
|
||||
| 20 | X_JTAG_TCK | IN | 3.3 V | JTAG Chain Test |
|
||||
| | | | | Clock signal |
|
||||
| 21 | X_USB_DP_EXP | I/O | 3.3 V | USB data plus |
|
||||
| | | | | (for USB0 or USB1) |
|
||||
| 22 | X_USB_DM_EXP | I/O | 3.3 V | USB data minus |
|
||||
| | | | | (for USB0 or USB1) |
|
||||
| 23 | nRESET_OUT | OUT | 3.3 V | Reset |
|
||||
| 24 | GND | - | - | Ground |
|
||||
| 25 | X_MMC2_CMD | I/O | 3.3 V | MMC command |
|
||||
| 26 | X_MMC2_DATO | I/O | 3.3 V | MMC data 0 |
|
||||
| 27 | X_MMC2_CLK | I/O | 3.3 V | MMC clock |
|
||||
| 28 | X_MMC2_DAT1 | I/O | 3.3 V | MMC data 1 |
|
||||
| 29 | GND | - | - | Ground |
|
||||
| 30 | X_MMC2_DAT2 | I/O | 3.3 V | MMC data 2 |
|
||||
| 31 | X_UART2_RX_GPIO3_9 | I/O | 3.3 V | UART 2 receive data |
|
||||
| | | | | or GPIO3_9 |
|
||||
| 32 | X_MMC2_DAT3 | I/O | 3.3 V | MMC data 3 |
|
||||
| 33 | X_UART2_TX_GPIO3_10 | I/O | 3.3 V | UART 2 transmit data |
|
||||
| | | | | or GPIO3_10 |
|
||||
| 34 | GND | - | - | Ground |
|
||||
| 35 | X_UART3_RX_GPIO2_18 | I/O | 3.3 V | UART 3 receive data |
|
||||
| | | | | or GPIO2_18 |
|
||||
| 36 | X_UART3_TX_GPIO2_19 | I/O | 3.3 V | UART 3 transmit data |
|
||||
| | | | | or GPIO2_19 |
|
||||
| 37 | X_INTR1_GPIO0_20 | I/O | 3.3 V | Interrupt 1 or GPIO0_20 |
|
||||
| 38 | X_GPIO0_7 | I/O | 3.3 V | GPIO0_7 |
|
||||
| 39 | X_AM335_EXT_WAKEUP | IN | 3.3 V | External wakeup |
|
||||
| 40 | X_INT_RTCn | OUT | 3.3 V | Interrupt from the RTC |
|
||||
| 41 | GND | - | - | Ground |
|
||||
| 42 | X_GPIO3_7_nPMOD_PW | I/O | 3.3 V | GPIO3_7; Caution! Also |
|
||||
| | RFAIL | | | connected to power fail |
|
||||
| | | | | signal through R415. |
|
||||
| 43 | nRESET_IN | IN | 3.3 V | Push-button reset |
|
||||
| 44 | X_GPIO1_31 | I/O | 3.3 V | GPIO1_31 |
|
||||
| 45 | X_AM335_NMIn | IN | 3.3 V | AM335x |
|
||||
| | | | | non-maskable interrupt |
|
||||
| 46 | GND | - | - | Ground |
|
||||
| 47 | X_AIN4 | IN | 1.8 V | Analog input 4 |
|
||||
| 48 | X_AIN5 | IN | 1.8 V | Analog input 5 |
|
||||
| 49 | X_AIN6 | IN | 1.8 V | Analog input 6 |
|
||||
| 50 | X_AIN7 | IN | 1.8 V | Analog input 7 |
|
||||
| 51 | GND | - | - | Ground |
|
||||
| 52 | X_GPIO_CKSYNC | I/O | 3.3 V | GPIO Clock |
|
||||
| | | | | Synchronization |
|
||||
| 53 | X_USB_ID_EXP | IN | 1.8 V | USB port identification |
|
||||
| | | | | (for USB0 or USB1) |
|
||||
| 54 | USB_VBUS_EXP | OUT | 5.0 V | USB bus voltage |
|
||||
| | | | | (for USB0 or USB1) |
|
||||
| 55 | X_USB1_CE | OUT | 3.3 V | USB 1 charger enable |
|
||||
| 56 | GND | - | - | Ground |
|
||||
| 57 | VCC_BL | OUT | NS | Backlight power supply |
|
||||
| 58 | X_BP_POWER | IN | 5.0 V | Power On for Power |
|
||||
| | | | | Management IC for AM335x|
|
||||
| 59 | GND | - | - | Ground |
|
||||
| 60 | VCC5V_IN | IN | 5.0 V | 5 V input supply voltage|
|
||||
|
||||
|
||||
Pin Assignment of X70 A/V Connector
|
||||
-----------------------------------
|
||||
|
||||
| Physical Pin | Signal Name | Type | SL | Description |
|
||||
|--------------|---------------------|------|-------|-------------------------|
|
||||
| 1 | GND | - | - | Ground |
|
||||
| 2 | X_LCD_D21 | OUT | 3.3 V | LCD D21 |
|
||||
| 3 | X_LCD_D18 | OUT | 3.3 V | LCD D18 |
|
||||
| 4 | X_LCD_D16 | OUT | 3.3 V | LCD D16 |
|
||||
| 5 | X_LCD_D0 | OUT | 3.3 V | LCD D0 |
|
||||
| 6 | GND | - | - | Ground |
|
||||
| 7 | X_LCD_D1 | OUT | 3.3 V | LCD D1 |
|
||||
| 8 | X_LCD_D2 | OUT | 3.3 V | LCD D2 |
|
||||
| 9 | X_LCD_D3 | OUT | 3.3 V | LCD D3 |
|
||||
| 10 | X_LCD_D4 | OUT | 3.3 V | LCD D4 |
|
||||
| 11 | GND | - | - | Ground |
|
||||
| 12 | X_LCD_D22 | OUT | 3.3 V | LCD D22 |
|
||||
| 13 | X_LCD_D19 | OUT | 3.3 V | LCD D19 |
|
||||
| 14 | X_LCD_D5 | OUT | 3.3 V | LCD D5 |
|
||||
| 15 | X_LCD_D6 | OUT | 3.3 V | LCD D6 |
|
||||
| 16 | GND | - | - | Ground |
|
||||
| 17 | X_LCD_D7 | OUT | 3.3 V | LCD D7 |
|
||||
| 18 | X_LCD_D8 | OUT | 3.3 V | LCD D8 |
|
||||
| 19 | X_LCD_D9 | OUT | 3.3 V | LCD D9 |
|
||||
| 20 | X_LCD_D10 | OUT | 3.3 V | LCD D10 |
|
||||
| 21 | GND | - | - | Ground |
|
||||
| 22 | X_LCD_D23 | OUT | 3.3 V | LCD D23 |
|
||||
| 23 | X_LCD_D20 | OUT | 3.3 V | LCD D20 |
|
||||
| 24 | X_LCD_D17 | OUT | 3.3 V | LCD D17 |
|
||||
| 25 | X_LCD_D11 | OUT | 3.3 V | LCD D11 |
|
||||
| 26 | GND | - | - | Ground |
|
||||
| 27 | X_LCD_D12 | OUT | 3.3 V | LCD D12 |
|
||||
| 28 | X_LCD_D13 | OUT | 3.3 V | LCD D13 |
|
||||
| 29 | X_LCD_D14 | OUT | 3.3 V | LCD D14 |
|
||||
| 30 | X_LCD_D15 | OUT | 3.3 V | LCD D15 |
|
||||
| 31 | GND | - | - | Ground |
|
||||
| 32 | X_LCD_PCLK | OUT | 3.3 V | LCD Pixel Clock |
|
||||
| 33 | X_LCD_BIAS_EN | OUT | 3.3 V | LCD BIAS |
|
||||
| 34 | X_LCD_HSYNC | OUT | 3.3 V | LCD Horizontal |
|
||||
| | | | | Synchronization |
|
||||
| 35 | X_LCD_VSYNC | OUT | 3.3 V | LCD Vertical |
|
||||
| | | | | Synchronisation |
|
||||
| 36 | GND | - | - | Ground |
|
||||
| 37 | GND | - | - | Ground |
|
||||
| 38 | X_PWM1_OUT | OUT | 3.3 V | Pulse Width Modulation |
|
||||
| 39 | VCC_BL | OUT | NS | Backlight power supply |
|
||||
| 40 | VCC5V | OUT | 5.0 V | 5 V power supply |
|
||||
|
||||
|
||||
Pin Assignment of X71 A/V Connector
|
||||
-----------------------------------
|
||||
|
||||
| Physical Pin | Signal Name | Type | SL | Description |
|
||||
|--------------|---------------------|------|-------|-------------------------|
|
||||
| 1 | X_I2S_CLK | I/O | 3.3 V | I2S Clock |
|
||||
| 2 | X_I2S_FRM | I/O | 3.3 V | I2S Frame |
|
||||
| 3 | X_I2S_ADC | I/O | 3.3 V | I2S Analog-Digital |
|
||||
| | | | | converter (microphone) |
|
||||
| 4 | X_I2S_DAC | I/O | 3.3 V | I2S Digital-Analog |
|
||||
| | | | | converter (speaker) |
|
||||
| 5 | X_AV_INT_GPIO1_30 | I/O | 3.3 V | A/V interrupt; GPIO1_30 |
|
||||
| 6 | nUSB1_OC_GPIO3_19 or| I/O | 3.3 V | GPIO3_19 or McASP0 |
|
||||
| | X_MCASP0_AHCLKX_GPIO3_21| | | high frequency clock |
|
||||
| 7 | GND | - | - | Ground |
|
||||
| 8 | nRESET_OUT | OUT | 3.3 V | Reset |
|
||||
| 9 | TS_X+ | IN | 1.8 V | Touch X+ |
|
||||
| 10 | TS_X- | IN | 1.8 V | Touch X- |
|
||||
| 11 | TS_Y+ | IN | 1.8 V | Touch Y+ |
|
||||
| 12 | TS_Y- | IN | 1.8 V | Touch Y- |
|
||||
| 13 | VCC3V3 | OUT | 3.3 V | 3.3 V power supply |
|
||||
| 14 | GND | - | - | Ground |
|
||||
| 15 | X_I2C0_SCL | I/O | 3.3 V | I2C Clock |
|
||||
| 16 | X_I2C0_SDA | I/O | 3.3 V | I2C Data |
|
||||
|
||||
Jumper J77 connects either signal X_MCASP0_AHCLKX_GPIO3_21 or signal
|
||||
nUSB1_OC_GPIO3_19 to pin 6 of X71.
|
||||
The following table shows the available configurations:
|
||||
|
||||
A/V Jumper configuration J77
|
||||
----------------------------
|
||||
|
||||
| J77 | Description |
|
||||
|-----|--------------------------|
|
||||
| 1+2 | X_MCASP0_AHCLKX_GPIO3_21 |
|
||||
| 2+3 | nUSB1_OC_GPIO3_19 |
|
||||
|
||||
Caution: If J77 is set to 2+3 , J78 also has to be set to 2+3 !
|
||||
|
||||
|
||||
GPIO - Pin-mapping (with installed expansion board)
|
||||
---------------------------------------------------
|
||||
|
||||
| Physical Pin | Pin-Name | Pin-Map / Sysfs GPIO | Def. usage | Connector|
|
||||
|--------------|---------------|----------------------|------------|----------|
|
||||
| 31 | X_GPIO3_9 | 105 | OUT LED3 | X69 |
|
||||
| 33 | X_GPIO3_10 | 106 | IN S3 | X69 |
|
||||
| 35 | X_GPIO2_18 | 82 (busy) | OUT LED1 | X69 |
|
||||
| 36 | X_GPIO2_19 | 83 | OUT LED2 | X69 |
|
||||
| 37 | X_GPIO0_20 | 20 (busy) | IN S1 | X69 |
|
||||
| 38 | X_GPIO0_7 | 7 | IN S2 | X69 |
|
||||
| 42 | X_GPIO3_7 | 103 | IN | X69 |
|
||||
| 44 | X_GPIO1_31 | 63 | IN | X69 |
|
||||
|--------------|---------------|----------------------|------------|----------|
|
||||
| 5 (105) | X_GPIO1_30 | 62 | IN | X71 |
|
||||
| 6 (106) | X_GPIO3_19 or | 115 | IN | X71 |
|
||||
| | X_GPIO3_21 | 117 | IN | X71 |
|
||||
|
||||
Info: (busy) means, that it is used by kernel driver!
|
29
docs/up.md
29
docs/up.md
@@ -1,11 +1,11 @@
|
||||
UP Board {#up}
|
||||
============
|
||||
|
||||
UP Board is based on the Intel(R) Atom(TM) x5-Z83xx SoC (formerly Cherry Trail).
|
||||
It includes 2GB RAM, 16/32GB eMMC flash, 6 USB2.0 ports, 1 USB 3.0 OTG port,
|
||||
1 Gigabit Ethernet, HDMI and DSI Graphics ports, RTC and a 40-pin I/O header.
|
||||
The form-factor for the board is based on the Raspberry Pi 2, and can be used
|
||||
with many of the add-on HAT boards designed for the Raspberry Pi 2.
|
||||
UP Board is based on the Intel(R) Atom(TM) x5-Z8350 SoC (formerly Cherry Trail).
|
||||
It includes 1/2/4GB RAM, 16/32/64GB eMMC flash, 6 USB2.0 ports, 1 USB 3.0 OTG
|
||||
port, 1 Gigabit Ethernet, HDMI and DSI/eDP Graphics ports, RTC and a 40-pin I/O
|
||||
header. The form-factor for the board is based on the Raspberry Pi 2, and can be
|
||||
used with many of the add-on HAT boards designed for the Raspberry Pi.
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
@@ -25,12 +25,15 @@ granular at higher speeds. E.g. Available speeds include:
|
||||
25MHz, 12.5MHz, 8.33MHz, 6.25MHz, 5MHz, 4.167MHz, 3.571MHz, 3.125MHz, etc.
|
||||
Please be aware that speeds in between those steps will be rounded UP to the
|
||||
next nearest available speed, and capped at 25MHz.
|
||||
At the time of writing, only a single native chip-select is available (SPI CS0).
|
||||
2 chip-selects are available, one natively (SPI CS0) and one by GPIO (SPI CS1).
|
||||
|
||||
**UART** 2 high-speed UARTs are available, supporting baud rates up to
|
||||
support baud rates between 300 and 3686400. Hardware flow-control signals are
|
||||
not exposed, so software flow-control may be needed for rates above 115200.
|
||||
A console UART is also available but is not fully supported at this time.
|
||||
**UART** 1 high-speed UART is available, supporting baud rates between 300 and
|
||||
3686400. Hardware flow-control signals are available on pins 11/36 (RTS/CTS).
|
||||
|
||||
**ADC** 1 8-bit single-channel ADC (TI ADC081C021) is available on pin 7.
|
||||
|
||||
Please note that a kernel with UP board support is required to enable the I/O
|
||||
interfaces above. Refer to https://up-community.org for more information.
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
@@ -48,13 +51,13 @@ Note that there is an enum to use wiringPi style numbers.
|
||||
| 4 | P1-04 | 5V VCC | | |
|
||||
| 5 | P1-05 | I2C SCL1 | 3 | I2C1 (/dev/i2c-1) |
|
||||
| 6 | P1-06 | GND | | |
|
||||
| 7 | P1-07 | GPIO(4) | 4 | |
|
||||
| 7 | P1-07 | GPIO(4) | 4 | ADC0 (iio:device0) |
|
||||
| 8 | P1-08 | UART TX1 | 14 | UART1 (/dev/ttyS1) |
|
||||
| 9 | P1-09 | GND | | |
|
||||
| 10 | P1-10 | UART RX1 | 15 | UART1 (/dev/ttyS1) |
|
||||
| 11 | P1-11 | GPIO(17) | 17 | |
|
||||
| 12 | P1-12 | I2S CLK | 18 | I2S0 (PCM Audio) |
|
||||
| 13 | P1-13 | UART RX2 | 27 | UART2 (/dev/ttyS2) |
|
||||
| 13 | P1-13 | GPIO(27) | 27 | |
|
||||
| 14 | P1-14 | GND | | |
|
||||
| 15 | P1-15 | GPIO(22) | 22 | |
|
||||
| 16 | P1-16 | GPIO(23) | 23 | |
|
||||
@@ -63,7 +66,7 @@ Note that there is an enum to use wiringPi style numbers.
|
||||
| 19 | P1-19 | SPI MOSI | 10 | SPI2 (/dev/spidev2.x)|
|
||||
| 20 | P1-20 | GND | | |
|
||||
| 21 | P1-21 | SPI MISO | 9 | SPI2 (/dev/spidev2.x)|
|
||||
| 22 | P1-22 | UART TX2 | 25 | UART2 (/dev/ttyS2) |
|
||||
| 22 | P1-22 | GPIO(25) | 25 | |
|
||||
| 23 | P1-23 | SPI SCL | 11 | SPI2 (/dev/spidev2.x)|
|
||||
| 24 | P1-24 | SPI CS0 | 8 | SPI2 (/dev/spidev2.0)|
|
||||
| 25 | P1-25 | GND | | |
|
||||
|
@@ -11,8 +11,11 @@ add_executable (blink_onboard blink_onboard.c)
|
||||
add_executable (uart uart.c)
|
||||
add_executable (mraa-gpio mraa-gpio.c)
|
||||
add_executable (mraa-i2c mraa-i2c.c)
|
||||
add_executable (mraa-uart mraa-uart.c)
|
||||
add_executable (spi_max7219 spi_max7219.c)
|
||||
add_executable (iio_driver iio_driver.c)
|
||||
if (NOT ANDROID_TOOLCHAIN)
|
||||
add_executable (iio_driver iio_driver.c)
|
||||
endif ()
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
# FIXME Hack to access mraa internal types used by mraa-i2c
|
||||
@@ -32,9 +35,11 @@ target_link_libraries (blink_onboard mraa)
|
||||
target_link_libraries (uart mraa)
|
||||
target_link_libraries (mraa-gpio mraa)
|
||||
target_link_libraries (mraa-i2c mraa)
|
||||
target_link_libraries (mraa-uart mraa)
|
||||
target_link_libraries (spi_max7219 mraa)
|
||||
target_link_libraries (iio_driver mraa)
|
||||
|
||||
if (NOT ANDROID_TOOLCHAIN)
|
||||
target_link_libraries (iio_driver mraa)
|
||||
endif ()
|
||||
if (ONEWIRE)
|
||||
add_executable (uart_ow uart_ow.c)
|
||||
target_link_libraries (uart_ow mraa)
|
||||
@@ -47,7 +52,9 @@ if (FIRMATA)
|
||||
target_link_libraries (i2c_firmata mraa)
|
||||
endif ()
|
||||
|
||||
add_subdirectory (c++)
|
||||
if (NOT ANDROID_TOOLCHAIN)
|
||||
add_subdirectory (c++)
|
||||
endif ()
|
||||
|
||||
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/mraa/examples)
|
||||
|
||||
@@ -58,4 +65,5 @@ endif()
|
||||
if (INSTALLTOOLS)
|
||||
install (TARGETS mraa-gpio DESTINATION bin)
|
||||
install (TARGETS mraa-i2c DESTINATION bin)
|
||||
install (TARGETS mraa-uart DESTINATION bin)
|
||||
endif()
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Nandkishor Sonar
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -23,30 +24,49 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
//! [Interesting]
|
||||
#include <signal.h>
|
||||
|
||||
#include "mraa/aio.h"
|
||||
|
||||
int running = 0;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
printf("closing down nicely\n");
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa_aio_context adc_a0;
|
||||
uint16_t adc_value = 0;
|
||||
float adc_value_float = 0.0;
|
||||
mraa_result_t r = MRAA_SUCCESS;
|
||||
|
||||
adc_a0 = mraa_aio_init(0);
|
||||
if (adc_a0 == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (running == 0) {
|
||||
adc_value = mraa_aio_read(adc_a0);
|
||||
adc_value_float = mraa_aio_read_float(adc_a0);
|
||||
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f (Ctrl+C to exit)\n", adc_value_float);
|
||||
}
|
||||
|
||||
mraa_aio_close(adc_a0);
|
||||
r = mraa_aio_close(adc_a0);
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
}
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
return r;
|
||||
}
|
||||
//! [Interesting]
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -25,9 +26,21 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "mraa/gpio.h"
|
||||
|
||||
int running = 0;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
printf("closing down nicely\n");
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
@@ -35,6 +48,7 @@ main(int argc, char** argv)
|
||||
mraa_gpio_context gpio, gpio_in = NULL;
|
||||
const char* board_name = mraa_get_platform_name();
|
||||
int ledstate = 0;
|
||||
mraa_result_t r = MRAA_SUCCESS;
|
||||
|
||||
switch (platform) {
|
||||
case MRAA_INTEL_GALILEO_GEN1:
|
||||
@@ -46,11 +60,14 @@ main(int argc, char** argv)
|
||||
// lure put an LED on pin 21
|
||||
gpio = mraa_gpio_init(21);
|
||||
break;
|
||||
case MRAA_INTEL_JOULE_EXPANSION:
|
||||
gpio = mraa_gpio_init(101);
|
||||
break;
|
||||
default:
|
||||
gpio = mraa_gpio_init(13);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
|
||||
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s (Ctrl+C to exit)\n", mraa_get_version(), board_name);
|
||||
|
||||
|
||||
if (gpio == NULL) {
|
||||
@@ -70,8 +87,11 @@ main(int argc, char** argv)
|
||||
|
||||
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
|
||||
|
||||
for (;;) {
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (running == 0) {
|
||||
if (gpio_in != NULL && mraa_gpio_read(gpio_in) == 0) {
|
||||
mraa_gpio_close(gpio_in);
|
||||
return 0;
|
||||
}
|
||||
ledstate = !ledstate;
|
||||
@@ -79,5 +99,10 @@ main(int argc, char** argv)
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
r = mraa_gpio_close(gpio);
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributors: Alex Tereschenko <alex.mkrs@gmail.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -22,9 +23,22 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//! [Interesting]
|
||||
#include <signal.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
int running = 0;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
printf("closing down nicely\n");
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -33,17 +47,17 @@ main()
|
||||
mraa::Aio* a0;
|
||||
|
||||
a0 = new mraa::Aio(0);
|
||||
if (a0 == NULL) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (running == 0) {
|
||||
adc_value = a0->read();
|
||||
adc_value_float = a0->readFloat();
|
||||
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f (Ctrl+C to exit)\n", adc_value_float);
|
||||
}
|
||||
|
||||
delete a0;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
//! [Interesting]
|
||||
|
@@ -56,12 +56,10 @@ main(int argc, char** argv)
|
||||
|
||||
//! [Interesting]
|
||||
mraa::Gpio* gpio = new mraa::Gpio(iopin);
|
||||
if (gpio == NULL) {
|
||||
return mraa::ERROR_UNSPECIFIED;
|
||||
}
|
||||
mraa::Result response = gpio->dir(mraa::DIR_OUT);
|
||||
if (response != mraa::SUCCESS) {
|
||||
mraa::printError(response);
|
||||
delete gpio;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -44,7 +45,8 @@ main()
|
||||
|
||||
x->isr(mraa::EDGE_BOTH, &interrupt, NULL);
|
||||
|
||||
for (;;) {
|
||||
int i = 100;
|
||||
for (; i > 0; --i) {
|
||||
if (counter != oldcounter) {
|
||||
fprintf(stdout, "timeout counter == %d\n", counter);
|
||||
oldcounter = counter;
|
||||
@@ -53,5 +55,6 @@ main()
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
delete x;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
@@ -46,9 +46,6 @@ main()
|
||||
mraa::Pwm* pwm;
|
||||
|
||||
pwm = new mraa::Pwm(3);
|
||||
if (pwm == NULL) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
|
||||
pwm->enable(true);
|
||||
|
||||
|
@@ -27,8 +27,6 @@
|
||||
//! [Interesting]
|
||||
#include "uart_ow.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
@@ -38,28 +36,30 @@ main(int argc, char** argv)
|
||||
mraa::Result rv;
|
||||
|
||||
if ((rv = uart->reset()) == mraa::SUCCESS) {
|
||||
cout << "Reset succeeded, device(s) detected!" << endl;
|
||||
std::cout << "Reset succeeded, device(s) detected!" << std::endl;
|
||||
} else {
|
||||
cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl;
|
||||
std::cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << std::endl;
|
||||
delete uart;
|
||||
return 1;
|
||||
}
|
||||
|
||||
cout << "Looking for devices..." << endl;
|
||||
std::cout << "Looking for devices..." << std::endl;
|
||||
;
|
||||
|
||||
uint8_t count = 0;
|
||||
// start the search from scratch
|
||||
string id = uart->search(true);
|
||||
std::string id = uart->search(true);
|
||||
|
||||
if (id.empty()) {
|
||||
cout << "No devices detected." << endl;
|
||||
std::cout << "No devices detected." << std::endl;
|
||||
delete uart;
|
||||
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();
|
||||
uint8_t* ptr = (uint8_t*) id.data();
|
||||
|
||||
// The first byte (0) is the device type (family) code.
|
||||
// The last byte (7) is the rom code CRC value. The
|
||||
@@ -73,7 +73,7 @@ main(int argc, char** argv)
|
||||
id = uart->search(false);
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
|
||||
delete uart;
|
||||
|
||||
|
@@ -49,6 +49,7 @@ main()
|
||||
value = 0.0f;
|
||||
}
|
||||
float output = mraa_pwm_read(pwm);
|
||||
printf("PWM value is %f\n", output);
|
||||
}
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
|
@@ -56,7 +56,7 @@ main()
|
||||
|
||||
mraa_firmata_response(firm, interrupt);
|
||||
|
||||
uint8_t* buffer = calloc(4, 0);
|
||||
char* buffer = calloc(4, 0);
|
||||
if (buffer == NULL) {
|
||||
free(firm);
|
||||
return EXIT_FAILURE;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -24,14 +25,28 @@
|
||||
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
#include <signal.h>
|
||||
|
||||
#include "mraa.h"
|
||||
|
||||
int running = 0;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
printf("closing down nicely\n");
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t r = MRAA_SUCCESS;
|
||||
|
||||
mraa_init();
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n", mraa_get_version());
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6 (Ctrl+C to exit)\n", mraa_get_version());
|
||||
|
||||
//! [Interesting]
|
||||
mraa_gpio_context gpio;
|
||||
@@ -40,13 +55,18 @@ main(int argc, char** argv)
|
||||
|
||||
mraa_gpio_dir(gpio, MRAA_GPIO_IN);
|
||||
|
||||
for (;;) {
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (running == 0) {
|
||||
fprintf(stdout, "Gpio is %d\n", mraa_gpio_read(gpio));
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
mraa_gpio_close(gpio);
|
||||
r = mraa_gpio_close(gpio);
|
||||
//! [Interesting]
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return r;
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ interrupt(char* data)
|
||||
mraa_iio_channel* channels = mraa_iio_get_channels(iio_device0);
|
||||
int i = 0;
|
||||
|
||||
for (i; i < mraa_iio_get_channel_count(iio_device0); i++) {
|
||||
for (; i < mraa_iio_get_channel_count(iio_device0); i++) {
|
||||
if (channels[i].enabled) {
|
||||
printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
|
||||
switch (channels[i].bytes) {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -52,7 +53,8 @@ main()
|
||||
|
||||
mraa_gpio_isr(x, edge, &interrupt, NULL);
|
||||
|
||||
for (;;) {
|
||||
int i = 100;
|
||||
for (; i > 0; --i) {
|
||||
if (counter != oldcounter) {
|
||||
fprintf(stdout, "timeout counter == %d\n", counter);
|
||||
oldcounter = counter;
|
||||
|
@@ -44,11 +44,12 @@ public class AioA0 {
|
||||
public static void main(String[] args) {
|
||||
Aio a0 = new Aio(0);
|
||||
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
int adc_value = a0.read();
|
||||
float adc_value_float = a0.readFloat();
|
||||
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
|
||||
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ public class BlinkIO {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
gpio.write(1);
|
||||
Thread.sleep(1000);
|
||||
gpio.write(0);
|
||||
|
@@ -64,7 +64,7 @@ public class BlinkOnboard {
|
||||
}
|
||||
|
||||
boolean state = false;
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
if (gpio_in != null && gpio_in.read() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ public class CyclePwm3 {
|
||||
pwm.enable(true);
|
||||
|
||||
float value = 0;
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
value += 0.01;
|
||||
pwm.write(value);
|
||||
Thread.sleep(50);
|
||||
|
@@ -50,8 +50,8 @@ public class FTDITest {
|
||||
/* Blink FTDI board LED */
|
||||
Gpio led = new Gpio(514);
|
||||
led.dir(Dir.DIR_OUT);
|
||||
for (int i = 0;; i = (i + 1) % 2) {
|
||||
led.write(i);
|
||||
for (int i = 100; i > 0; --i) {
|
||||
led.write(i % 2);
|
||||
Thread.sleep(500);
|
||||
}
|
||||
} else {
|
||||
|
@@ -44,12 +44,13 @@ public class GpioMmapped {
|
||||
String version = mraa.getVersion();
|
||||
System.out.println("hello mraa");
|
||||
System.out.println(String.format("Version: %s", version));
|
||||
System.out.println(String.format("Platform: %s", board));
|
||||
|
||||
Gpio gpio = new Gpio(1);
|
||||
|
||||
gpio.useMmap(true);
|
||||
|
||||
while (true) {
|
||||
for (int i = 1000; i > 0; --i) {
|
||||
gpio.write(1);
|
||||
Thread.sleep(50);
|
||||
gpio.write(0);
|
||||
|
@@ -46,7 +46,7 @@ public class GpioRead6 {
|
||||
|
||||
gpio.dir(Dir.DIR_IN);
|
||||
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
System.out.format("Gpio is %d\n", gpio.read());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
@@ -110,16 +110,16 @@ public class I2cCompass {
|
||||
conf_buf[1] = HMC5883L_CONT_MODE;
|
||||
i2c.write(conf_buf);
|
||||
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.writeByte(HMC5883L_DATA_REG);
|
||||
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.read(rx_tx_buf);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_X_LSB_REG] & 0xFF);
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Z_LSB_REG] & 0xFF);
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Y_LSB_REG] & 0xFF);
|
||||
|
||||
direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
||||
|
||||
|
@@ -43,7 +43,7 @@ public class SpiMCP4261 {
|
||||
|
||||
System.out.println("Hello, SPI initialised");
|
||||
byte data[] = {0x00, 100};
|
||||
while (true) {
|
||||
for (int cnt = 100; cnt > 0; --cnt) {
|
||||
for (int i = 90; i < 130; i++) {
|
||||
data[1] = (byte) i;
|
||||
byte[] recv = spi.write(data);
|
||||
|
@@ -22,11 +22,13 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
|
||||
"use strict";
|
||||
|
||||
var analogPin0 = new m.Aio(0); //setup access analog inpuput pin 0
|
||||
var analogValue = analogPin0.read(); //read the value of the analog pin
|
||||
var analogValueFloat = analogPin0.readFloat(); //read the pin value as a float
|
||||
const mraa = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
|
||||
|
||||
let analogPin0 = new mraa.Aio(0); //setup access analog inpuput pin 0
|
||||
let analogValue = analogPin0.read(); //read the value of the analog pin
|
||||
let analogValueFloat = analogPin0.readFloat(); //read the pin value as a float
|
||||
console.log(analogValue); //write the value of the analog pin to the console
|
||||
console.log(analogValueFloat.toFixed(5)); //write the value in the float format
|
||||
|
@@ -22,19 +22,18 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
|
||||
"use strict";
|
||||
|
||||
var myLed = new m.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
|
||||
myLed.dir(m.DIR_OUT); //set the gpio direction to output
|
||||
var ledState = true; //Boolean to hold the state of Led
|
||||
const mraa = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
|
||||
|
||||
function periodicActivity()
|
||||
{
|
||||
myLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low)
|
||||
ledState = !ledState; //invert the ledState
|
||||
setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds)
|
||||
let myLed = new mraa.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
|
||||
myLed.dir(mraa.DIR_OUT); //set the gpio direction to output
|
||||
let ledState = true; //Boolean to hold the state of Led
|
||||
|
||||
function periodicActivity() {
|
||||
myLed.write(ledState ? 1 : 0); //if ledState is true then write a '1' (high) otherwise write a '0' (low)
|
||||
ledState = !ledState; //invert the ledState
|
||||
}
|
||||
|
||||
periodicActivity(); //call the periodicActivity function
|
||||
|
||||
setInterval(periodicActivity, 1000); //call the periodicActivity function every second
|
||||
|
@@ -22,17 +22,17 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
|
||||
"use strict";
|
||||
|
||||
var myDigitalPin = new m.Gpio(6); //setup digital read on pin 6
|
||||
myDigitalPin.dir(m.DIR_IN); //set the gpio direction to input
|
||||
const mraa = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
|
||||
|
||||
periodicActivity(); //call the periodicActivity function
|
||||
let myDigitalPin = new mraa.Gpio(6); //setup digital read on pin 6
|
||||
myDigitalPin.dir(mraa.DIR_IN); //set the gpio direction to input
|
||||
|
||||
function periodicActivity() //
|
||||
{
|
||||
var myDigitalValue = myDigitalPin.read(); //read the digital value of the pin
|
||||
console.log('Gpio is ' + myDigitalValue); //write the read value out to the console
|
||||
setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds)
|
||||
function periodicActivity() {
|
||||
let myDigitalValue = myDigitalPin.read(); //read the digital value of the pin
|
||||
console.log('Gpio value is ' + myDigitalValue); //write the read value out to the console
|
||||
}
|
||||
|
||||
setInterval(periodicActivity, 1000); //call the indicated function every 1 second (1000 milliseconds)
|
||||
|
@@ -22,9 +22,11 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
|
||||
"use strict";
|
||||
|
||||
var myDigitalPin = new m.Gpio(5); //setup digital read on pin 5
|
||||
myDigitalPin.dir(m.DIR_OUT); //set the gpio direction to output
|
||||
const mraa = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
|
||||
|
||||
let myDigitalPin = new mraa.Gpio(5); //setup digital read on pin 5
|
||||
myDigitalPin.dir(mraa.DIR_OUT); //set the gpio direction to output
|
||||
myDigitalPin.write(1); //set the digital pin to high (1)
|
||||
|
@@ -24,29 +24,32 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
"use strict";
|
||||
|
||||
x = new m.I2c(0)
|
||||
x.address(0x77)
|
||||
const mraa = require('mraa'); //require mraa
|
||||
|
||||
let i2cDevice = new mraa.I2c(0);
|
||||
i2cDevice.address(0x77);
|
||||
|
||||
// initialise device
|
||||
if (x.readReg(0xd0) != 0x55) {
|
||||
console.log("error");
|
||||
if (i2cDevice.readReg(0xd0) != 0x55) {
|
||||
console.log("error");
|
||||
}
|
||||
|
||||
// we want to read temperature so write 0x2e into control reg
|
||||
x.writeReg(0xf4, 0x2e)
|
||||
i2cDevice.writeReg(0xf4, 0x2e);
|
||||
|
||||
// read a 16bit reg, obviously it's uncalibrated so mostly a useless value :)
|
||||
console.log(x.readWordReg(0xf6))
|
||||
console.log(i2cDevice.readWordReg(0xf6));
|
||||
|
||||
// and we can do the same thing with the read()/write() calls if we wished
|
||||
// thought I'd really not recommend it!
|
||||
buf = new Buffer(2)
|
||||
buf[0] = 0xf4
|
||||
buf[1] = 0x2e
|
||||
console.log(buf.toString('hex'))
|
||||
x.write(buf)
|
||||
let buf = new Buffer(2);
|
||||
buf[0] = 0xf4;
|
||||
buf[1] = 0x2e;
|
||||
console.log(buf.toString('hex'));
|
||||
i2cDevice.write(buf);
|
||||
|
||||
x.writeByte(0xf6)
|
||||
d = x.read(2)
|
||||
i2cDevice.writeByte(0xf6);
|
||||
let result = i2cDevice.read(2);
|
||||
console.log(result.toString('hex'));
|
||||
|
@@ -22,7 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var mraa = require('mraa');
|
||||
"use strict";
|
||||
|
||||
const mraa = require('mraa');
|
||||
console.log('MRAA Version: ' + mraa.getVersion());
|
||||
|
||||
// open connection to firmata
|
||||
|
@@ -22,12 +22,14 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var mraa = require('mraa');
|
||||
"use strict";
|
||||
|
||||
const mraa = require('mraa');
|
||||
const readline = require('readline');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
function printUsage() {
|
||||
@@ -42,16 +44,16 @@ function getVersion() {
|
||||
}
|
||||
|
||||
function setPin() {
|
||||
var pinNumber = arguments[0];
|
||||
var pinValue = arguments[1];
|
||||
var pin = new mraa.Gpio(pinNumber);
|
||||
let pinNumber = arguments[0];
|
||||
let pinValue = arguments[1];
|
||||
let pin = new mraa.Gpio(pinNumber);
|
||||
pin.dir(mraa.DIR_OUT);
|
||||
pin.write(pinNumber, pinValue);
|
||||
}
|
||||
|
||||
function getPin() {
|
||||
var pinNumber = arguments[0];
|
||||
var pin = new mraa.Gpio(pinNumber);
|
||||
let pinNumber = arguments[0];
|
||||
let pin = new mraa.Gpio(pinNumber);
|
||||
pin.dir(mraa.DIR_IN);
|
||||
console.log('Gpio ' + pinNumber + ' = ' + pin.read());
|
||||
}
|
||||
@@ -61,9 +63,9 @@ function onPinLevelChange() {
|
||||
}
|
||||
|
||||
function monitorPin() {
|
||||
var pinNumber = arguments[0];
|
||||
let pinNumber = arguments[0];
|
||||
try {
|
||||
var pin = new mraa.Gpio(pinNumber);
|
||||
let pin = new mraa.Gpio(pinNumber);
|
||||
pin.dir(mraa.DIR_IN);
|
||||
pin.isr(mraa.EDGE_BOTH, onPinLevelChange);
|
||||
rl.question('Press ENTER to stop', function(answer) {
|
||||
@@ -71,37 +73,37 @@ function monitorPin() {
|
||||
pin.isrExit();
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err.message);
|
||||
console.log(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
const args = process.argv;
|
||||
const argc = args.length;
|
||||
|
||||
if (argc >= 3) {
|
||||
const cmd = args[2];
|
||||
if (argc > 3) {
|
||||
const pinNumber = parseInt(args[3]);
|
||||
}
|
||||
|
||||
switch (args[2]) {
|
||||
case "version":
|
||||
getVersion();
|
||||
break;
|
||||
case "get":
|
||||
var pinNumber = parseInt(args[3]);
|
||||
getPin(pinNumber);
|
||||
break;
|
||||
case "set":
|
||||
var pinNumber = parseInt(args[3]);
|
||||
var pinValue = parseInt(args[4]);
|
||||
getPin(pinNumber, pinValue);
|
||||
break;
|
||||
case "monitor":
|
||||
var pinNumber = parseInt(args[3]);
|
||||
monitorPin(pinNumber);
|
||||
break;
|
||||
default:
|
||||
console.log("Invalid command " + args[2]);
|
||||
break;
|
||||
case "version":
|
||||
getVersion();
|
||||
break;
|
||||
case "get":
|
||||
getPin(pinNumber);
|
||||
break;
|
||||
case "set":
|
||||
let pinValue = parseInt(args[4]);
|
||||
getPin(pinNumber, pinValue);
|
||||
break;
|
||||
case "monitor":
|
||||
monitorPin(pinNumber);
|
||||
break;
|
||||
default:
|
||||
console.log("Invalid command " + args[2]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
console.log("Command not specified");
|
||||
printUsage();
|
||||
}
|
||||
|
||||
|
@@ -22,27 +22,29 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa');
|
||||
"use strict";
|
||||
|
||||
const mraa = require('mraa');
|
||||
|
||||
// GPIO-PIN
|
||||
m.gpioFromDesc("gpio-1");
|
||||
mraa.gpioFromDesc("gpio-1");
|
||||
// GPIO-RAW-RAWPIN
|
||||
m.gpioFromDesc("gpio-raw-131");
|
||||
mraa.gpioFromDesc("gpio-raw-131");
|
||||
// AIO-PIN
|
||||
m.aioFromDesc("aio-1");
|
||||
mraa.aioFromDesc("aio-1");
|
||||
//PWM-PIN
|
||||
m.pwmFromDesc("pwm-6");
|
||||
mraa.pwmFromDesc("pwm-6");
|
||||
// PWM-RAW-CHIPID-PIN
|
||||
m.pwmFromDesc("pwm-raw-0-1")
|
||||
mraa.pwmFromDesc("pwm-raw-0-1")
|
||||
// UART-INDEX: the index is the one represented internally in the uart_dev array
|
||||
m.uartFromDesc("uart-0");
|
||||
mraa.uartFromDesc("uart-0");
|
||||
// UART-RAW-PATH
|
||||
m.uartFromDesc("uart-raw-/dev/ttyS0");
|
||||
mraa.uartFromDesc("uart-raw-/dev/ttyS0");
|
||||
// SPI-INDEX: same as UART
|
||||
m.spiFromDesc("spi-0");
|
||||
mraa.spiFromDesc("spi-0");
|
||||
// SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
|
||||
m.spiFromDesc("spi-raw-0-1");
|
||||
mraa.spiFromDesc("spi-raw-0-1");
|
||||
// I2C-INDEX: same as UART
|
||||
m.i2cFromDesc("i2c-0");
|
||||
mraa.i2cFromDesc("i2c-0");
|
||||
// I2C-RAW-BUS
|
||||
m.i2cFromDesc("i2c-raw-0");
|
||||
mraa.i2cFromDesc("i2c-raw-0");
|
||||
|
@@ -1,16 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var m = require('mraa')
|
||||
"use strict";
|
||||
|
||||
function h() {
|
||||
console.log("HELLO!!!!")
|
||||
const mraa = require('mraa');
|
||||
|
||||
function hello() {
|
||||
console.log("HELLO!!!!");
|
||||
}
|
||||
|
||||
x = new m.Gpio(14)
|
||||
x.isr(m.EDGE_BOTH, h)
|
||||
let pin = new mraa.Gpio(14);
|
||||
pin.isr(mraa.EDGE_BOTH, hello);
|
||||
|
||||
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)
|
||||
console.log("Waiting for an interrupt at GPIO pin " + pin.getPin() + "...");
|
||||
}, 10000);
|
||||
|
@@ -22,13 +22,15 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
"use strict";
|
||||
|
||||
x = new m.I2c(0)
|
||||
x.address(0x62)
|
||||
x.writeReg(0, 0)
|
||||
x.writeReg(1, 0)
|
||||
const mraa = require('mraa'); //require mraa
|
||||
|
||||
x.writeReg(0x08, 0xAA)
|
||||
x.writeReg(0x04, 255)
|
||||
x.writeReg(0x02, 255)
|
||||
let i2cDevice = new mraa.I2c(0);
|
||||
i2cDevice.address(0x62);
|
||||
i2cDevice.writeReg(0, 0);
|
||||
i2cDevice.writeReg(1, 0);
|
||||
|
||||
i2cDevice.writeReg(0x08, 0xAA);
|
||||
i2cDevice.writeReg(0x04, 255);
|
||||
i2cDevice.writeReg(0x02, 255);
|
||||
|
@@ -24,15 +24,15 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
|
||||
x = new m.Spi(0)
|
||||
buf = new Buffer(4)
|
||||
buf[0] = 0xf4
|
||||
buf[1] = 0x2e
|
||||
buf[2] = 0x3e
|
||||
buf[3] = 0x4e
|
||||
buf2 = x.write(buf)
|
||||
console.log("Sent: " + buf.toString('hex') + ". Received: " + buf2.toString('hex'))
|
||||
"use strict";
|
||||
|
||||
const mraa = require('mraa'); //require mraa
|
||||
|
||||
let spiDevice = new mraa.Spi(0);
|
||||
let buf = new Buffer(4);
|
||||
buf[0] = 0xf4;
|
||||
buf[1] = 0x2e;
|
||||
buf[2] = 0x3e;
|
||||
buf[3] = 0x4e;
|
||||
let buf2 = spiDevice.write(buf);
|
||||
console.log("Sent: " + buf.toString('hex') + ". Received: " + buf2.toString('hex'));
|
||||
|
@@ -22,33 +22,35 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var m = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + m.getVersion());
|
||||
u = new m.Uart(0)
|
||||
"use strict";
|
||||
|
||||
const mraa = require('mraa'); //require mraa
|
||||
console.log('MRAA Version: ' + mraa.getVersion());
|
||||
let uart = new mraa.Uart(0);
|
||||
|
||||
console.log("Note: connect Rx and Tx of UART with a wire before use");
|
||||
|
||||
function sleep(delay) {
|
||||
delay += new Date().getTime();
|
||||
while (new Date() < delay) { }
|
||||
delay += new Date().getTime();
|
||||
while (new Date() < delay) {}
|
||||
}
|
||||
|
||||
console.log("Set UART parameters");
|
||||
|
||||
u.setBaudRate(115200);
|
||||
u.setMode(8, 0, 1);
|
||||
u.setFlowcontrol(false, false);
|
||||
uart.setBaudRate(115200);
|
||||
uart.setMode(8, 0, 1);
|
||||
uart.setFlowcontrol(false, false);
|
||||
sleep(200);
|
||||
|
||||
console.log("First write-read circle:");
|
||||
|
||||
u.writeStr("test\n");
|
||||
uart.writeStr("test\n");
|
||||
sleep(200);
|
||||
console.log(u.readStr(6));
|
||||
console.log(uart.readStr(6));
|
||||
sleep(200);
|
||||
|
||||
console.log("Second write-read circle:");
|
||||
|
||||
u.writeStr("2nd test\n");
|
||||
uart.writeStr("2nd test\n");
|
||||
sleep(200);
|
||||
console.log(u.readStr(10));
|
||||
console.log(uart.readStr(10));
|
||||
|
@@ -144,7 +144,6 @@ i2c_set_exit:
|
||||
void
|
||||
i2c_detect_devices(int bus)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_i2c_context i2c = mraa_i2c_init(bus);
|
||||
if (i2c == NULL) {
|
||||
return;
|
||||
@@ -167,16 +166,16 @@ int
|
||||
process_command(int argc, char** argv)
|
||||
{
|
||||
int status = 0;
|
||||
if (strcmp(argv[1], "help") == 0) {
|
||||
if (strncmp(argv[1], "help", strlen("help") + 1) == 0) {
|
||||
print_help();
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "version") == 0) {
|
||||
} else if (strncmp(argv[1], "version", strlen("version") + 1) == 0) {
|
||||
print_version();
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "list") == 0) {
|
||||
} else if (strncmp(argv[1], "list", strlen("list") + 1) == 0) {
|
||||
print_busses();
|
||||
return 0;
|
||||
} else if (strcmp(argv[1], "detect") == 0) {
|
||||
} else if (strncmp(argv[1], "detect", strlen("detect") + 1) == 0) {
|
||||
if (argc == 3) {
|
||||
int bus = strtol(argv[2], NULL, 0);
|
||||
i2c_detect_devices(bus);
|
||||
@@ -185,10 +184,11 @@ process_command(int argc, char** argv)
|
||||
print_command_error();
|
||||
return 1;
|
||||
}
|
||||
} else if ((strcmp(argv[1], "get") == 0) || (strcmp(argv[1], "getrpt") == 0)) {
|
||||
} else if ((strncmp(argv[1], "get", strlen("get") + 1) == 0) ||
|
||||
(strncmp(argv[1], "getrpt", strlen("getrpt") + 1) == 0)) {
|
||||
if (argc == 5) {
|
||||
int interation = 0;
|
||||
mraa_boolean_t should_repeat = strcmp(argv[1], "getrpt") == 0;
|
||||
mraa_boolean_t should_repeat = strncmp(argv[1], "getrpt", strlen("getrpt") + 1) == 0;
|
||||
int bus = strtol(argv[2], NULL, 0);
|
||||
uint8_t device_address = strtol(argv[3], NULL, 0);
|
||||
uint8_t register_address = strtol(argv[4], NULL, 0);
|
||||
@@ -212,7 +212,7 @@ process_command(int argc, char** argv)
|
||||
status = 1;
|
||||
}
|
||||
return status;
|
||||
} else if ((strcmp(argv[1], "set") == 0)) {
|
||||
} else if ((strncmp(argv[1], "set", strlen("set") + 1) == 0)) {
|
||||
if (argc == 6) {
|
||||
int bus = strtol(argv[2], NULL, 0);
|
||||
uint8_t device_address = strtol(argv[3], NULL, 0);
|
||||
@@ -247,12 +247,14 @@ run_interactive_mode()
|
||||
fprintf(stdout, "Command: ");
|
||||
fgets(command, 80, stdin);
|
||||
command[strlen(command) - 1] = 0;
|
||||
if (strcmp(command, "q") == 0)
|
||||
if (strncmp(command, "q", strlen("q") + 1) == 0)
|
||||
return;
|
||||
char* str = strtok(command, " ");
|
||||
int len = 0;
|
||||
while (str != NULL) {
|
||||
arg = malloc(strlen(str) + 1);
|
||||
argv[argc++] = strcpy(arg, str);
|
||||
len = strlen(str) + 1;
|
||||
arg = malloc(len);
|
||||
argv[argc++] = strncpy(arg, str, len);
|
||||
str = strtok(NULL, " ");
|
||||
}
|
||||
process_command(argc, argv);
|
||||
|
301
examples/mraa-uart.c
Normal file
301
examples/mraa-uart.c
Normal file
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Author: Tapani Utriainen <tapani@technexion.com>
|
||||
* Copyright (c) 2017 TechNexion Ltd.
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
static const char *undefined = "<undefined>";
|
||||
|
||||
static const char paritymode_table[] = {
|
||||
[MRAA_UART_PARITY_NONE] = 'N',
|
||||
[MRAA_UART_PARITY_EVEN] = 'E',
|
||||
[MRAA_UART_PARITY_ODD] = 'O',
|
||||
[MRAA_UART_PARITY_MARK] = 'M',
|
||||
[MRAA_UART_PARITY_SPACE] = 'S'
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
mraa_uart_context
|
||||
uarttool_find(const char *str) {
|
||||
/* Try to find the uart by name, then by index, by devpath and as last resort create a raw uart */
|
||||
int uart_index = mraa_uart_lookup(str);
|
||||
if (uart_index < 0) {
|
||||
/* name lookup failed, try index if the first character is a digit */
|
||||
if (isdigit(*str)) {
|
||||
uart_index = atoi(str);
|
||||
} else {
|
||||
const char *devpath;
|
||||
int number_of_uarts = mraa_get_uart_count();
|
||||
for (uart_index = 0; uart_index < number_of_uarts; uart_index++) {
|
||||
mraa_result_t res = mraa_uart_settings(uart_index, NULL, &devpath, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (res == MRAA_SUCCESS && devpath != NULL && !strcmp(devpath, str)) break;
|
||||
}
|
||||
if (uart_index >= number_of_uarts) {
|
||||
return mraa_uart_init_raw(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mraa_uart_init(uart_index);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
double
|
||||
now(void) {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (double)tv.tv_usec * 1e-6 + (double)tv.tv_sec;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void
|
||||
uarttool_read_and_print(mraa_uart_context uart, double receive_timeout) {
|
||||
char buf;
|
||||
do {
|
||||
double start = now();
|
||||
if (mraa_uart_data_available(uart, 1.0 + receive_timeout * 1000.0)) {
|
||||
mraa_uart_read(uart, &buf, 1);
|
||||
putchar(buf);
|
||||
fflush(stdout);
|
||||
}
|
||||
receive_timeout -= now() - start;
|
||||
} while (receive_timeout > 0.0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void
|
||||
uarttool_usage(const char *name) {
|
||||
printf("Usage: %s { list | dev device } [ baud bps ] [ databits d ] [ parity p ] [ stopbits s ] [ ctsrts mode ] [ send string ] [ recv timeout ] [ show ]\n\n", name);
|
||||
printf("Simple tool to test UART functionality. Needs either list or dev arguments, the others are optional\n");
|
||||
printf(" list : lists uarts on the system (non intrusive)\n");
|
||||
printf(" dev : select uart device, can be by name, by device name or by index (as listed in list)\n");
|
||||
printf(" baud : set the baudrate to given parameter, in bits per second\n");
|
||||
printf(" parity : set parity mode to given parameter - can be E, O, or N\n");
|
||||
printf(" stopbits : set the number of stopbits - can be 1 or 2\n");
|
||||
printf(" ctsrts : set CTS/RTS flow control to either on or off\n");
|
||||
printf(" send : transmits a string\n");
|
||||
printf(" recv : reads data on uart for timeout seconds, and displays the result on stdout\n");
|
||||
printf(" show : show settings of selected uart\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int
|
||||
main(int argc, const char** argv) {
|
||||
mraa_uart_context uart = NULL;
|
||||
int uart_index, i;
|
||||
|
||||
int baudrate = 115200, stopbits = 1, databits = 8;
|
||||
mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE;
|
||||
unsigned int ctsrts = FALSE, xonxoff = FALSE;
|
||||
const char *name = NULL, *dev = NULL;
|
||||
|
||||
double recieve_timeout = 0.0;
|
||||
int recieve = FALSE; /* whether we are requested to receive */
|
||||
int send = FALSE; /* whether we are requested to send or not */
|
||||
const char *to_send; /* data to send, assigned during parsing of command line */
|
||||
int show = FALSE; /* whether to show uart settings after everything else*/
|
||||
|
||||
/* Initialize MRAA. Init is done automatically if libmraa is compiled
|
||||
with a compiler that supports __attribute__((constructor)), like
|
||||
GCC and CLANG
|
||||
*/
|
||||
mraa_init();
|
||||
|
||||
if (argc <= 1) {
|
||||
uarttool_usage(argv[0]);
|
||||
} else
|
||||
if (!strcmp(argv[1], "list")) {
|
||||
int number_of_uarts = mraa_get_uart_count();
|
||||
for (uart_index = 0; uart_index < number_of_uarts; uart_index++) {
|
||||
mraa_result_t res = mraa_uart_settings(uart_index, &name, &dev, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
|
||||
if (res == MRAA_SUCCESS) {
|
||||
if (name == NULL) name = undefined;
|
||||
if (dev == NULL) dev = undefined;
|
||||
printf("%i. %-12s %-16s %7i %i%c%i %s %s\n", uart_index, name, dev, baudrate, databits, paritymode_table[parity], stopbits, ctsrts?"CTSRTS":"(none)", xonxoff?"XONXOFF":"(none) ");
|
||||
} else {
|
||||
printf("%i. ---- error reading uart information ----\n", uart_index);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i=1; i<argc; i++) {
|
||||
if (!strcmp(argv[i], "dev")) {
|
||||
uart = uarttool_find(argv[i+1]);
|
||||
if (uart == NULL) {
|
||||
fprintf(stderr, "%s : cannot find uart %s\n", argv[0], argv[i+1]);
|
||||
break;
|
||||
}
|
||||
dev = mraa_uart_get_dev_path(uart);
|
||||
mraa_result_t res = mraa_uart_settings(-1, &dev, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
|
||||
if (res != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "warning: problems accessing uart settings, attempting to continue\n");
|
||||
}
|
||||
} else
|
||||
|
||||
/* Baudrate setting */
|
||||
if (!strcmp(argv[i], "baud") || !strcmp(argv[i], "baudrate")) {
|
||||
if (i+1 >= argc || !isdigit(argv[i+1][0])) {
|
||||
fprintf(stderr, "%s : %s needs number as argument\n", argv[0], argv[i]);
|
||||
break;
|
||||
}
|
||||
baudrate = atoi(argv[i+1]);
|
||||
if (uart != NULL) {
|
||||
mraa_uart_set_baudrate(uart, baudrate);
|
||||
}
|
||||
i++;
|
||||
} else
|
||||
|
||||
/* Accept a few variants of the flow control setting name */
|
||||
if (!strcmp(argv[i], "ctsrts") || !strcmp(argv[i], "rtscts") || !strcmp(argv[i], "crtscts")) {
|
||||
if (i+1 >= argc || argv[i+1][0] != 'o') {
|
||||
fprintf(stderr, "%s : ctsrts needs either on or off as argument\n", argv[0]);
|
||||
break;
|
||||
}
|
||||
ctsrts = !strcmp(argv[i+1], "on") ? 1u : 0u;
|
||||
xonxoff = 0u;
|
||||
if (uart != NULL) {
|
||||
mraa_uart_set_flowcontrol(uart, xonxoff, ctsrts);
|
||||
}
|
||||
i++;
|
||||
} else
|
||||
|
||||
/* Number of stopbits */
|
||||
if (!strcmp(argv[i], "stopbits")) {
|
||||
if (i+1 >= argc || !isdigit(argv[i+1][0])) {
|
||||
fprintf(stderr, "%s : %s needs number as argument\n", argv[0], argv[i]);
|
||||
break;
|
||||
}
|
||||
stopbits = atoi(argv[i+1]);
|
||||
if (stopbits < 1 || stopbits > 2) {
|
||||
stopbits = 1;
|
||||
fprintf(stderr, "%s : invalid number of stopbits, bust be 1 or 2\n", argv[0]);
|
||||
}
|
||||
if (uart != NULL) {
|
||||
mraa_uart_set_mode(uart, databits, parity, stopbits);
|
||||
}
|
||||
i++;
|
||||
} else
|
||||
|
||||
/* Databits */
|
||||
if (!strcmp(argv[i], "databits") || !strcmp(argv[i], "bytesize")) {
|
||||
if (i+1 >= argc || !isdigit(argv[i+1][0])) {
|
||||
fprintf(stderr, "%s : %s needs number as argument\n", argv[0], argv[i]);
|
||||
break;
|
||||
}
|
||||
databits = atoi(argv[i+1]);
|
||||
if (uart != NULL) {
|
||||
mraa_uart_set_mode(uart, databits, parity, stopbits);
|
||||
}
|
||||
i++;
|
||||
} else
|
||||
|
||||
/* Parity mode, uses paritmode array */
|
||||
if (!strcmp(argv[i], "paritybits") || !strcmp(argv[i], "parity")) {
|
||||
int j;
|
||||
if (i+1 >= argc) {
|
||||
fprintf(stderr, "%s : %s needs 'O','E' or 'N' as argument\n", argv[0], argv[i]);
|
||||
break;
|
||||
}
|
||||
/* Even if there were gaps between declared array elements, they would be initialized to 0 compile time */
|
||||
for (j=0; j<sizeof(paritymode_table); j++) {
|
||||
if (paritymode_table[j] == toupper(argv[i+1][0])) {
|
||||
parity = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j >= sizeof(paritymode_table)) {
|
||||
fprintf(stderr, "warning: unrecognized parity mode %s (ignoring)\n", argv[i+1]);
|
||||
}
|
||||
if (uart != NULL) {
|
||||
mraa_uart_set_mode(uart, databits, parity, stopbits);
|
||||
}
|
||||
i++;
|
||||
} else
|
||||
|
||||
/* Show settings */
|
||||
if (!strcmp(argv[i], "show")) {
|
||||
show = TRUE;
|
||||
} else
|
||||
|
||||
/* Send data */
|
||||
if (!strcmp(argv[i], "send")) {
|
||||
if (i+1 >= argc) {
|
||||
fprintf(stderr, "%s : %s needs string as argument\n", argv[0], argv[i]);
|
||||
break;
|
||||
}
|
||||
send = TRUE;
|
||||
to_send = argv[i+1];
|
||||
i++;
|
||||
} else
|
||||
|
||||
if (!strcmp(argv[i], "receive") || !strcmp(argv[i], "recieve") || !strcmp(argv[i], "recv")) {
|
||||
if (i+1 >= argc) {
|
||||
fprintf(stderr, "%s : %s needs a timeout (in seconds, fractional ok) as argument\n", argv[0], argv[i]);
|
||||
break;
|
||||
}
|
||||
recieve = TRUE;
|
||||
recieve_timeout = atof(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == argc && uart != NULL) {
|
||||
if (send) {
|
||||
mraa_uart_write(uart, to_send, strlen(to_send)+1);
|
||||
}
|
||||
|
||||
if (recieve) {
|
||||
uarttool_read_and_print(uart, recieve_timeout);
|
||||
}
|
||||
|
||||
if (show) {
|
||||
if (recieve) putchar('\n');
|
||||
dev = mraa_uart_get_dev_path(uart);
|
||||
mraa_uart_settings(-1, &dev, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
|
||||
printf("%-12s %-16s %7i %i%c%i %s %s\n", name!=NULL?name:undefined, dev, baudrate, databits, paritymode_table[parity], stopbits, ctsrts?"CTS/RTS":"(no hw)", xonxoff?"XONXOFF":"(no sw)");
|
||||
}
|
||||
} else {
|
||||
uarttool_usage(argv[0]);
|
||||
}
|
||||
}
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
26
examples/platform/intel-aero.json
Normal file
26
examples/platform/intel-aero.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"platform":[
|
||||
{
|
||||
"id":301,
|
||||
"name":"Intel Aero",
|
||||
"pin_count": 0,
|
||||
"gpio_count": 0,
|
||||
"i2c_count": 1,
|
||||
"aio_count": 0,
|
||||
"spi_count": 1,
|
||||
"uart_count": 0,
|
||||
}
|
||||
],
|
||||
"layout":[
|
||||
],
|
||||
"GPIO":[
|
||||
],
|
||||
"I2C": [
|
||||
{ "index": 0, "bus" : 2, "default":true }
|
||||
],
|
||||
"SPI": [
|
||||
{ "index":0, "bus": 3, "slaveselect": 0, "default": true}
|
||||
],
|
||||
|
||||
}
|
@@ -1,73 +1,74 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"platform":[
|
||||
{ "id":300,
|
||||
"name":"Turbot",
|
||||
"pin_count": 28,
|
||||
"gpio_count": 28,
|
||||
"i2c_count": 1,
|
||||
"aio_count": 0,
|
||||
"spi_count": 1,
|
||||
"uart_count": 1,
|
||||
"pwmDefPeriod":500,
|
||||
"pwmMaxPeriod":1000000000,
|
||||
"pwmMinPeriod":1
|
||||
"version": "1.1.0",
|
||||
"platform": [
|
||||
{
|
||||
"id":300,
|
||||
"name":"Turbot",
|
||||
"pin_count": 28,
|
||||
"gpio_count": 28,
|
||||
"i2c_count": 1,
|
||||
"aio_count": 0,
|
||||
"spi_count": 1,
|
||||
"uart_count": 1,
|
||||
"pwmDefPeriod":500,
|
||||
"pwmMaxPeriod":1000000000,
|
||||
"pwmMinPeriod":1
|
||||
}
|
||||
],
|
||||
"layout":[
|
||||
{"label": "INVALID", "invalid": true},
|
||||
{"label": "GND"},
|
||||
{"label": "GND"},
|
||||
{"label": "5v"},
|
||||
{"label": "3.3v"},
|
||||
{"label": "SPI_CS"},
|
||||
{"label": "UART1TX"},
|
||||
{"label": "SPIMISO"},
|
||||
{"label": "UART1RX"},
|
||||
{"label": "SPIMOSI"},
|
||||
{"label": "UART1CT"},
|
||||
{"label": "SPI_CLK"},
|
||||
{"label": "UART1RT"},
|
||||
{"label": "I2C_SCL"},
|
||||
{"label": "I2S_CLK"},
|
||||
{"label": "I2C_SDA"},
|
||||
{"label": "I2S_FRM"},
|
||||
{"label": "UART2TX"},
|
||||
{"label": "I2S_DO"},
|
||||
{"label": "UART2RX"},
|
||||
{"label": "I2S_DI"},
|
||||
{"label": "S5_0"},
|
||||
{"label": "PWM0"},
|
||||
{"label": "S5_1"},
|
||||
{"label": "PWM1"},
|
||||
{"label": "S5_4"},
|
||||
{"label": "I2S_MCLK"},
|
||||
{"label": "S5_22"}
|
||||
"layout": [
|
||||
{"label": "INVALID", "invalid": true},
|
||||
{"label": "GND"},
|
||||
{"label": "GND"},
|
||||
{"label": "5v"},
|
||||
{"label": "3.3v"},
|
||||
{"label": "SPI_CS"},
|
||||
{"label": "UART1TX"},
|
||||
{"label": "SPIMISO"},
|
||||
{"label": "UART1RX"},
|
||||
{"label": "SPIMOSI"},
|
||||
{"label": "UART1CT"},
|
||||
{"label": "SPI_CLK"},
|
||||
{"label": "UART1RT"},
|
||||
{"label": "I2C_SCL"},
|
||||
{"label": "I2S_CLK"},
|
||||
{"label": "I2C_SDA"},
|
||||
{"label": "I2S_FRM"},
|
||||
{"label": "UART2TX"},
|
||||
{"label": "I2S_DO"},
|
||||
{"label": "UART2RX"},
|
||||
{"label": "I2S_DI"},
|
||||
{"label": "S5_0"},
|
||||
{"label": "PWM0"},
|
||||
{"label": "S5_1"},
|
||||
{"label": "PWM1"},
|
||||
{"label": "S5_4"},
|
||||
{"label": "I2S_MCLK"},
|
||||
{"label": "S5_22"}
|
||||
],
|
||||
"GPIO": [
|
||||
{ "index": 10, "rawpin": 483 },
|
||||
{ "index": 12, "rawpin": 482 },
|
||||
{ "index": 14, "rawpin": 472 },
|
||||
{ "index": 16, "rawpin": 473 },
|
||||
{ "index": 18, "rawpin": 475 },
|
||||
{ "index": 20, "rawpin": 474 },
|
||||
{ "index": 21, "rawpin": 338 },
|
||||
{ "index": 23, "rawpin": 339 },
|
||||
{ "index": 25, "rawpin": 340 },
|
||||
{ "index": 26, "rawpin": 509 },
|
||||
{ "index": 27, "rawpin": 360 }
|
||||
],
|
||||
"GPIO":[
|
||||
{ "index": 10, "rawpin": 483 },
|
||||
{ "index": 12, "rawpin": 482 },
|
||||
{ "index": 14, "rawpin": 472 },
|
||||
{ "index": 16, "rawpin": 473 },
|
||||
{ "index": 18, "rawpin": 475 },
|
||||
{ "index": 20, "rawpin": 474 },
|
||||
{ "index": 21, "rawpin": 338 },
|
||||
{ "index": 23, "rawpin": 339 },
|
||||
{ "index": 25, "rawpin": 340 },
|
||||
{ "index": 26, "rawpin": 509 },
|
||||
{ "index": 27, "rawpin": 360 }
|
||||
"I2C": [
|
||||
{ "sclpin":13, "sdapin":15, "bus": 9, "index": 0, "default":true }
|
||||
],
|
||||
"I2C": [
|
||||
{ "sclpin":13, "sdapin":15, "rawpin": 0, "index": 0, "default":true }
|
||||
],
|
||||
"PWM": [
|
||||
{ "index":22, "rawpin":0, "chipID":0},
|
||||
{ "index":24, "rawpin":0, "chipID":1 }
|
||||
],
|
||||
"SPI": [
|
||||
{ "index":0, "chipID": 0, "clock": 11, "miso": 7, "mosi": 9, "chipselect": 5, "default": true}
|
||||
],
|
||||
"UART":[
|
||||
{ "index":0, "chipID":0, "rawpin":0, "path":"/dev/ttyS0", "default":true}
|
||||
]
|
||||
"PWM": [
|
||||
{ "index":22, "rawpin":0, "chipID":0},
|
||||
{ "index":24, "rawpin":0, "chipID":1 }
|
||||
],
|
||||
"SPI": [
|
||||
{ "index":0, "bus": 0, "slaveselect": 0, "clock": 11, "miso": 7, "mosi": 9, "chipselect": 5, "default": true}
|
||||
],
|
||||
"UART": [
|
||||
{ "index":0, "chipID":0, "rawpin":0, "path":"/dev/ttyS0", "default":true}
|
||||
]
|
||||
}
|
||||
|
40
examples/python/mcp3004.py
Normal file
40
examples/python/mcp3004.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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
|
||||
|
||||
# Read from MCP3004 ADC pin 0 in single ended mode
|
||||
import mraa
|
||||
import time
|
||||
|
||||
dev = mraa.Spi(0)
|
||||
txbuf = bytearray(3)
|
||||
txbuf[0] = 0x01
|
||||
txbuf[1] = 0x80
|
||||
txbuf[2] = 0x00
|
||||
|
||||
while True:
|
||||
rxbuf = dev.write(txbuf)
|
||||
value = ((rxbuf[1] & 0x03) << 8) | rxbuf[2]
|
||||
print value
|
||||
time.sleep(0.5)
|
||||
|
@@ -85,4 +85,5 @@ main(int argc, char** argv)
|
||||
mraa_spi_stop(spi);
|
||||
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@@ -33,7 +33,6 @@ main(int argc, char** argv)
|
||||
//! [Interesting]
|
||||
mraa_spi_context spi;
|
||||
spi = mraa_spi_init(0);
|
||||
unsigned int response = 0;
|
||||
printf("Hello, SPI initialised\n");
|
||||
uint8_t data[] = { 0x00, 100 };
|
||||
uint8_t* recv;
|
||||
|
@@ -1,10 +1,11 @@
|
||||
add_executable (imraa imraa.c)
|
||||
add_executable (imraa imraa.c imraa_arduino.c imraa_io.c imraa_lock.c)
|
||||
|
||||
include_directories (${PROJECT_SOURCE_DIR}/api)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/include)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/api/mraa)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/imraa)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
|
||||
|
||||
find_package (JSON-C REQUIRED)
|
||||
include_directories (${JSON-C_INCLUDE_DIR})
|
||||
|
519
imraa/imraa.c
519
imraa/imraa.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Author: Longwei Su <lsu@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
* Copyright (c) 2015-2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -29,395 +29,23 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <json-c/json.h>
|
||||
#include <libudev.h>
|
||||
#include <error.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <mraa/uart.h>
|
||||
#include <mraa/gpio.h>
|
||||
#include <mraa/i2c.h>
|
||||
#include <mraa/pwm.h>
|
||||
#include <json-c/json.h>
|
||||
|
||||
#include <argp.h>
|
||||
|
||||
#include <mraa_internal.h>
|
||||
|
||||
#include <imraa_arduino.h>
|
||||
#include <imraa_io.h>
|
||||
#include <imraa_lock.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)
|
||||
imraa_check_version(struct json_object* jobj)
|
||||
{
|
||||
struct json_object* imraa_version;
|
||||
if (json_object_object_get_ex(jobj, "version", &imraa_version) == true) {
|
||||
@@ -434,58 +62,82 @@ check_version(struct json_object* jobj)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
print_version()
|
||||
const char *argp_program_version = "imraa version 2.0";
|
||||
const char *argp_program_bug_address = "http://github.com/intel-iot-devkit/mraa/issues";
|
||||
|
||||
static char doc[] = "somestuff";
|
||||
|
||||
static char args_doc[] = "-i imraa.conf";
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{"verbose", 'v', 0, 0, "Produce verbose output" },
|
||||
{"quiet", 'q', 0, 0, "Don't produce any output" },
|
||||
{"silent", 's', 0, OPTION_ALIAS },
|
||||
{"force", 'f', 0, 0, "Force update" },
|
||||
{"arduino", 'a', 0, 0, "Arduino detection" },
|
||||
{"input", 'i', "FILE", 0,
|
||||
"configuration file" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
struct arguments
|
||||
{
|
||||
fprintf(stdout, "Version %s on %s\n", mraa_get_version(), mraa_get_platform_name());
|
||||
char *args[2];
|
||||
int silent, verbose, force, arduino;
|
||||
char *input_file;
|
||||
};
|
||||
|
||||
static error_t
|
||||
parse_opt(int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
|
||||
/* Get the input argument from argp_parse, which we
|
||||
know is a pointer to our arguments structure. */
|
||||
struct arguments *arguments = state->input;
|
||||
|
||||
switch(key) {
|
||||
case 'q': case 's':
|
||||
arguments->silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
arguments->verbose = 1;
|
||||
break;
|
||||
case 'a':
|
||||
arguments->arduino = 1;
|
||||
break;
|
||||
case 'f':
|
||||
arguments->force = 1;
|
||||
break;
|
||||
case 'i':
|
||||
arguments->input_file = arg;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
break;
|
||||
case ARGP_KEY_END:
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
static struct argp argp = { options, parse_opt, args_doc, doc};
|
||||
|
||||
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;
|
||||
struct arguments arguments;
|
||||
|
||||
if (argc > 2) {
|
||||
print_command_error();
|
||||
}
|
||||
arguments.silent = 0;
|
||||
arguments.verbose = 0;
|
||||
arguments.force = 0;
|
||||
arguments.input_file = IMRAA_CONF_FILE;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
FILE* fh = fopen(imraa_conf_file, "r");
|
||||
FILE* fh = fopen(arguments.input_file, "r");
|
||||
if (fh == NULL) {
|
||||
fprintf(stderr, "Failed to open configuration file\n");
|
||||
return EXIT_FAILURE;
|
||||
@@ -497,28 +149,33 @@ main(int argc, char** argv)
|
||||
buffer = calloc(fsize, sizeof(char));
|
||||
if (buffer != NULL) {
|
||||
int result = fread(buffer, sizeof(char), fsize, fh);
|
||||
if (result != fsize) {
|
||||
printf("imraa conf reading error");
|
||||
if (result != (fsize - 1)) {
|
||||
printf("imraa conf reading error\n");
|
||||
}
|
||||
} else {
|
||||
printf("imraa read_conf buffer can't allocated\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// call reduced imraa_init (not that mraa_init) will already have been called
|
||||
imraa_init();
|
||||
|
||||
json_object* jobj = json_tokener_parse(buffer);
|
||||
if (check_version(jobj) != 0) {
|
||||
if (imraa_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);
|
||||
|
||||
if (arguments.arduino) {
|
||||
imraa_handle_subplatform(jobj, arguments.force);
|
||||
}
|
||||
|
||||
if (type == MRAA_NULL_PLATFORM || type == MRAA_UNKNOWN_PLATFORM) {
|
||||
printf("imraa: attempting to do IO pinmuxing on null/unkown platform\n");
|
||||
}
|
||||
imraa_handle_IO(jobj);
|
||||
}
|
||||
|
||||
fclose(fh);
|
||||
json_object_put(jobj);
|
||||
free(buffer);
|
||||
|
@@ -1,12 +1,8 @@
|
||||
{
|
||||
"version": "0.9.6",
|
||||
"version": "2.0",
|
||||
"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"}
|
||||
]
|
||||
}
|
||||
|
12
imraa/imraa.io.conf
Normal file
12
imraa/imraa.io.conf
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "1.4.0",
|
||||
"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", "user": "brendan", "group": "brendan"},
|
||||
{"type":"i2c", "index":0, "raw": false, "label": "i2c-0", "user": "brendan", "group": "user"}
|
||||
]
|
||||
}
|
@@ -3,7 +3,7 @@ Description=imraa
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/imraa
|
||||
ExecStart=/usr/bin/imraa -a
|
||||
|
||||
[Install]
|
||||
WantedBy = multi-user.target
|
||||
WantedBy=multi-user.target
|
||||
|
279
imraa/imraa_arduino.c
Normal file
279
imraa/imraa_arduino.c
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Author: Longwei Su <lsu@ics.com>
|
||||
* Copyright (c) 2015-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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <json-c/json.h>
|
||||
#include <libudev.h>
|
||||
|
||||
#include <argp.h>
|
||||
#include <error.h>
|
||||
|
||||
#include <mraa/uart.h>
|
||||
#include <mraa/gpio.h>
|
||||
#include <mraa/i2c.h>
|
||||
#include <mraa/pwm.h>
|
||||
|
||||
#include <mraa_internal.h>
|
||||
#include <imraa_lock.h>
|
||||
|
||||
const char*
|
||||
imraa_get_101_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_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");
|
||||
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_get_101_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");
|
||||
}
|
||||
}
|
||||
}
|
29
imraa/imraa_arduino.h
Normal file
29
imraa/imraa_arduino.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
void imraa_handle_subplatform(struct json_object* jobj, bool force_update);
|
||||
|
||||
|
178
imraa/imraa_io.c
Normal file
178
imraa/imraa_io.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2015-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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <error.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <json-c/json.h>
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
#include <mraa/uart.h>
|
||||
#include <mraa/gpio.h>
|
||||
#include <mraa/i2c.h>
|
||||
#include <mraa/pwm.h>
|
||||
|
||||
#include <mraa_internal.h>
|
||||
|
||||
#include <imraa_arduino.h>
|
||||
|
||||
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
||||
#define MAX_SIZE 64
|
||||
|
||||
typedef struct mraa_io_objects_t {
|
||||
const char* type;
|
||||
int index;
|
||||
bool raw;
|
||||
const char* label;
|
||||
const char* user;
|
||||
} mraa_io_objects_t;
|
||||
|
||||
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*) calloc(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);
|
||||
}
|
||||
if (json_object_object_get_ex(ioobj, "user", &x) == true) {
|
||||
mraa_io_obj[i].user = json_object_get_string(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) {
|
||||
if (mraa_io_obj[i].user != NULL) {
|
||||
int sysfs_gpio_pin = mraa_gpio_get_pin_raw(gpio);
|
||||
if (sysfs_gpio_pin >= 0) {
|
||||
char bu[MAX_SIZE];
|
||||
snprintf(bu, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/value", sysfs_gpio_pin);
|
||||
struct passwd* user = getpwnam(mraa_io_obj[i].user);
|
||||
if (user != NULL) {
|
||||
if (chown(bu, user->pw_uid, user->pw_gid) == -1) {
|
||||
fprintf(stderr, "Couldn't change ownership of file %s to %d:%d\n", bu, user->pw_uid, user->pw_gid);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid user %s\n", mraa_io_obj[i].user);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
28
imraa/imraa_io.h
Normal file
28
imraa/imraa_io.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
void imraa_handle_IO(struct json_object* jobj);
|
||||
|
71
imraa/imraa_lock.c
Normal file
71
imraa/imraa_lock.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <json-c/json.h>
|
||||
#include <libudev.h>
|
||||
|
||||
#include <argp.h>
|
||||
#include <error.h>
|
||||
|
||||
#include <mraa/uart.h>
|
||||
#include <mraa/gpio.h>
|
||||
#include <mraa/i2c.h>
|
||||
#include <mraa/pwm.h>
|
||||
|
||||
#include <mraa_internal.h>
|
||||
|
||||
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);
|
||||
}
|
28
imraa/imraa_lock.h
Normal file
28
imraa/imraa_lock.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
void imraa_write_lockfile(const char* lock_file_location, const char* serialport);
|
||||
|
86
include/arm/am335x.h
Normal file
86
include/arm/am335x.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Author: Norbert Wesp <nwesp@phytec.de>
|
||||
* Author: Stefan Müller-Klieser <S.Mueller-Klieser@phytec.de>
|
||||
* Copyright (c) 2016 Phytec Messtechnik GmbH.
|
||||
*
|
||||
* Based on src/arm/beaglebone.c
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mraa/types.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define SYSFS_CLASS_PWM "/sys/class/pwm/"
|
||||
#define SYSFS_CLASS_MMC "/sys/class/mmc_host/"
|
||||
|
||||
#define MMAP_PATH "/dev/mem"
|
||||
#define MAX_SIZE 64
|
||||
|
||||
#define AM335X_GPIO0_BASE 0x44e07000
|
||||
#define AM335X_GPIO1_BASE 0x4804c000
|
||||
#define AM335X_GPIO2_BASE 0x481AC000
|
||||
#define AM335X_GPIO3_BASE 0x481AE000
|
||||
#define AM335X_GPIO_SIZE (4 * 1024)
|
||||
#define AM335X_IN 0x138
|
||||
#define AM335X_CLR 0x190
|
||||
#define AM335X_SET 0x194
|
||||
|
||||
/**
|
||||
* Writes 'value' to gpio_context 'dev'
|
||||
*
|
||||
* @return mraa_result_t indicating success of actions.
|
||||
*/
|
||||
mraa_result_t mraa_am335x_mmap_write(mraa_gpio_context dev, int value);
|
||||
|
||||
/**
|
||||
* Unsetup register of mmap_gpio[]
|
||||
*
|
||||
* @return static mraa_result_t indicating success of actions.
|
||||
*/
|
||||
static mraa_result_t mraa_am335x_mmap_unsetup();
|
||||
|
||||
/**
|
||||
* Read from gpio_context 'dev'
|
||||
*
|
||||
* @return int result indicating success of actions.
|
||||
*/
|
||||
int mraa_am335x_mmap_read(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Disables gpio_context 'dev' in case of 'en' or mmap'ing gpio_context 'dev'
|
||||
*
|
||||
* @return mraa_result_t indicating success of actions.
|
||||
*/
|
||||
mraa_result_t mraa_am335x_mmap_setup(mraa_gpio_context dev, mraa_boolean_t en);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
43
include/arm/de_nano_soc.h
Normal file
43
include/arm/de_nano_soc.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
* Copyright (c) 2017 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"
|
||||
|
||||
// 1x32 Arduino header, 1x40 GPIO_0/JP1, 1x40 GPIO_1/JP7,
|
||||
// 9 LEDs (8 User + HPS_LED), 4 switches, 3 buttons (2 User + HPS_KEY)
|
||||
// 10 ADC pins
|
||||
#define MRAA_DE_NANO_SOC_PINCOUNT 138
|
||||
|
||||
mraa_board_t *
|
||||
mraa_de_nano_soc();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
42
include/arm/phyboard.h
Normal file
42
include/arm/phyboard.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Norbert Wesp <nwesp@phytec.de>
|
||||
* Author: Stefan Müller-Klieser <S.Mueller-Klieser@phytec.de>
|
||||
* Copyright (c) 2016 Phytec Messtechnik GmbH.
|
||||
*
|
||||
* Based on include/arm/beaglebone.h
|
||||
*
|
||||
* 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"
|
||||
|
||||
#define MRAA_PHYBOARD_WEGA_PINCOUNT 117
|
||||
|
||||
mraa_board_t * mraa_phyboard();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -36,6 +36,8 @@ extern "C" {
|
||||
#define MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT 41
|
||||
#define MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT 41
|
||||
#define MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT 41
|
||||
#define MRAA_RASPBERRY_PI_ZERO_PINCOUNT 41
|
||||
#define MRAA_RASPBERRY_PI3_B_PINCOUNT 41
|
||||
|
||||
mraa_board_t *
|
||||
mraa_raspberry_pi();
|
||||
|
@@ -24,6 +24,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "uart.h"
|
||||
|
||||
#define MODE_INPUT 0x00
|
||||
@@ -99,6 +101,7 @@ typedef struct s_firmata {
|
||||
char firmware[140];
|
||||
uint8_t dev_count;
|
||||
struct _firmata** devs;
|
||||
pthread_spinlock_t lock;
|
||||
} t_firmata;
|
||||
|
||||
t_firmata* firmata_new(const char* name);
|
||||
|
@@ -30,7 +30,7 @@ extern "C" {
|
||||
|
||||
#include "mraa_internal.h"
|
||||
|
||||
#define MRAA_MOCK_PINCOUNT 4
|
||||
#define MRAA_MOCK_PINCOUNT 10
|
||||
|
||||
mraa_board_t*
|
||||
mraa_mock_board();
|
||||
|
73
include/mock/mock_board_spi.h
Normal file
73
include/mock/mock_board_spi.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2016 Alex Tereschenko.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#define MOCK_SPI_DEFAULT_FREQ 4000000
|
||||
#define MOCK_SPI_DEFAULT_MODE MRAA_SPI_MODE0
|
||||
#define MOCK_SPI_DEFAULT_LSBMODE 0
|
||||
#define MOCK_SPI_DEFAULT_BIT_PER_WORD 8
|
||||
// This is XORed with each byte/word of the transmitted message to get the received one
|
||||
#define MOCK_SPI_REPLY_DATA_MODIFIER_BYTE 0xAB
|
||||
#define MOCK_SPI_REPLY_DATA_MODIFIER_WORD 0xABBA
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_init_raw_replace(mraa_spi_context dev, unsigned int bus, unsigned int cs);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_stop_replace(mraa_spi_context dev);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_bit_per_word_replace(mraa_spi_context dev, unsigned int bits);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_lsbmode_replace(mraa_spi_context dev, mraa_boolean_t lsb);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_mode_replace(mraa_spi_context dev, mraa_spi_mode_t mode);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_frequency_replace(mraa_spi_context dev, int hz);
|
||||
|
||||
int
|
||||
mraa_mock_spi_write_replace(mraa_spi_context dev, uint8_t data);
|
||||
|
||||
int
|
||||
mraa_mock_spi_write_word_replace(mraa_spi_context dev, uint16_t data);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_transfer_buf_replace(mraa_spi_context dev, uint8_t* data, uint8_t* rxbuf, int length);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_spi_transfer_buf_word_replace(mraa_spi_context dev, uint16_t* data, uint16_t* rxbuf, int length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
71
include/mock/mock_board_uart.h
Normal file
71
include/mock/mock_board_uart.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2016 Alex Tereschenko.
|
||||
*
|
||||
* 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"
|
||||
|
||||
// ASCII code for "Z", used as a basis for our mock reads
|
||||
#define MOCK_UART_DATA_BYTE 0x5A
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_set_baudrate_replace(mraa_uart_context dev, unsigned int baud);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_init_raw_replace(mraa_uart_context dev, const char* path);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_flush_replace(mraa_uart_context dev);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_sendbreak_replace(mraa_uart_context dev, int duration);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_set_flowcontrol_replace(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_set_mode_replace(mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_set_non_blocking_replace(mraa_uart_context dev, mraa_boolean_t nonblock);
|
||||
|
||||
mraa_result_t
|
||||
mraa_mock_uart_set_timeout_replace(mraa_uart_context dev, int read, int write, int interchar);
|
||||
|
||||
mraa_boolean_t
|
||||
mraa_mock_uart_data_available_replace(mraa_uart_context dev, unsigned int millis);
|
||||
|
||||
int
|
||||
mraa_mock_uart_write_replace(mraa_uart_context dev, const char* buf, size_t len);
|
||||
|
||||
int
|
||||
mraa_mock_uart_read_replace(mraa_uart_context dev, char* buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -86,6 +86,7 @@ typedef struct {
|
||||
|
||||
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_raw_replace) (mraa_pwm_context dev, 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);
|
||||
@@ -97,8 +98,28 @@ typedef struct {
|
||||
|
||||
mraa_result_t (*spi_init_pre) (int bus);
|
||||
mraa_result_t (*spi_init_post) (mraa_spi_context spi);
|
||||
mraa_result_t (*spi_init_raw_replace) (mraa_spi_context spi, unsigned int bus, unsigned int cs);
|
||||
mraa_result_t (*spi_lsbmode_replace) (mraa_spi_context dev, mraa_boolean_t lsb);
|
||||
mraa_result_t (*spi_mode_replace) (mraa_spi_context dev, mraa_spi_mode_t mode);
|
||||
mraa_result_t (*spi_bit_per_word_replace) (mraa_spi_context dev, unsigned int bits);
|
||||
mraa_result_t (*spi_frequency_replace) (mraa_spi_context dev, int hz);
|
||||
mraa_result_t (*spi_transfer_buf_replace) (mraa_spi_context dev, uint8_t* data, uint8_t* rxbuf, int length);
|
||||
mraa_result_t (*spi_transfer_buf_word_replace) (mraa_spi_context dev, uint16_t* data, uint16_t* rxbuf, int length);
|
||||
int (*spi_write_replace) (mraa_spi_context dev, uint8_t data);
|
||||
int (*spi_write_word_replace) (mraa_spi_context dev, uint16_t data);
|
||||
mraa_result_t (*spi_stop_replace) (mraa_spi_context dev);
|
||||
|
||||
mraa_result_t (*uart_init_pre) (int index);
|
||||
mraa_result_t (*uart_init_post) (mraa_uart_context uart);
|
||||
mraa_result_t (*uart_init_raw_replace) (mraa_uart_context dev, const char* path);
|
||||
mraa_result_t (*uart_flush_replace) (mraa_uart_context dev);
|
||||
mraa_result_t (*uart_sendbreak_replace) (mraa_uart_context dev, int duration);
|
||||
mraa_result_t (*uart_set_baudrate_replace) (mraa_uart_context dev, unsigned int baud);
|
||||
mraa_result_t (*uart_set_mode_replace) (mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits);
|
||||
mraa_result_t (*uart_set_flowcontrol_replace) (mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts);
|
||||
mraa_result_t (*uart_set_timeout_replace) (mraa_uart_context dev, int read, int write, int interchar);
|
||||
mraa_result_t (*uart_set_non_blocking_replace) (mraa_uart_context dev, mraa_boolean_t nonblock);
|
||||
int (*uart_read_replace) (mraa_uart_context dev, char* buf, size_t len);
|
||||
int (*uart_write_replace)(mraa_uart_context dev, const char* buf, size_t len);
|
||||
mraa_boolean_t (*uart_data_available_replace) (mraa_uart_context dev, unsigned int millis);
|
||||
} mraa_adv_func_t;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user