Compare commits
184 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
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 |
20
.travis.yml
20
.travis.yml
@@ -2,16 +2,12 @@ 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
|
||||
- MOCK=true NODE4=true
|
||||
- MOCK=true NODE5=true
|
||||
- NPM=true NODE4=true
|
||||
- NPM=true NODE5=true
|
||||
compiler:
|
||||
@@ -26,16 +22,14 @@ 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 [ "${MOCK}" ]; then export BUILDARCH="MOCK"; else export BUILDARCH=""; 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 ..
|
||||
- npm install node-gyp && export NODE_GYP="$TRAVIS_BUILD_DIR/node_modules/node-gyp/bin/node-gyp.js"
|
||||
- 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=/home/travis/ && make && make install && cd ..
|
||||
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
|
||||
- echo "CC=$CC BUILDJAVA=$BUILDJAVA BUILDARCH=$BUILDARCH JSONPLAT=$JSONPLAT NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
|
||||
- if [ -z ${NPM} ]; then mkdir build && cd build && cmake -DBUILDSWIGJAVA="$BUILDJAVA" -DBUILDARCH="$BUILDARCH" -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:
|
||||
|
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,7 +138,7 @@ 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)
|
||||
|
||||
set (BUILDARCH "" CACHE STRING "Override architecture to build for")
|
||||
@@ -107,8 +167,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
|
||||
------------
|
||||
|
||||
|
@@ -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
|
||||
=========
|
||||
|
||||
|
@@ -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.
|
||||
@@ -233,6 +233,38 @@ 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 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
|
||||
@@ -214,6 +216,90 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@@ -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")
|
||||
|
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 | | |
|
||||
|
@@ -12,7 +12,9 @@ add_executable (uart uart.c)
|
||||
add_executable (mraa-gpio mraa-gpio.c)
|
||||
add_executable (mraa-i2c mraa-i2c.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
|
||||
@@ -33,8 +35,9 @@ target_link_libraries (uart mraa)
|
||||
target_link_libraries (mraa-gpio mraa)
|
||||
target_link_libraries (mraa-i2c 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 +50,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)
|
||||
|
||||
|
@@ -46,6 +46,9 @@ 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);
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ main(int argc, char** argv)
|
||||
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
|
||||
|
@@ -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;
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
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;
|
||||
|
@@ -38,7 +38,9 @@ extern "C" {
|
||||
|
||||
extern mraa_board_t* plat;
|
||||
extern char* platform_name;
|
||||
#if !defined(PERIPHERALMAN)
|
||||
extern mraa_iio_info_t* plat_iio;
|
||||
#endif
|
||||
extern mraa_lang_func_t* lang_func;
|
||||
|
||||
/**
|
||||
@@ -140,6 +142,25 @@ mraa_boolean_t mraa_link_targets(const char* filename, const char* targetname);
|
||||
*/
|
||||
int mraa_find_i2c_bus(const char* devname, int startfrom);
|
||||
|
||||
/**
|
||||
* helper function to wrap strtol for our basic usage
|
||||
*
|
||||
* @param string representing int
|
||||
* @param converted string
|
||||
* @return Result of the operation
|
||||
*/
|
||||
mraa_result_t mraa_atoi(char* intStr, int* value);
|
||||
|
||||
/**
|
||||
* helper function to find an i2c bus based on pci data
|
||||
*
|
||||
* @param pci_device
|
||||
* @param pci_id on pci_device
|
||||
* @param i2c adapter name & number
|
||||
* @return the matching i2c-dev bus id or -1
|
||||
*/
|
||||
int mraa_find_i2c_bus_pci(const char* pci_device, const char *pci_id, const char* adapter_name);
|
||||
|
||||
#if defined(IMRAA)
|
||||
/**
|
||||
* read Imraa subplatform lock file, caller is responsible to free return
|
||||
|
@@ -25,16 +25,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef PERIPHERALMAN
|
||||
#include <pio/peripheral_manager_client.h>
|
||||
#else
|
||||
#include "iio.h"
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "mraa.h"
|
||||
#include "mraa_adv_func.h"
|
||||
#include "iio.h"
|
||||
|
||||
// Bionic does not implement pthread cancellation API
|
||||
#ifndef __BIONIC__
|
||||
#define HAVE_PTHREAD_CANCEL
|
||||
#endif
|
||||
|
||||
// Max count for various busses
|
||||
#define MAX_I2C_BUS_COUNT 12
|
||||
#define MAX_SPI_BUS_COUNT 12
|
||||
#define MAX_UART_COUNT 6
|
||||
#define MAX_PWM_COUNT 6
|
||||
|
||||
|
||||
// general status failures for internal functions
|
||||
#define MRAA_PLATFORM_NO_INIT -3
|
||||
#define MRAA_IO_SETUP_FAILURE -2
|
||||
@@ -66,9 +78,11 @@
|
||||
#define MISO_KEY "miso"
|
||||
#define MOSI_KEY "mosi"
|
||||
#define CS_KEY "chipselect"
|
||||
#define SS_KEY "slaveselect"
|
||||
#define PIN_KEY "pin"
|
||||
#define IO_KEY "layout"
|
||||
#define PLATFORM_KEY "platform"
|
||||
#define BUS_KEY "bus"
|
||||
|
||||
// IO keys
|
||||
#define GPIO_KEY "GPIO"
|
||||
@@ -116,6 +130,9 @@ struct _gpio {
|
||||
int mock_state; /**< mock state of the pin */
|
||||
#endif
|
||||
/*@}*/
|
||||
#ifdef PERIPHERALMAN
|
||||
AGpio *bgpio;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -135,6 +152,10 @@ struct _i2c {
|
||||
uint8_t* mock_dev_data; /**< mock device data register block contents */
|
||||
#endif
|
||||
/*@}*/
|
||||
#ifdef PERIPHERALMAN
|
||||
AI2cDevice *bi2c;
|
||||
char bus_name[256];
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,6 +170,9 @@ struct _spi {
|
||||
unsigned int bpw; /**< Bits per word */
|
||||
mraa_adv_func_t* advance_func; /**< override function table */
|
||||
/*@}*/
|
||||
#ifdef PERIPHERALMAN
|
||||
ASpiDevice *bspi;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -163,6 +187,9 @@ struct _pwm {
|
||||
mraa_boolean_t owner; /**< Owner of pwm context*/
|
||||
mraa_adv_func_t* advance_func; /**< override function table */
|
||||
/*@}*/
|
||||
#ifdef PERIPHERALMAN
|
||||
APwm *bpwm;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -187,8 +214,12 @@ struct _uart {
|
||||
int fd; /**< file descriptor for device. */
|
||||
mraa_adv_func_t* advance_func; /**< override function table */
|
||||
/*@}*/
|
||||
#if defined(PERIPHERALMAN)
|
||||
struct AUartDevice *buart;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(PERIPHERALMAN)
|
||||
/**
|
||||
* A structure representing an IIO device
|
||||
*/
|
||||
@@ -207,6 +238,7 @@ struct _iio {
|
||||
mraa_iio_event* events;
|
||||
int datasize;
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A bitfield representing the capabilities of a pin.
|
||||
@@ -285,7 +317,11 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
#if defined(PERIPHERALMAN)
|
||||
char *name; /**< Peripheral manager's pin name */
|
||||
#else
|
||||
char name[MRAA_PIN_NAME_SIZE]; /**< Pin's real world name */
|
||||
#endif
|
||||
mraa_pincapabilities_t capabilities; /**< Pin Capabiliites */
|
||||
mraa_pin_t gpio; /**< GPIO structure */
|
||||
mraa_pin_t pwm; /**< PWM structure */
|
||||
@@ -302,6 +338,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char *name; /**< i2c bus name */
|
||||
int bus_id; /**< ID as exposed in the system */
|
||||
int scl; /**< i2c SCL */
|
||||
int sda; /**< i2c SDA */
|
||||
@@ -314,6 +351,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char *name; /**< spi bus name */
|
||||
unsigned int bus_id; /**< The Bus ID as exposed to the system. */
|
||||
unsigned int slave_s; /**< Slave select */
|
||||
mraa_boolean_t three_wire; /**< Is the bus only a three wire system */
|
||||
@@ -329,6 +367,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char *name; /**< uart name */
|
||||
unsigned int index; /**< ID as exposed in the system */
|
||||
int rx; /**< uart rx */
|
||||
int tx; /**< uart tx */
|
||||
@@ -336,6 +375,17 @@ typedef struct {
|
||||
/*@}*/
|
||||
} mraa_uart_dev_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a pwm device.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char *name; /**< pwm device name */
|
||||
unsigned int index; /**< ID as exposed in the system */
|
||||
char* device_path; /**< To store "/dev/pwm" for example */
|
||||
/*@}*/
|
||||
} mraa_pwm_dev_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a platform/board.
|
||||
*/
|
||||
@@ -346,17 +396,20 @@ typedef struct _board_t {
|
||||
int gpio_count; /**< GPIO Count */
|
||||
int aio_count; /**< Analog side Count */
|
||||
int i2c_bus_count; /**< Usable i2c Count */
|
||||
mraa_i2c_bus_t i2c_bus[12]; /**< Array of i2c */
|
||||
mraa_i2c_bus_t i2c_bus[MAX_I2C_BUS_COUNT]; /**< Array of i2c */
|
||||
unsigned int def_i2c_bus; /**< Position in array of default i2c bus */
|
||||
int spi_bus_count; /**< Usable spi Count */
|
||||
mraa_spi_bus_t spi_bus[12]; /**< Array of spi */
|
||||
mraa_spi_bus_t spi_bus[MAX_SPI_BUS_COUNT]; /**< Array of spi */
|
||||
unsigned int def_spi_bus; /**< Position in array of defult spi bus */
|
||||
unsigned int adc_raw; /**< ADC raw bit value */
|
||||
unsigned int adc_supported; /**< ADC supported bit value */
|
||||
unsigned int def_uart_dev; /**< Position in array of defult uart */
|
||||
int uart_dev_count; /**< Usable spi Count */
|
||||
mraa_uart_dev_t uart_dev[6]; /**< Array of UARTs */
|
||||
unsigned int def_uart_dev; /**< Position in array of default uart */
|
||||
unsigned int def_pwm_dev; /**< Position in array of default pwm */
|
||||
int uart_dev_count; /**< Usable uart Count */
|
||||
mraa_uart_dev_t uart_dev[MAX_UART_COUNT]; /**< Array of UARTs */
|
||||
mraa_boolean_t no_bus_mux; /**< i2c/spi/adc/pwm/uart bus muxing setup not required */
|
||||
int pwm_dev_count; /**< Usable pwm Count */
|
||||
mraa_pwm_dev_t pwm_dev[MAX_PWM_COUNT]; /**< Array of PWMs */
|
||||
int pwm_default_period; /**< The default PWM period is US */
|
||||
int pwm_max_period; /**< Maximum period in us */
|
||||
int pwm_min_period; /**< Minimum period in us */
|
||||
@@ -369,7 +422,9 @@ typedef struct _board_t {
|
||||
/*@}*/
|
||||
} mraa_board_t;
|
||||
|
||||
#if !defined(PERIPHERALMAN)
|
||||
typedef struct {
|
||||
struct _iio* iio_devices; /**< Pointer to IIO devices */
|
||||
uint8_t iio_device_count; /**< IIO device count */
|
||||
} mraa_iio_info_t;
|
||||
#endif
|
||||
|
39
include/peripheralmanager/peripheralman.h
Normal file
39
include/peripheralmanager/peripheralman.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mraa_internal.h"
|
||||
|
||||
mraa_platform_t mraa_peripheralman_platform();
|
||||
|
||||
void pman_mraa_deinit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -32,10 +32,10 @@ extern "C" {
|
||||
|
||||
// +1 as pins are "1 indexed"
|
||||
// we have 20 useless pins then the 4 LEDS and the 2 LEDs on the module.
|
||||
#define MRAA_INTEL_GT_TUCHUCK_PINCOUNT (40*2 + 23 +1 +2)
|
||||
#define MRAA_INTEL_JOULE_EXPANSION_PINCOUNT (40*2 + 23 +1 +2)
|
||||
|
||||
mraa_board_t*
|
||||
mraa_gt_tuchuck_board();
|
||||
mraa_joule_expansion_board();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@@ -26,10 +26,16 @@ set (mraa_LIB_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/spi/spi.c
|
||||
${PROJECT_SOURCE_DIR}/src/aio/aio.c
|
||||
${PROJECT_SOURCE_DIR}/src/uart/uart.c
|
||||
${PROJECT_SOURCE_DIR}/src/iio/iio.c
|
||||
${mraa_LIB_SRCS_NOAUTO}
|
||||
)
|
||||
|
||||
if (NOT PERIPHERALMAN)
|
||||
set (mraa_LIB_SRCS_NOAUTO
|
||||
${mraa_LIB_SRCS_NOAUTO}
|
||||
${PROJECT_SOURCE_DIR}/src/iio/iio.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
set (mraa_LIB_X86_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/x86/x86.c
|
||||
${PROJECT_SOURCE_DIR}/src/x86/intel_galileo_rev_d.c
|
||||
@@ -41,7 +47,7 @@ set (mraa_LIB_X86_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/x86/intel_sofia_3gr.c
|
||||
${PROJECT_SOURCE_DIR}/src/x86/intel_cherryhills.c
|
||||
${PROJECT_SOURCE_DIR}/src/x86/up.c
|
||||
${PROJECT_SOURCE_DIR}/src/x86/intel_gt_tuchuck.c
|
||||
${PROJECT_SOURCE_DIR}/src/x86/intel_joule_expansion.c
|
||||
)
|
||||
|
||||
message (STATUS "INFO - Adding support for platform ${MRAAPLATFORMFORCE}")
|
||||
@@ -67,8 +73,8 @@ if (NOT ${MRAAPLATFORMFORCE} STREQUAL "ALL")
|
||||
set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_cherryhills.c)
|
||||
elseif (${MRAAPLATFORMFORCE} STREQUAL "MRAA_UP")
|
||||
set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/up.c)
|
||||
elseif( ${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_GT_TUCHUCK")
|
||||
set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_gt_tuchuck.c)
|
||||
elseif( ${MRAAPLATFORMFORCE} STREQUAL "MRAA_INTEL_JOULE_EXPANSION")
|
||||
set (mraa_LIB_X86_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/x86/x86.c ${PROJECT_SOURCE_DIR}/src/x86/intel_joule_expansion.c)
|
||||
else ()
|
||||
message (FATAL_ERROR "Unknown x86 platform enabled!")
|
||||
endif ()
|
||||
@@ -81,7 +87,9 @@ set (mraa_LIB_ARM_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/arm/96boards.c
|
||||
${PROJECT_SOURCE_DIR}/src/arm/raspberry_pi.c
|
||||
${PROJECT_SOURCE_DIR}/src/arm/beaglebone.c
|
||||
${PROJECT_SOURCE_DIR}/src/arm/phyboard.c
|
||||
${PROJECT_SOURCE_DIR}/src/arm/banana.c
|
||||
${PROJECT_SOURCE_DIR}/src/arm/de_nano_soc.c
|
||||
)
|
||||
|
||||
set (mraa_LIB_MOCK_SRCS_NOAUTO
|
||||
@@ -90,6 +98,12 @@ set (mraa_LIB_MOCK_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/mock/mock_board_gpio.c
|
||||
${PROJECT_SOURCE_DIR}/src/mock/mock_board_aio.c
|
||||
${PROJECT_SOURCE_DIR}/src/mock/mock_board_i2c.c
|
||||
${PROJECT_SOURCE_DIR}/src/mock/mock_board_spi.c
|
||||
${PROJECT_SOURCE_DIR}/src/mock/mock_board_uart.c
|
||||
)
|
||||
|
||||
set (mraa_LIB_PERIPHERALMAN_SRCS_NOAUTO
|
||||
${PROJECT_SOURCE_DIR}/src/peripheralman/peripheralman.c
|
||||
)
|
||||
|
||||
if (JSONPLAT)
|
||||
@@ -104,7 +118,6 @@ endif ()
|
||||
|
||||
set (mraa_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
|
||||
if (X86PLAT)
|
||||
add_subdirectory(x86)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1")
|
||||
@@ -123,6 +136,23 @@ if (MOCKPLAT)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
if (PERIPHERALMAN)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPERIPHERALMAN=1")
|
||||
|
||||
# Use the find_package provided by Android Things. Make sure this is
|
||||
# available in CMAKE_MODULE_PATH.
|
||||
find_package(AndroidThings REQUIRED)
|
||||
|
||||
# Add Android Things libraries
|
||||
set (mraa_LIBS ${mraa_LIBS} ${ANDROIDTHINGS_LIBRARIES})
|
||||
|
||||
# Add Android Things include directories
|
||||
include_directories(${ANDROIDTHINGS_INCLUDE_DIRS})
|
||||
|
||||
# Add the peripheral manager source to the build
|
||||
add_subdirectory(peripheralman)
|
||||
endif()
|
||||
|
||||
if (USBPLAT)
|
||||
message (STATUS "INFO - Adding USB platforms")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
|
||||
@@ -238,6 +268,8 @@ if (BUILDSWIG)
|
||||
if (BUILDSWIGJAVA)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/java/manifest.txt.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/java/manifest.txt)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/java/pom.xml.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/java/mraa-${VERSION_SHORT}.pom)
|
||||
add_subdirectory (java)
|
||||
endif ()
|
||||
if (BUILDSWIGNODE)
|
||||
|
@@ -25,67 +25,74 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <mraa/common.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mraa/common.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "arm/96boards.h"
|
||||
#include "common.h"
|
||||
|
||||
#define DT_BASE "/sys/firmware/devicetree/base"
|
||||
#define DT_BASE "/proc/device-tree"
|
||||
|
||||
#define PLATFORM_NAME_DB410C "DB410C"
|
||||
#define PLATFORM_NAME_HIKEY "HIKEY"
|
||||
#define PLATFORM_NAME_BBGUM "BBGUM"
|
||||
|
||||
int db410c_ls_gpio_pins[MRAA_96BOARDS_LS_GPIO_COUNT] = {
|
||||
36, 12, 13, 69, 115, 4, 24, 25, 35, 34, 28, 33,
|
||||
36, 12, 13, 69, 115, 4, 24, 25, 35, 34, 28, 33,
|
||||
};
|
||||
|
||||
const char* db410c_serialdev[MRAA_96BOARDS_LS_UART_COUNT] = { "/dev/ttyMSM0", "/dev/ttyMSM1"};
|
||||
const char* db410c_serialdev[MRAA_96BOARDS_LS_UART_COUNT] = { "/dev/ttyMSM0", "/dev/ttyMSM1" };
|
||||
|
||||
int hikey_ls_gpio_pins[MRAA_96BOARDS_LS_GPIO_COUNT] = {
|
||||
488, 489, 490, 491, 492, 415, 463, 495, 426, 433, 427, 434,
|
||||
488, 489, 490, 491, 492, 415, 463, 495, 426, 433, 427, 434,
|
||||
};
|
||||
|
||||
const char* hikey_serialdev[MRAA_96BOARDS_LS_UART_COUNT] = { "/dev/ttyAMA2", "/dev/ttyAMA3"};
|
||||
|
||||
void mraa_96boards_pininfo(mraa_board_t* board, int index, int sysfs_pin,
|
||||
char *fmt, ...)
|
||||
const char* hikey_serialdev[MRAA_96BOARDS_LS_UART_COUNT] = { "/dev/ttyAMA2", "/dev/ttyAMA3" };
|
||||
|
||||
int bbgum_ls_gpio_pins[MRAA_96BOARDS_LS_GPIO_COUNT] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 155, 154 };
|
||||
|
||||
const char* bbgum_serialdev[MRAA_96BOARDS_LS_UART_COUNT] = { "/dev/ttyS3", "/dev/ttyS5" };
|
||||
|
||||
void
|
||||
mraa_96boards_pininfo(mraa_board_t* board, int index, int sysfs_pin, char* fmt, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
if (index > board->phy_pin_count)
|
||||
return;
|
||||
va_list arg_ptr;
|
||||
if (index > board->phy_pin_count)
|
||||
return;
|
||||
|
||||
mraa_pininfo_t* pininfo = &board->pins[index];
|
||||
va_start(arg_ptr, fmt);
|
||||
vsnprintf(pininfo->name, MRAA_PIN_NAME_SIZE, fmt, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
if (sysfs_pin >= 0)
|
||||
pininfo->capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
else
|
||||
pininfo->capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
pininfo->gpio.pinmap = sysfs_pin;
|
||||
pininfo->gpio.mux_total = 0;
|
||||
mraa_pininfo_t* pininfo = &board->pins[index];
|
||||
va_start(arg_ptr, fmt);
|
||||
vsnprintf(pininfo->name, MRAA_PIN_NAME_SIZE, fmt, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
if (sysfs_pin >= 0)
|
||||
pininfo->capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
else
|
||||
pininfo->capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
pininfo->gpio.pinmap = sysfs_pin;
|
||||
pininfo->gpio.mux_total = 0;
|
||||
}
|
||||
|
||||
mraa_board_t* mraa_96boards()
|
||||
mraa_board_t*
|
||||
mraa_96boards()
|
||||
{
|
||||
int i, pin;
|
||||
int *ls_gpio_pins = NULL;
|
||||
char ch;
|
||||
int i, pin;
|
||||
int* ls_gpio_pins = NULL;
|
||||
char ch;
|
||||
|
||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||
if (b == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||
if (b == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// pin mux for buses are setup by default by kernel so tell mraa to ignore them
|
||||
b->no_bus_mux = 1;
|
||||
b->phy_pin_count = MRAA_96BOARDS_LS_PIN_COUNT + 1;
|
||||
// pin mux for buses are setup by default by kernel so tell mraa to ignore them
|
||||
b->no_bus_mux = 1;
|
||||
b->phy_pin_count = MRAA_96BOARDS_LS_PIN_COUNT + 1;
|
||||
|
||||
if (mraa_file_exist(DT_BASE "/model")) {
|
||||
if (mraa_file_exist(DT_BASE "/model")) {
|
||||
// We are on a modern kernel, great!!!!
|
||||
if (mraa_file_contains(DT_BASE "/model", "Qualcomm Technologies, Inc. APQ 8016 SBC")) {
|
||||
b->platform_name = PLATFORM_NAME_DB410C;
|
||||
@@ -97,78 +104,88 @@ mraa_board_t* mraa_96boards()
|
||||
ls_gpio_pins = hikey_ls_gpio_pins;
|
||||
b->uart_dev[0].device_path = hikey_serialdev[0];
|
||||
b->uart_dev[1].device_path = hikey_serialdev[1];
|
||||
}
|
||||
}
|
||||
} else if (mraa_file_contains(DT_BASE "/model", "s900")) {
|
||||
b->platform_name = PLATFORM_NAME_BBGUM;
|
||||
ls_gpio_pins = bbgum_ls_gpio_pins;
|
||||
b->uart_dev[0].device_path = bbgum_serialdev[0];
|
||||
b->uart_dev[1].device_path = bbgum_serialdev[1];
|
||||
}
|
||||
}
|
||||
|
||||
//UART
|
||||
b->uart_dev_count = MRAA_96BOARDS_LS_UART_COUNT;
|
||||
b->def_uart_dev = 0;
|
||||
// UART
|
||||
b->uart_dev_count = MRAA_96BOARDS_LS_UART_COUNT;
|
||||
b->def_uart_dev = 0;
|
||||
|
||||
//I2C
|
||||
b->i2c_bus_count = MRAA_96BOARDS_LS_I2C_COUNT;
|
||||
b->def_i2c_bus = 0;
|
||||
b->i2c_bus[0].bus_id = 0;
|
||||
b->i2c_bus[1].bus_id= 1;
|
||||
// I2C
|
||||
if (b->platform_name == PLATFORM_NAME_BBGUM) {
|
||||
b->i2c_bus_count = MRAA_96BOARDS_LS_I2C_COUNT;
|
||||
b->def_i2c_bus = 0;
|
||||
b->i2c_bus[0].bus_id = 1;
|
||||
b->i2c_bus[1].bus_id = 2;
|
||||
} else {
|
||||
b->i2c_bus_count = MRAA_96BOARDS_LS_I2C_COUNT;
|
||||
b->def_i2c_bus = 0;
|
||||
b->i2c_bus[0].bus_id = 0;
|
||||
b->i2c_bus[1].bus_id = 1;
|
||||
}
|
||||
|
||||
//SPI
|
||||
b->spi_bus_count = MRAA_96BOARDS_LS_SPI_COUNT;
|
||||
b->spi_bus[0].bus_id = 0;
|
||||
b->def_spi_bus = 0;
|
||||
// SPI
|
||||
b->spi_bus_count = MRAA_96BOARDS_LS_SPI_COUNT;
|
||||
b->spi_bus[0].bus_id = 0;
|
||||
b->def_spi_bus = 0;
|
||||
|
||||
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
|
||||
if (b->adv_func == NULL) {
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
|
||||
if (b->adv_func == NULL) {
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count);
|
||||
if (b->pins == NULL) {
|
||||
free(b->adv_func);
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count);
|
||||
if (b->pins == NULL) {
|
||||
free(b->adv_func);
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mraa_96boards_pininfo(b, 0, -1, "INVALID");
|
||||
mraa_96boards_pininfo(b, 1, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 2, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 3, -1, "UART0_CTS");
|
||||
mraa_96boards_pininfo(b, 4, -1, "PWR_BTN_N");
|
||||
mraa_96boards_pininfo(b, 5, -1, "UART0_TXD");
|
||||
mraa_96boards_pininfo(b, 6, -1, "RST_BTN_N");
|
||||
mraa_96boards_pininfo(b, 7, -1, "UART0_RXD");
|
||||
mraa_96boards_pininfo(b, 8, -1, "SPI0_SCLK");
|
||||
mraa_96boards_pininfo(b, 9, -1, "UART0_RTS");
|
||||
mraa_96boards_pininfo(b, 10, -1, "SPI0_DIN");
|
||||
mraa_96boards_pininfo(b, 11, -1, "UART1_TXD");
|
||||
mraa_96boards_pininfo(b, 12, -1, "SPI0_CS");
|
||||
mraa_96boards_pininfo(b, 13, -1, "UART1_RXD");
|
||||
mraa_96boards_pininfo(b, 14, -1, "SPI0_DOUT");
|
||||
mraa_96boards_pininfo(b, 15, -1, "I2C0_SCL");
|
||||
mraa_96boards_pininfo(b, 16, -1, "PCM_FS");
|
||||
mraa_96boards_pininfo(b, 17, -1, "I2C0_SDA");
|
||||
mraa_96boards_pininfo(b, 18, -1, "PCM_CLK");
|
||||
mraa_96boards_pininfo(b, 19, -1, "I2C1_SCL");
|
||||
mraa_96boards_pininfo(b, 20, -1, "PCM_DO");
|
||||
mraa_96boards_pininfo(b, 21, -1, "I2C1_SDA");
|
||||
mraa_96boards_pininfo(b, 22, -1, "PCM_DI");
|
||||
// GPIOs are labelled "GPIO-A" through "GPIO-L"
|
||||
for (i = 0; i < MRAA_96BOARDS_LS_GPIO_COUNT; i++)
|
||||
{
|
||||
mraa_96boards_pininfo(b, 23 + i, ls_gpio_pins ? ls_gpio_pins[i] : -1,
|
||||
"GPIO-%c", 'A'+i);
|
||||
}
|
||||
mraa_96boards_pininfo(b, 35, -1, "1.8v");
|
||||
mraa_96boards_pininfo(b, 36, -1, "SYS_DCIN");
|
||||
mraa_96boards_pininfo(b, 37, -1, "5v");
|
||||
mraa_96boards_pininfo(b, 38, -1, "SYS_DCIN");
|
||||
mraa_96boards_pininfo(b, 39, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 40, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 0, -1, "INVALID");
|
||||
mraa_96boards_pininfo(b, 1, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 2, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 3, -1, "UART0_CTS");
|
||||
mraa_96boards_pininfo(b, 4, -1, "PWR_BTN_N");
|
||||
mraa_96boards_pininfo(b, 5, -1, "UART0_TXD");
|
||||
mraa_96boards_pininfo(b, 6, -1, "RST_BTN_N");
|
||||
mraa_96boards_pininfo(b, 7, -1, "UART0_RXD");
|
||||
mraa_96boards_pininfo(b, 8, -1, "SPI0_SCLK");
|
||||
mraa_96boards_pininfo(b, 9, -1, "UART0_RTS");
|
||||
mraa_96boards_pininfo(b, 10, -1, "SPI0_DIN");
|
||||
mraa_96boards_pininfo(b, 11, -1, "UART1_TXD");
|
||||
mraa_96boards_pininfo(b, 12, -1, "SPI0_CS");
|
||||
mraa_96boards_pininfo(b, 13, -1, "UART1_RXD");
|
||||
mraa_96boards_pininfo(b, 14, -1, "SPI0_DOUT");
|
||||
mraa_96boards_pininfo(b, 15, -1, "I2C0_SCL");
|
||||
mraa_96boards_pininfo(b, 16, -1, "PCM_FS");
|
||||
mraa_96boards_pininfo(b, 17, -1, "I2C0_SDA");
|
||||
mraa_96boards_pininfo(b, 18, -1, "PCM_CLK");
|
||||
mraa_96boards_pininfo(b, 19, -1, "I2C1_SCL");
|
||||
mraa_96boards_pininfo(b, 20, -1, "PCM_DO");
|
||||
mraa_96boards_pininfo(b, 21, -1, "I2C1_SDA");
|
||||
mraa_96boards_pininfo(b, 22, -1, "PCM_DI");
|
||||
// GPIOs are labelled "GPIO-A" through "GPIO-L"
|
||||
for (i = 0; i < MRAA_96BOARDS_LS_GPIO_COUNT; i++) {
|
||||
mraa_96boards_pininfo(b, 23 + i, ls_gpio_pins ? ls_gpio_pins[i] : -1, "GPIO-%c", 'A' + i);
|
||||
}
|
||||
mraa_96boards_pininfo(b, 35, -1, "1.8v");
|
||||
mraa_96boards_pininfo(b, 36, -1, "SYS_DCIN");
|
||||
mraa_96boards_pininfo(b, 37, -1, "5v");
|
||||
mraa_96boards_pininfo(b, 38, -1, "SYS_DCIN");
|
||||
mraa_96boards_pininfo(b, 39, -1, "GND");
|
||||
mraa_96boards_pininfo(b, 40, -1, "GND");
|
||||
|
||||
b->gpio_count = MRAA_96BOARDS_LS_GPIO_COUNT;
|
||||
b->gpio_count = MRAA_96BOARDS_LS_GPIO_COUNT;
|
||||
|
||||
b->aio_count = 0;
|
||||
b->adc_raw = 0;
|
||||
b->adc_supported = 0;
|
||||
b->aio_count = 0;
|
||||
b->adc_raw = 0;
|
||||
b->adc_supported = 0;
|
||||
|
||||
return b;
|
||||
return b;
|
||||
}
|
||||
|
160
src/arm/am335x.c
Normal file
160
src/arm/am335x.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mraa/types.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "arm/am335x.h"
|
||||
|
||||
// MMAP
|
||||
static uint8_t* mmap_gpio[4] = { NULL, NULL, NULL, NULL };
|
||||
static int mmap_fd = 0;
|
||||
static unsigned int mmap_count = 0;
|
||||
|
||||
mraa_result_t
|
||||
mraa_am335x_mmap_write(mraa_gpio_context dev, int value)
|
||||
{
|
||||
if (value) {
|
||||
*(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_SET) = (uint32_t)(1 << (dev->pin % 32));
|
||||
} else {
|
||||
*(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_CLR) = (uint32_t)(1 << (dev->pin % 32));
|
||||
}
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
static mraa_result_t
|
||||
mraa_am335x_mmap_unsetup()
|
||||
{
|
||||
if (mmap_gpio[0] == NULL) {
|
||||
syslog(LOG_ERR, "am335x mmap: null register cant unsetup");
|
||||
|
||||
return MRAA_ERROR_INVALID_RESOURCE;
|
||||
}
|
||||
munmap(mmap_gpio[0], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[0] = NULL;
|
||||
munmap(mmap_gpio[1], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[1] = NULL;
|
||||
munmap(mmap_gpio[2], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[2] = NULL;
|
||||
munmap(mmap_gpio[3], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[3] = NULL;
|
||||
if (close(mmap_fd) != 0) {
|
||||
return MRAA_ERROR_INVALID_RESOURCE;
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
mraa_am335x_mmap_read(mraa_gpio_context dev)
|
||||
{
|
||||
uint32_t value = *(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_IN);
|
||||
if (value & (uint32_t)(1 << (dev->pin % 32))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_am335x_mmap_setup(mraa_gpio_context dev, mraa_boolean_t en)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
syslog(LOG_ERR, "am335x mmap: context not valid");
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (en == 0) {
|
||||
if (dev->mmap_write == NULL && dev->mmap_read == NULL) {
|
||||
syslog(LOG_ERR, "am335x mmap: can't disable disabled mmap gpio");
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
dev->mmap_write = NULL;
|
||||
dev->mmap_read = NULL;
|
||||
mmap_count--;
|
||||
if (mmap_count == 0) {
|
||||
return mraa_am335x_mmap_unsetup();
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
if (dev->mmap_write != NULL && dev->mmap_read != NULL) {
|
||||
syslog(LOG_ERR, "am335x mmap: can't enable enabled mmap gpio");
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Might need to make some elements of this thread safe.
|
||||
// For example only allow one thread to enter the following block
|
||||
// to prevent mmap'ing twice.
|
||||
if (mmap_gpio[0] == NULL) {
|
||||
if ((mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) {
|
||||
syslog(LOG_ERR, "am335x map: unable to open resource file");
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
mmap_gpio[0] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO0_BASE);
|
||||
if (mmap_gpio[0] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "am335x mmap: failed to mmap");
|
||||
mmap_gpio[0] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
mmap_gpio[1] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO1_BASE);
|
||||
if (mmap_gpio[1] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "am335x mmap: failed to mmap");
|
||||
mmap_gpio[1] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
mmap_gpio[2] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO2_BASE);
|
||||
if (mmap_gpio[2] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "am335x mmap: failed to mmap");
|
||||
mmap_gpio[2] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
mmap_gpio[3] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO3_BASE);
|
||||
if (mmap_gpio[3] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "am335x mmap: failed to mmap");
|
||||
mmap_gpio[3] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
dev->mmap_write = &mraa_am335x_mmap_write;
|
||||
dev->mmap_read = &mraa_am335x_mmap_read;
|
||||
mmap_count++;
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
@@ -26,11 +26,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mraa_internal.h"
|
||||
#include "arm/raspberry_pi.h"
|
||||
#include "arm/beaglebone.h"
|
||||
#include "arm/banana.h"
|
||||
#include "arm/96boards.h"
|
||||
#include "arm/de_nano_soc.h"
|
||||
#include "arm/banana.h"
|
||||
#include "arm/beaglebone.h"
|
||||
#include "arm/phyboard.h"
|
||||
#include "arm/raspberry_pi.h"
|
||||
#include "mraa_internal.h"
|
||||
|
||||
|
||||
mraa_platform_t
|
||||
@@ -46,42 +48,53 @@ mraa_arm_platform()
|
||||
if (strncmp(line, "Hardware", 8) == 0) {
|
||||
if (strstr(line, "BCM2708")) {
|
||||
platform_type = MRAA_RASPBERRY_PI;
|
||||
}
|
||||
else if (strstr(line, "BCM2709")) {
|
||||
} else if (strstr(line, "BCM2709")) {
|
||||
platform_type = MRAA_RASPBERRY_PI;
|
||||
}
|
||||
else if (strstr(line, "Generic AM33XX")) {
|
||||
platform_type = MRAA_BEAGLEBONE;
|
||||
}
|
||||
else if (strstr(line, "HiKey Development Board")) {
|
||||
platform_type = MRAA_96BOARDS;
|
||||
}
|
||||
else if (strstr(line, "sun7i")) {
|
||||
if (mraa_file_contains("/sys/firmware/devicetree/base/model", "Banana Pro")) {
|
||||
platform_type = MRAA_BANANA;
|
||||
} else if (strstr(line, "BCM2835")) {
|
||||
platform_type = MRAA_RASPBERRY_PI;
|
||||
} else if (strstr(line, "Generic AM33XX")) {
|
||||
if(mraa_file_contains("/proc/device-tree/model", "phyBOARD-WEGA")) {
|
||||
platform_type = MRAA_PHYBOARD_WEGA;
|
||||
} else {
|
||||
platform_type = MRAA_BEAGLEBONE;
|
||||
}
|
||||
else if (mraa_file_contains("/sys/firmware/devicetree/base/model", "Banana Pi")) {
|
||||
} else if (strstr(line, "HiKey Development Board")) {
|
||||
platform_type = MRAA_96BOARDS;
|
||||
} else if (strstr(line, "s900")) {
|
||||
platform_type = MRAA_96BOARDS;
|
||||
} else if (strstr(line, "sun7i")) {
|
||||
if (mraa_file_contains("/proc/device-tree/model", "Banana Pro")) {
|
||||
platform_type = MRAA_BANANA;
|
||||
} else if (mraa_file_contains("/proc/device-tree/model",
|
||||
"Banana Pi")) {
|
||||
platform_type = MRAA_BANANA;
|
||||
}
|
||||
// For old kernels
|
||||
else if (mraa_file_exist("/sys/class/leds/green:ph24:led1")) {
|
||||
platform_type = MRAA_BANANA;
|
||||
}
|
||||
} else if (strstr(line, "DE0/DE10-Nano-SoC")) {
|
||||
platform_type = MRAA_DE_NANO_SOC;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
fclose(fh);
|
||||
}
|
||||
free(line);
|
||||
|
||||
/* Get compatible string from Device tree for boards that dont have enough info in /proc/cpuinfo */
|
||||
/* Get compatible string from Device tree for boards that dont have enough info in /proc/cpuinfo
|
||||
*/
|
||||
if (platform_type == MRAA_UNKNOWN_PLATFORM) {
|
||||
if (mraa_file_contains("/sys/firmware/devicetree/base/compatible", "qcom,apq8016-sbc"))
|
||||
platform_type = MRAA_96BOARDS;
|
||||
else if (mraa_file_contains("/sys/firmware/devicetree/base/model", "HiKey Development Board"))
|
||||
platform_type = MRAA_96BOARDS;
|
||||
}
|
||||
if (mraa_file_contains("/proc/device-tree/compatible", "qcom,apq8016-sbc"))
|
||||
platform_type = MRAA_96BOARDS;
|
||||
else if (mraa_file_contains("/proc/device-tree/model",
|
||||
"HiKey Development Board"))
|
||||
platform_type = MRAA_96BOARDS;
|
||||
else if (mraa_file_contains("/proc/device-tree/model", "s900"))
|
||||
platform_type = MRAA_96BOARDS;
|
||||
else if (mraa_file_contains("/proc/device-tree/compatible", "raspberrypi,"))
|
||||
platform_type = MRAA_RASPBERRY_PI;
|
||||
}
|
||||
|
||||
switch (platform_type) {
|
||||
case MRAA_RASPBERRY_PI:
|
||||
@@ -90,12 +103,18 @@ mraa_arm_platform()
|
||||
case MRAA_BEAGLEBONE:
|
||||
plat = mraa_beaglebone();
|
||||
break;
|
||||
case MRAA_PHYBOARD_WEGA:
|
||||
plat = mraa_phyboard();
|
||||
break;
|
||||
case MRAA_BANANA:
|
||||
plat = mraa_banana();
|
||||
break;
|
||||
case MRAA_96BOARDS:
|
||||
plat = mraa_96boards();
|
||||
break;
|
||||
case MRAA_DE_NANO_SOC:
|
||||
plat = mraa_de_nano_soc();
|
||||
break;
|
||||
default:
|
||||
plat = NULL;
|
||||
syslog(LOG_ERR, "Unknown Platform, currently not supported by MRAA");
|
||||
|
@@ -37,7 +37,7 @@
|
||||
#define PLATFORM_NAME_BANANA_PRO "Banana Pro"
|
||||
#define PLATFORM_BANANA_PRO 2
|
||||
#define MMAP_PATH "/dev/mem"
|
||||
#define DT_BASE "/sys/firmware/devicetree/base"
|
||||
#define DT_BASE "/proc/device-tree"
|
||||
|
||||
#define SUNXI_BASE (0x01C20000)
|
||||
#define SUNXI_BLOCK_SIZE (4 * 1024)
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "arm/beaglebone.h"
|
||||
#include "arm/am335x.h"
|
||||
|
||||
#define NUM2STR(x) #x
|
||||
|
||||
@@ -37,147 +38,11 @@
|
||||
#define PLATFORM_NAME_BEAGLEBONE_BLACK_REV_C "Beaglebone Black Rev. C"
|
||||
|
||||
#define SYSFS_DEVICES_CAPEMGR_SLOTS "/sys/devices/bone_capemgr.*/slots"
|
||||
#define SYSFS_CLASS_PWM "/sys/class/pwm/"
|
||||
#define SYSFS_CLASS_MMC "/sys/class/mmc_host/"
|
||||
#define SYSFS_PWM_OVERLAY "am33xx_pwm"
|
||||
#define UART_OVERLAY(x) "ADAFRUIT-UART" NUM2STR(x)
|
||||
//#define ADAFRUIT_SPI_OVERLAY "ADAFRUIT-SPI%d"
|
||||
#define SPI_OVERLAY(x) "BB-SPI" NUM2STR(x) "-01"
|
||||
#define I2C_OVERLAY(x) "ADAFRUIT-I2C" NUM2STR(x)
|
||||
#define MAX_SIZE 64
|
||||
|
||||
#define MMAP_PATH "/dev/mem"
|
||||
#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
|
||||
|
||||
// MMAP
|
||||
static uint8_t* mmap_gpio[4] = { NULL, NULL, NULL, NULL };
|
||||
static int mmap_fd = 0;
|
||||
static unsigned int mmap_count = 0;
|
||||
|
||||
mraa_result_t
|
||||
mraa_beaglebone_mmap_write(mraa_gpio_context dev, int value)
|
||||
{
|
||||
if (value) {
|
||||
*(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_SET) = (uint32_t)(1 << (dev->pin % 32));
|
||||
} else {
|
||||
*(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_CLR) = (uint32_t)(1 << (dev->pin % 32));
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
static mraa_result_t
|
||||
mraa_beaglebone_mmap_unsetup()
|
||||
{
|
||||
if (mmap_gpio[0] == NULL) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: null register cant unsetup");
|
||||
return MRAA_ERROR_INVALID_RESOURCE;
|
||||
}
|
||||
munmap(mmap_gpio[0], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[0] = NULL;
|
||||
munmap(mmap_gpio[1], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[1] = NULL;
|
||||
munmap(mmap_gpio[2], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[2] = NULL;
|
||||
munmap(mmap_gpio[3], AM335X_GPIO_SIZE);
|
||||
mmap_gpio[3] = NULL;
|
||||
if (close(mmap_fd) != 0) {
|
||||
return MRAA_ERROR_INVALID_RESOURCE;
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
mraa_beaglebone_mmap_read(mraa_gpio_context dev)
|
||||
{
|
||||
uint32_t value = *(volatile uint32_t*) (mmap_gpio[dev->pin / 32] + AM335X_IN);
|
||||
if (value & (uint32_t)(1 << (dev->pin % 32))) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_beaglebone_mmap_setup(mraa_gpio_context dev, mraa_boolean_t en)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: context not valid");
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (en == 0) {
|
||||
if (dev->mmap_write == NULL && dev->mmap_read == NULL) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: can't disable disabled mmap gpio");
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
dev->mmap_write = NULL;
|
||||
dev->mmap_read = NULL;
|
||||
mmap_count--;
|
||||
if (mmap_count == 0) {
|
||||
return mraa_beaglebone_mmap_unsetup();
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
if (dev->mmap_write != NULL && dev->mmap_read != NULL) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: can't enable enabled mmap gpio");
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Might need to make some elements of this thread safe.
|
||||
// For example only allow one thread to enter the following block
|
||||
// to prevent mmap'ing twice.
|
||||
if (mmap_gpio[0] == NULL) {
|
||||
if ((mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) {
|
||||
syslog(LOG_ERR, "beaglebone map: unable to open resource0 file");
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
mmap_gpio[0] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO0_BASE);
|
||||
if (mmap_gpio[0] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: failed to mmap");
|
||||
mmap_gpio[0] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
mmap_gpio[1] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO1_BASE);
|
||||
if (mmap_gpio[1] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: failed to mmap");
|
||||
mmap_gpio[1] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
mmap_gpio[2] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO2_BASE);
|
||||
if (mmap_gpio[2] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: failed to mmap");
|
||||
mmap_gpio[2] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
mmap_gpio[3] = (uint8_t*) mmap(NULL, AM335X_GPIO_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, mmap_fd, AM335X_GPIO3_BASE);
|
||||
if (mmap_gpio[3] == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "beaglebone mmap: failed to mmap");
|
||||
mmap_gpio[3] = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
dev->mmap_write = &mraa_beaglebone_mmap_write;
|
||||
dev->mmap_read = &mraa_beaglebone_mmap_read;
|
||||
mmap_count++;
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_beaglebone_uart_init_pre(int index)
|
||||
|
409
src/arm/de_nano_soc.c
Normal file
409
src/arm/de_nano_soc.c
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mraa/common.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "arm/de_nano_soc.h"
|
||||
|
||||
#define PLATFORM_NAME "DE0/DE10-Nano-SoC"
|
||||
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
|
||||
#define DEBUGFS_PINMODE_PATH "/sys/kernel/debug/gpio"
|
||||
|
||||
#define FPGA_REGION_BASE 0xFF200000
|
||||
#define FPGA_REGION_SIZE 0x00200000
|
||||
|
||||
#define MMAP_PATH "/dev/mem"
|
||||
|
||||
|
||||
// MMAP
|
||||
static uint8_t* mmap_reg = NULL;
|
||||
static int mmap_fd = 0;
|
||||
static int mmap_size = FPGA_REGION_SIZE;
|
||||
static unsigned int mmap_count = 0;
|
||||
|
||||
|
||||
// MMAP stubbed functions
|
||||
mraa_result_t
|
||||
mraa_de_nano_soc_spi_init_pre(int index)
|
||||
{
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_de_nano_soc_i2c_init_pre(unsigned int bus)
|
||||
{
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_de_nano_soc_mmap_write(mraa_gpio_context dev, int value)
|
||||
{
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
static mraa_result_t
|
||||
mraa_de_nano_soc_mmap_unsetup()
|
||||
{
|
||||
if (mmap_reg == NULL) {
|
||||
syslog(LOG_ERR, "de_nano_soc mmap: null register cant unsetup");
|
||||
return MRAA_ERROR_INVALID_RESOURCE;
|
||||
}
|
||||
munmap(mmap_reg, mmap_size);
|
||||
mmap_reg = NULL;
|
||||
if (close(mmap_fd) != 0) {
|
||||
return MRAA_ERROR_INVALID_RESOURCE;
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
mraa_de_nano_soc_mmap_read(mraa_gpio_context dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_de_nano_soc_mmap_setup(mraa_gpio_context dev, mraa_boolean_t en)
|
||||
{
|
||||
|
||||
if (dev == NULL) {
|
||||
syslog(LOG_ERR, "de_nano_soc mmap: context not valid");
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (en == 0) {
|
||||
if (dev->mmap_write == NULL && dev->mmap_read == NULL) {
|
||||
syslog(LOG_ERR, "de_nano_soc mmap: can't disable disabled mmap gpio");
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
dev->mmap_write = NULL;
|
||||
dev->mmap_read = NULL;
|
||||
mmap_count--;
|
||||
if (mmap_count == 0) {
|
||||
return mraa_de_nano_soc_mmap_unsetup();
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
if (dev->mmap_write != NULL && dev->mmap_read != NULL) {
|
||||
syslog(LOG_ERR, "de_nano_soc mmap: can't enable enabled mmap gpio");
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Might need to make some elements of this thread safe.
|
||||
// For example only allow one thread to enter the following block
|
||||
// to prevent mmap'ing twice.
|
||||
if (mmap_reg == NULL) {
|
||||
if ((mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) {
|
||||
syslog(LOG_ERR, "de_nano_soc map: unable to open resource0 file");
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
mmap_reg = (uint8_t*) mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, mmap_fd, FPGA_REGION_BASE);
|
||||
if (mmap_reg == MAP_FAILED) {
|
||||
syslog(LOG_ERR, "de_nano_soc mmap: failed to mmap");
|
||||
mmap_reg = NULL;
|
||||
close(mmap_fd);
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
dev->mmap_write = &mraa_de_nano_soc_mmap_write;
|
||||
dev->mmap_read = &mraa_de_nano_soc_mmap_read;
|
||||
mmap_count++;
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
mraa_board_t*
|
||||
mraa_de_nano_soc()
|
||||
{
|
||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||
if (b == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b->platform_name = PLATFORM_NAME;
|
||||
b->phy_pin_count = MRAA_DE_NANO_SOC_PINCOUNT;
|
||||
b->gpio_count = 96; // update as needed when adding ADC pins
|
||||
b->aio_count = 8;
|
||||
//b->pwm_default_period = 5000;
|
||||
//b->pwm_max_period = 218453;
|
||||
//b->pwm_min_period = 1;
|
||||
|
||||
b->pins = (mraa_pininfo_t*) calloc(b->phy_pin_count, sizeof(mraa_pininfo_t));
|
||||
if (b->pins == NULL) {
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
|
||||
if (b->adv_func == NULL) {
|
||||
free(b->pins);
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
|
||||
strncpy(b->pins[pos].name, "D0/RX", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
|
||||
//b->pins[pos].gpio.pinmap = 0;
|
||||
//b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D1/TX", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
|
||||
//b->pins[pos].gpio.pinmap = 0;
|
||||
//b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D2", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 203;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D3", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 204;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D4", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 205;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D5", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 206;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D6", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 207;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D7", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 208;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D8", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 209;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "D9", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 210;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
// TODO: add rest of the Arduino header
|
||||
while (pos < 32) {
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
pos++;
|
||||
}
|
||||
|
||||
// FPGA GPIO-0/JP1
|
||||
int jp = 1;
|
||||
int os_index = 171;
|
||||
while (pos < 52) {
|
||||
if (jp == 11) {
|
||||
strncpy(b->pins[pos].name, "5V", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else if (jp == 12) {
|
||||
strncpy(b->pins[pos].name, "GND", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else {
|
||||
snprintf(b->pins[pos].name, 8, "JP1-%d", jp);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = os_index;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
os_index++;
|
||||
}
|
||||
pos++;
|
||||
jp++;
|
||||
}
|
||||
|
||||
os_index = 139;
|
||||
while (pos < 72) {
|
||||
if (jp == 29) {
|
||||
strncpy(b->pins[pos].name, "3V3", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else if (jp == 30) {
|
||||
strncpy(b->pins[pos].name, "GND", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else {
|
||||
snprintf(b->pins[pos].name, 8, "JP1-%d", jp);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = os_index;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
os_index++;
|
||||
}
|
||||
pos++;
|
||||
jp++;
|
||||
}
|
||||
|
||||
// FPGA GPIO-1/JP7
|
||||
jp = 1;
|
||||
os_index = 107;
|
||||
while (pos < 92) {
|
||||
if (jp == 11) {
|
||||
strncpy(b->pins[pos].name, "5V", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else if (jp == 12) {
|
||||
strncpy(b->pins[pos].name, "GND", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else {
|
||||
snprintf(b->pins[pos].name, 8, "JP7-%d", jp);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = os_index;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
os_index++;
|
||||
}
|
||||
pos++;
|
||||
jp++;
|
||||
}
|
||||
|
||||
os_index = 75;
|
||||
while (pos < 112) {
|
||||
if (jp == 29) {
|
||||
strncpy(b->pins[pos].name, "3V3", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else if (jp == 30) {
|
||||
strncpy(b->pins[pos].name, "GND", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
} else {
|
||||
snprintf(b->pins[pos].name, 8, "JP7-%d", jp);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = os_index;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
os_index++;
|
||||
}
|
||||
pos++;
|
||||
jp++;
|
||||
}
|
||||
|
||||
// 4 Switches
|
||||
jp = 0;
|
||||
os_index = 363;
|
||||
while (pos < 116) {
|
||||
snprintf(b->pins[pos].name, 8, "SW%d", jp);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = os_index;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
jp++;
|
||||
os_index++;
|
||||
}
|
||||
|
||||
// 8 LEDs
|
||||
jp = 0;
|
||||
os_index = 395;
|
||||
while (pos < 124) {
|
||||
snprintf(b->pins[pos].name, 8, "LED%d", jp);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = os_index;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
jp++;
|
||||
os_index++;
|
||||
}
|
||||
|
||||
// HPS_LED, HPS_KEY0, KEY0, KEY1
|
||||
strncpy(b->pins[pos].name, "HPS_LED", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 478;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "HPS_KEY", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 479;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "KEY0", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 331;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
strncpy(b->pins[pos].name, "KEY1", 8);
|
||||
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[pos].gpio.pinmap = 332;
|
||||
b->pins[pos].gpio.mux_total = 0;
|
||||
pos++;
|
||||
|
||||
// Bus definitions
|
||||
// No function muxing needed for buses (stubbed pins if added later)
|
||||
b->no_bus_mux = 1;
|
||||
|
||||
// 3 I2C buses (default 2 from Arduino header)
|
||||
b->i2c_bus_count = 3;
|
||||
b->def_i2c_bus = 2;
|
||||
|
||||
b->i2c_bus[0].bus_id = 0;
|
||||
//b->i2c_bus[0].sda = 0;
|
||||
//b->i2c_bus[0].scl = 0;
|
||||
|
||||
b->i2c_bus[1].bus_id = 1;
|
||||
//b->i2c_bus[1].sda = 0;
|
||||
//b->i2c_bus[1].scl = 0;
|
||||
|
||||
b->i2c_bus[2].bus_id = 2;
|
||||
//b->i2c_bus[2].sda = 0;
|
||||
//b->i2c_bus[2].scl = 0;
|
||||
|
||||
// 1 SPI bus
|
||||
b->spi_bus_count = 1;
|
||||
b->def_spi_bus = 0;
|
||||
b->spi_bus[0].bus_id = 32766;
|
||||
b->spi_bus[0].slave_s = 0;
|
||||
//b->spi_bus[0].cs = 0;
|
||||
//b->spi_bus[0].mosi = 0;
|
||||
//b->spi_bus[0].miso = 0;
|
||||
//b->spi_bus[0].sclk = 0;
|
||||
|
||||
// Arduino header UART (default)
|
||||
b->uart_dev_count = 1;
|
||||
b->def_uart_dev = 0;
|
||||
b->uart_dev[0].device_path = "/dev/ttyS1";
|
||||
//b->uart_dev[0].rx = 0;
|
||||
//b->uart_dev[0].tx = 0;
|
||||
|
||||
return b;
|
||||
}
|
688
src/arm/phyboard.c
Normal file
688
src/arm/phyboard.c
Normal file
@@ -0,0 +1,688 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mraa/types.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "arm/phyboard.h"
|
||||
#include "arm/am335x.h"
|
||||
|
||||
#define PLATFORM_NAME_PHYBOARD_WEGA "phyBOARD-Wega"
|
||||
|
||||
mraa_result_t
|
||||
mraa_phyboard_uart_init_pre(int index)
|
||||
{
|
||||
char devpath[MAX_SIZE];
|
||||
|
||||
snprintf(devpath, MAX_SIZE, "/dev/ttyO%u", index);
|
||||
if (!mraa_file_exist(devpath)) {
|
||||
syslog(LOG_ERR, "uart: Device not initialized");
|
||||
} else {
|
||||
plat->uart_dev[index].device_path = devpath;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
return MRAA_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
mraa_phyboard_spi_init_pre(int index)
|
||||
{
|
||||
mraa_result_t ret = MRAA_ERROR_INVALID_PARAMETER;
|
||||
char devpath[MAX_SIZE];
|
||||
int deviceindex = 0;
|
||||
|
||||
if ((index == 0) && mraa_link_targets("/sys/class/spidev/spidev1.0", "48030000")) {
|
||||
deviceindex = 1;
|
||||
}
|
||||
if (deviceindex == 0) {
|
||||
deviceindex = 1;
|
||||
}
|
||||
|
||||
snprintf(devpath, MAX_SIZE, "/dev/spidev%u.0", deviceindex);
|
||||
if (mraa_file_exist(devpath)) {
|
||||
plat->spi_bus[index].bus_id = deviceindex;
|
||||
ret = MRAA_SUCCESS;
|
||||
} else {
|
||||
syslog(LOG_NOTICE, "spi: Device not initialized");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* NOT DONE / TESTED YET */
|
||||
mraa_result_t
|
||||
mraa_phyboard_i2c_init_pre(unsigned int bus)
|
||||
{
|
||||
mraa_result_t ret = MRAA_ERROR_INVALID_PARAMETER;
|
||||
char devpath[MAX_SIZE];
|
||||
|
||||
snprintf(devpath, MAX_SIZE, "/dev/i2c-%u", plat->i2c_bus[bus].bus_id);
|
||||
if (!mraa_file_exist(devpath)) {
|
||||
syslog(LOG_ERR, "i2c: %s doesn't exist ", devpath);
|
||||
syslog(LOG_ERR, "i2c: Device not initialized");
|
||||
|
||||
return ret;
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
/* NOT DONE / TESTED YET */
|
||||
mraa_pwm_context
|
||||
mraa_phyboard_pwm_init_replace(int pin)
|
||||
{
|
||||
char devpath[MAX_SIZE];
|
||||
int length = strlen(SYSFS_CLASS_PWM) + 5;
|
||||
|
||||
if (plat == NULL) {
|
||||
syslog(LOG_ERR, "pwm: Platform Not Initialised");
|
||||
return NULL;
|
||||
}
|
||||
if (plat->pins[pin].capabilities.pwm != 1) {
|
||||
syslog(LOG_ERR, "pwm: pin not capable of pwm");
|
||||
return NULL;
|
||||
}
|
||||
if (!mraa_file_exist(SYSFS_CLASS_PWM "pwmchip0")) {
|
||||
syslog(LOG_ERR, "pwm: pwmchip0 not found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(devpath, MAX_SIZE, SYSFS_CLASS_PWM "pwm%u", plat->pins[pin].pwm.pinmap);
|
||||
if (!mraa_file_exist(devpath)) {
|
||||
FILE* fh;
|
||||
fh = fopen(SYSFS_CLASS_PWM "export", "w");
|
||||
if (fh == NULL) {
|
||||
syslog(LOG_ERR, "pwm: Failed to open %s for writing, check access "
|
||||
"rights for user", SYSFS_CLASS_PWM "export");
|
||||
return NULL;
|
||||
}
|
||||
if (fprintf(fh, "%d", plat->pins[pin].pwm.pinmap) < 0) {
|
||||
syslog(LOG_ERR, "pwm: Failed to write to %s", SYSFS_CLASS_PWM "export");
|
||||
}
|
||||
fclose(fh);
|
||||
}
|
||||
|
||||
if (mraa_file_exist(devpath)) {
|
||||
mraa_pwm_context dev = (mraa_pwm_context) calloc(1, sizeof(struct _pwm));
|
||||
if (dev == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
dev->duty_fp = -1;
|
||||
dev->chipid = -1;
|
||||
dev->pin = plat->pins[pin].pwm.pinmap;
|
||||
dev->period = -1;
|
||||
return dev;
|
||||
} else {
|
||||
syslog(LOG_ERR, "pwm: pin not initialized");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mraa_board_t*
|
||||
mraa_phyboard()
|
||||
{
|
||||
unsigned int uart2_enabled = 0;
|
||||
unsigned int uart3_enabled = 0;
|
||||
|
||||
if (mraa_file_exist("/sys/class/tty/ttyO2")) {
|
||||
uart2_enabled = 1;
|
||||
} else {
|
||||
uart2_enabled = 0;
|
||||
}
|
||||
|
||||
if (mraa_file_exist("/sys/class/tty/ttyO3")) {
|
||||
uart3_enabled = 1;
|
||||
} else {
|
||||
uart3_enabled = 0;
|
||||
}
|
||||
|
||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||
if (b == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
b->platform_name = PLATFORM_NAME_PHYBOARD_WEGA;
|
||||
b->phy_pin_count = MRAA_PHYBOARD_WEGA_PINCOUNT;
|
||||
|
||||
if (b->platform_name == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
b->aio_count = 4;
|
||||
b->adc_raw = 12;
|
||||
b->adc_supported = 12;
|
||||
|
||||
b->pwm_default_period = 500;
|
||||
b->pwm_max_period = 2147483;
|
||||
b->pwm_min_period = 1;
|
||||
|
||||
b->pins = (mraa_pininfo_t*) calloc(b->phy_pin_count,sizeof(mraa_pininfo_t));
|
||||
if (b->pins == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
|
||||
if (b->adv_func == NULL) {
|
||||
free(b->pins);
|
||||
goto error;
|
||||
}
|
||||
|
||||
b->adv_func->uart_init_pre = &mraa_phyboard_uart_init_pre;
|
||||
b->adv_func->spi_init_pre = &mraa_phyboard_spi_init_pre;
|
||||
b->adv_func->i2c_init_pre = &mraa_phyboard_i2c_init_pre;
|
||||
b->adv_func->pwm_init_replace = &mraa_phyboard_pwm_init_replace;
|
||||
|
||||
strncpy(b->pins[0].name, "INVALID", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[0].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// X69 connector
|
||||
strncpy(b->pins[1].name, "VCC3V3", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[2].name, "VCC5V", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[3].name, "VDIG1_1P8V", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[4].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[5].name, "X_SPIO_CS0", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[5].spi.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[6].name, "X_SPIO_MOSI", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[6].spi.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[7].name, "X_SPIO_MISO", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[7].spi.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[8].name, "X_SPIO_CLK", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[8].spi.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[9].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[10].name, "X_UART0_RXD", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
|
||||
b->pins[10].uart.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[11].name, "X_I2C0_SDA", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
|
||||
b->pins[11].i2c.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[12].name, "X_UART0_TXD", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
|
||||
b->pins[12].uart.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[13].name, "X_I2C0_SCL", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
|
||||
b->pins[13].i2c.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[14].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[15].name, "X_JTAG_TMS", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* changed name "X_nJTAG_TRST" to "X_JTAG_TRST" for fitting in b->pins[16].name*/
|
||||
strncpy(b->pins[16].name, "X_JTAG_TRST", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[17].name, "X_JTAG_TDI", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[18].name, "X_JTAG_TDO", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[19].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[20].name, "X_JTAG_TCK", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[20].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* changed name "X_USB_DP_EXP" to "X_USB_DP" for fitting in b->pins[21].name*/
|
||||
strncpy(b->pins[21].name, "X_USB_DP", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* changed name "X_USB_DM_EXP" to "X_USB_DM" for fitting in b->pins[22].name*/
|
||||
strncpy(b->pins[22].name, "X_USB_DM", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[23].name, "nRESET_OUT", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[24].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[25].name, "X_MMC2_CMD", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[25].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[26].name, "X_MMC2_DATO", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[26].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[27].name, "X_MMC2_CLK", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[28].name, "X_MMC2_DAT1", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[29].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[30].name, "X_MMC2_DAT2", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* PIN-Number "31" with name "X_UART2_RX_GPIO3_9" */
|
||||
if (uart2_enabled == 1) {
|
||||
strncpy(b->pins[31].name, "X_UART2_RX", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
} else {
|
||||
strncpy(b->pins[31].name, "X_GPIO3_9", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
}
|
||||
b->pins[31].gpio.pinmap = (3*32 + 9);
|
||||
b->pins[31].gpio.parent_id = 0;
|
||||
b->pins[31].gpio.mux_total = 0;
|
||||
b->pins[31].uart.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[32].name, "X_MMC2_DAT3", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* PIN-Number "33" with name "X_UART2_TX_GPIO3_10" */
|
||||
if (uart2_enabled == 1) {
|
||||
strncpy(b->pins[33].name, "X_UART2_TX", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
} else {
|
||||
strncpy(b->pins[33].name, "X_GPIO3_10", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
}
|
||||
b->pins[33].gpio.pinmap = (3*32 + 10);
|
||||
b->pins[33].gpio.parent_id = 0;
|
||||
b->pins[33].gpio.mux_total = 0;
|
||||
b->pins[33].uart.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* PIN-Number "35" with name "X_UART3_RX_GPIO2_18" */
|
||||
if (uart3_enabled == 1) {
|
||||
strncpy(b->pins[35].name, "X_UART3_RX", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
} else {
|
||||
strncpy(b->pins[35].name, "X_GPIO2_18", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
}
|
||||
b->pins[35].gpio.pinmap = (2*32 + 18);
|
||||
b->pins[35].gpio.parent_id = 0;
|
||||
b->pins[35].gpio.mux_total = 0;
|
||||
b->pins[35].uart.mux_total = 0;
|
||||
|
||||
/* PIN-Number "36" with name "X_UART3_TX_GPIO2_19" */
|
||||
if (uart3_enabled == 1) {
|
||||
strncpy(b->pins[36].name, "X_UART3_TX", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
} else {
|
||||
strncpy(b->pins[36].name, "X_GPIO2_19", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
}
|
||||
b->pins[36].gpio.pinmap = (2*32 + 19);
|
||||
b->pins[36].gpio.parent_id = 0;
|
||||
b->pins[36].gpio.mux_total = 0;
|
||||
b->pins[36].uart.mux_total = 0;
|
||||
|
||||
/* PIN-Number "37" with name "X_INTR1_GPIO0_20" */
|
||||
strncpy(b->pins[37].name, "X_GPIO0_20", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[37].gpio.pinmap = (0*32 + 20);
|
||||
b->pins[37].gpio.parent_id = 0;
|
||||
b->pins[37].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[38].name, "X_GPIO0_7", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[38].gpio.pinmap = (0*32 + 7);
|
||||
b->pins[38].gpio.parent_id = 0;
|
||||
b->pins[38].gpio.mux_total = 0;
|
||||
|
||||
/* changed name "X_AM335_EXT_WAKEUP" to "X_AM335_WUP" for fitting in b->pins[39].name*/
|
||||
strncpy(b->pins[39].name, "X_AM335_WUP", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[39].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[40].name, "X_INT_RTCn", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[41].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[41].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* PIN-Number "42" with name "X_GPIO3_7_nPMOD_PW RFAIL" */
|
||||
strncpy(b->pins[42].name, "X_GPIO3_7", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[42].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[42].gpio.pinmap = (3*32 + 7);
|
||||
b->pins[42].gpio.parent_id = 0;
|
||||
b->pins[42].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[43].name, "nRESET_IN", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[43].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[44].name, "X_GPIO1_31", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[44].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[44].gpio.pinmap = (1*32 + 31);
|
||||
b->pins[44].gpio.parent_id = 0;
|
||||
b->pins[44].gpio.mux_total = 0;
|
||||
|
||||
/* changed name "X_AM335_NMIn" to "X_AM335_NMI" for fitting in b->pins[45].name*/
|
||||
strncpy(b->pins[45].name, "X_AM335_NMI", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[45].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[46].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[46].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// NOT DONE / TESTED YET
|
||||
strncpy(b->pins[47].name, "X_AIN4", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[47].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
|
||||
|
||||
// NOT DONE / TESTED YET
|
||||
strncpy(b->pins[48].name, "X_AIN5", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[48].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
|
||||
|
||||
// NOT DONE / TESTED YET
|
||||
strncpy(b->pins[49].name, "X_AIN6", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[49].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
|
||||
|
||||
// NOT DONE / TESTED YET
|
||||
strncpy(b->pins[50].name, "X_AIN7", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[50].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
|
||||
|
||||
strncpy(b->pins[51].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[51].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* to CHECK X_GPIO_CKSYNC */
|
||||
/* changed name "X_GPIO_CKSYNC" to "X_GPIO_CSYN" for fitting in b->pins[52].name*/
|
||||
strncpy(b->pins[52].name, "X_GPIO_CSYN", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[52].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* changed name "X_USB_ID_EXP" to "X_USB_ID" for fitting in b->pins[53].name*/
|
||||
strncpy(b->pins[53].name, "X_USB_ID", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[53].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* changed name "USB_VBUS_EXP" to "USB_VBUS" for fitting in b->pins[54].name*/
|
||||
strncpy(b->pins[54].name, "USB_VBUS", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[54].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[55].name, "X_USB1_CE", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[55].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[56].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[56].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[57].name, "VCC_BL", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[57].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[58].name, "X_BP_POWER", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[58].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[59].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[59].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60].name, "VCC5V_IN", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// X70 connector
|
||||
strncpy(b->pins[60+1].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+2].name, "X_LCD_D21", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+3].name, "X_LCD_D18", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+4].name, "X_LCD_D16", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+5].name, "X_LCD_D0", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+5].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+6].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+7].name, "X_LCD_D1", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+7].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+8].name, "X_LCD_D2", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+8].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+9].name, "X_LCD_D3", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+10].name, "X_LCD_D4", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+10].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+11].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+11].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+12].name, "X_LCD_D22", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+12].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+13].name, "X_LCD_D19", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+13].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+14].name, "X_LCD_D5", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+15].name, "X_LCD_D6", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+15].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+16].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+16].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+17].name, "X_LCD_D7", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+17].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+18].name, "X_LCD_D8", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+18].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+19].name, "X_LCD_D9", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+19].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+20].name, "X_LCD_D10", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+20].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+21].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+21].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+22].name, "X_LCD_D23", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+22].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+23].name, "X_LCD_D20", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+23].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+24].name, "X_LCD_D17", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+24].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+25].name, "X_LCD_D11", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+25].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+26].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+26].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+27].name, "X_LCD_D12", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+28].name, "X_LCD_D13", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+29].name, "X_LCD_D14", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+29].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+30].name, "X_LCD_D15", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+30].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+31].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+31].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+32].name, "X_LCD_PCLK", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+32].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* changed name "X_LCD_BIAS_EN" to "X_LCD_BIAS" for fitting in b->pins[60+33].name*/
|
||||
strncpy(b->pins[60+33].name, "X_LCD_BIAS", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+33].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+34].name, "X_LCD_HSYNC", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+35].name, "X_LCD_VSYNC", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+35].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+36].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+36].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+37].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+37].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+38].name, "X_PWM1_OUT", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+38].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
|
||||
b->pins[60+38].pwm.pinmap = 0;
|
||||
b->pins[60+38].pwm.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[60+39].name, "VCC_BL", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+39].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40].name, "VCC5V", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// X71 connector
|
||||
strncpy(b->pins[60+40+1].name, "X_I2S_CLK", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+2].name, "X_I2S_FRM", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+3].name, "X_I2S_ADC", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+4].name, "X_I2S_DAC", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/* PIN-Number "60+40+5" with name "X_AV_INT_GPIO1_30" */
|
||||
strncpy(b->pins[60+40+5].name, "X_GPIO1_30", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[60+40+5].gpio.pinmap = (1*32 + 30);
|
||||
b->pins[60+40+5].gpio.parent_id = 0;
|
||||
b->pins[60+40+5].gpio.mux_total = 0;
|
||||
|
||||
/* PIN-Number "60+40+6" with name "nUSB1_OC_GPIO3_19" or "X_MCASP0_AHCLKX_GPIO3_21" */
|
||||
// TODO -> Check settings of Jumper J77
|
||||
strncpy(b->pins[60+40+6].name, "X_GPIO3_19", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+6].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[60+40+6].gpio.pinmap = (3*32 + 19);
|
||||
b->pins[60+40+6].gpio.parent_id = 0;
|
||||
b->pins[60+40+6].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[60+40+7].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+7].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+8].name, "nRESET_OUT", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+8].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+9].name, "TS_X+", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+10].name, "TS_X-", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+10].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+11].name, "TS_Y+", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+11].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+12].name, "TS_Y-", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+12].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+13].name, "VCC3V3", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+13].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+14].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
strncpy(b->pins[60+40+15].name, "X_I2C0_SCL", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+15].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
|
||||
b->pins[60+40+15].i2c.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[60+40+16].name, "X_I2C0_SDA", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[60+40+16].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
|
||||
b->pins[60+40+16].i2c.mux_total = 0;
|
||||
|
||||
// BUS DEFINITIONS
|
||||
b->i2c_bus_count = 2;
|
||||
b->def_i2c_bus = 0;
|
||||
b->i2c_bus[0].bus_id = 0;
|
||||
b->i2c_bus[0].sda = 11;
|
||||
b->i2c_bus[0].scl = 13;
|
||||
b->i2c_bus[1].bus_id = 0;
|
||||
b->i2c_bus[1].sda = (60+40+16);
|
||||
b->i2c_bus[1].scl = (60+40+15);
|
||||
|
||||
b->spi_bus_count = 1;
|
||||
b->def_spi_bus = 0;
|
||||
b->spi_bus[0].bus_id = 0;
|
||||
b->spi_bus[0].slave_s = 0;
|
||||
b->spi_bus[0].cs = 5;
|
||||
b->spi_bus[0].mosi = 6;
|
||||
b->spi_bus[0].miso = 7;
|
||||
b->spi_bus[0].sclk = 8;
|
||||
|
||||
b->uart_dev_count = 4;
|
||||
b->def_uart_dev = 0;
|
||||
b->uart_dev[0].rx = 10;
|
||||
b->uart_dev[0].tx = 12;
|
||||
/* TODO UART1 */
|
||||
b->uart_dev[1].rx = 0;
|
||||
b->uart_dev[1].tx = 0;
|
||||
/* TODO UART1 */
|
||||
b->uart_dev[2].rx = 31;
|
||||
b->uart_dev[2].tx = 33;
|
||||
b->uart_dev[3].rx = 35;
|
||||
b->uart_dev[3].tx = 36;
|
||||
|
||||
b->gpio_count = 0;
|
||||
int i;
|
||||
for (i = 0; i < b->phy_pin_count; i++) {
|
||||
if (b->pins[i].capabilities.gpio) {
|
||||
b->gpio_count++;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
error:
|
||||
syslog(LOG_CRIT, "phyboard: failed to initialize");
|
||||
free(b);
|
||||
|
||||
return NULL;
|
||||
};
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mraa/common.h>
|
||||
|
||||
@@ -38,6 +39,8 @@
|
||||
#define PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1 "Raspberry Pi Compute Module Rev 1"
|
||||
#define PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1 "Raspberry Pi Model A+ Rev 1"
|
||||
#define PLATFORM_NAME_RASPBERRY_PI2_B_REV_1 "Raspberry Pi 2 Model B Rev 1"
|
||||
#define PLATFORM_NAME_RASPBERRY_PI_ZERO "Raspberry Pi Zero"
|
||||
#define PLATFORM_NAME_RASPBERRY_PI3_B "Raspberry Pi 3 Model B"
|
||||
#define PLATFORM_RASPBERRY_PI_B_REV_1 1
|
||||
#define PLATFORM_RASPBERRY_PI_A_REV_2 2
|
||||
#define PLATFORM_RASPBERRY_PI_B_REV_2 3
|
||||
@@ -45,6 +48,8 @@
|
||||
#define PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1 5
|
||||
#define PLATFORM_RASPBERRY_PI_A_PLUS_REV_1 6
|
||||
#define PLATFORM_RASPBERRY_PI2_B_REV_1 7
|
||||
#define PLATFORM_RASPBERRY_PI_ZERO 8
|
||||
#define PLATFORM_RASPBERRY_PI3_B 9
|
||||
#define MMAP_PATH "/dev/mem"
|
||||
#define BCM2835_PERI_BASE 0x20000000
|
||||
#define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
|
||||
@@ -209,6 +214,8 @@ mraa_board_t*
|
||||
mraa_raspberry_pi()
|
||||
{
|
||||
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
|
||||
int pin_base = 0;
|
||||
|
||||
if (b == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -217,10 +224,13 @@ mraa_raspberry_pi()
|
||||
size_t len = 100;
|
||||
char* line = calloc(len, sizeof(char));
|
||||
|
||||
mraa_boolean_t tweakedCpuinfo = 0;
|
||||
|
||||
FILE* fh = fopen("/proc/cpuinfo", "r");
|
||||
if (fh != NULL) {
|
||||
while (getline(&line, &len, fh) != -1) {
|
||||
if (strncmp(line, "Revision", 8) == 0) {
|
||||
tweakedCpuinfo = 1;
|
||||
if (strstr(line, "0002") || strstr(line, "0003")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
|
||||
@@ -230,6 +240,10 @@ mraa_raspberry_pi()
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
|
||||
} else if (strstr(line, "900092")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_ZERO;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT;
|
||||
} else if (strstr(line, "0007") || strstr(line, "0008") || strstr(line, "0009")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
|
||||
@@ -246,10 +260,15 @@ mraa_raspberry_pi()
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
|
||||
} else if (strstr(line, "a01041") || strstr(line, "a21041") || strstr(line, "a02082")) {
|
||||
} else if (strstr(line, "a01041") || strstr(line, "a21041")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
|
||||
} else if (strstr(line, "a02082") || strstr(line, "a020a0") ||
|
||||
strstr(line, "a22082") || strstr(line, "a32082")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI3_B;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT;
|
||||
} else {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
|
||||
@@ -261,6 +280,56 @@ mraa_raspberry_pi()
|
||||
}
|
||||
free(line);
|
||||
|
||||
// Some distros have a Revision line in /proc/cpuinfo for rpi.
|
||||
// As this may not be the case for all distros, we need to find
|
||||
// another way to guess the raspberry pi model.
|
||||
if (!tweakedCpuinfo) {
|
||||
// See Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt
|
||||
// for the values
|
||||
const char *compatible_path = "/proc/device-tree/compatible";
|
||||
if (mraa_file_contains(compatible_path, "raspberrypi,model-b")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-rev2")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-zero")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_ZERO;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-a")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-plus")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,compute-module")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-a-plus")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,2-model-b")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
|
||||
} else if (mraa_file_contains(compatible_path, "raspberrypi,3-model-b")) {
|
||||
b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B;
|
||||
platform_detected = PLATFORM_RASPBERRY_PI3_B;
|
||||
b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT;
|
||||
}
|
||||
}
|
||||
|
||||
b->aio_count = 0;
|
||||
b->adc_raw = 0;
|
||||
b->adc_supported = 0;
|
||||
@@ -287,6 +356,31 @@ mraa_raspberry_pi()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Detect the base of the gpiochip, raspbian hardcodes it to 0 in the kernel
|
||||
// while upstream kernel does not.
|
||||
DIR* gpio_dir = opendir("/sys/class/gpio");
|
||||
if (gpio_dir == NULL) {
|
||||
free(b->adv_func);
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct dirent* child;
|
||||
while ((child = readdir(gpio_dir)) != NULL) {
|
||||
if (strstr(child->d_name, "gpiochip")) {
|
||||
char chip_path[MAX_SIZE];
|
||||
sprintf(chip_path, "/sys/class/gpio/%s/label", child->d_name);
|
||||
if (mraa_file_contains(chip_path, "bcm2835")) {
|
||||
if (mraa_atoi(child->d_name + 8, &pin_base) != MRAA_SUCCESS) {
|
||||
free(b->adv_func);
|
||||
free(b);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b->adv_func->spi_init_pre = &mraa_raspberry_pi_spi_init_pre;
|
||||
b->adv_func->i2c_init_pre = &mraa_raspberry_pi_i2c_init_pre;
|
||||
b->adv_func->gpio_mmap_setup = &mraa_raspberry_pi_mmap_setup;
|
||||
@@ -302,7 +396,7 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[3].name, "SDA0", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
|
||||
b->pins[3].gpio.pinmap = 2;
|
||||
b->pins[3].gpio.pinmap = pin_base + 2;
|
||||
b->pins[3].gpio.mux_total = 0;
|
||||
b->pins[3].i2c.pinmap = 0;
|
||||
b->pins[3].i2c.mux_total = 0;
|
||||
@@ -312,7 +406,7 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[5].name, "SCL0", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
|
||||
b->pins[5].gpio.pinmap = 3;
|
||||
b->pins[5].gpio.pinmap = pin_base + 3;
|
||||
b->pins[5].gpio.mux_total = 0;
|
||||
b->pins[5].i2c.pinmap = 0;
|
||||
b->pins[5].i2c.mux_total = 0;
|
||||
@@ -322,12 +416,12 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[7].name, "GPIO4", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[7].gpio.pinmap = 4;
|
||||
b->pins[7].gpio.pinmap = pin_base + 4;
|
||||
b->pins[7].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[8].name, "UART_TX", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
b->pins[8].gpio.pinmap = 14;
|
||||
b->pins[8].gpio.pinmap = pin_base + 14;
|
||||
b->pins[8].gpio.mux_total = 0;
|
||||
b->pins[8].uart.parent_id = 0;
|
||||
b->pins[8].uart.mux_total = 0;
|
||||
@@ -337,27 +431,27 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[10].name, "UART_RX", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
|
||||
b->pins[10].gpio.pinmap = 15;
|
||||
b->pins[10].gpio.pinmap = pin_base + 15;
|
||||
b->pins[10].gpio.mux_total = 0;
|
||||
b->pins[10].uart.parent_id = 0;
|
||||
b->pins[10].uart.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[11].name, "GPIO17", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[11].gpio.pinmap = 17;
|
||||
b->pins[11].gpio.pinmap = pin_base + 17;
|
||||
b->pins[11].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[12].name, "GPIO18", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[12].gpio.pinmap = 18;
|
||||
b->pins[12].gpio.pinmap = pin_base + 18;
|
||||
b->pins[12].gpio.mux_total = 0;
|
||||
|
||||
if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1) {
|
||||
strncpy(b->pins[13].name, "GPIO21", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[13].gpio.pinmap = 21;
|
||||
b->pins[13].gpio.pinmap = pin_base + 21;
|
||||
} else {
|
||||
strncpy(b->pins[13].name, "GPIO27", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[13].gpio.pinmap = 27;
|
||||
b->pins[13].gpio.pinmap = pin_base + 27;
|
||||
}
|
||||
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[13].gpio.mux_total = 0;
|
||||
@@ -367,12 +461,12 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[15].name, "GPIO22", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[15].gpio.pinmap = 22;
|
||||
b->pins[15].gpio.pinmap = pin_base + 22;
|
||||
b->pins[15].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[16].name, "GPIO23", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[16].gpio.pinmap = 23;
|
||||
b->pins[16].gpio.pinmap = pin_base + 23;
|
||||
b->pins[16].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[17].name, "3V3", MRAA_PIN_NAME_SIZE);
|
||||
@@ -380,12 +474,12 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[18].name, "GPIO24", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[18].gpio.pinmap = 24;
|
||||
b->pins[18].gpio.pinmap = pin_base + 24;
|
||||
b->pins[18].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[19].name, "SPI_MOSI", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[19].gpio.pinmap = 10;
|
||||
b->pins[19].gpio.pinmap = pin_base + 10;
|
||||
b->pins[19].gpio.mux_total = 0;
|
||||
b->pins[19].spi.pinmap = 0;
|
||||
b->pins[19].spi.mux_total = 0;
|
||||
@@ -395,26 +489,26 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[21].name, "SPI_MISO", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[21].gpio.pinmap = 9;
|
||||
b->pins[21].gpio.pinmap = pin_base + 9;
|
||||
b->pins[21].gpio.mux_total = 0;
|
||||
b->pins[21].spi.pinmap = 0;
|
||||
b->pins[21].spi.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[22].name, "GPIO25", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[22].gpio.pinmap = 25;
|
||||
b->pins[22].gpio.pinmap = pin_base + 25;
|
||||
b->pins[22].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[23].name, "SPI_CLK", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[23].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[23].gpio.pinmap = 11;
|
||||
b->pins[23].gpio.pinmap = pin_base + 11;
|
||||
b->pins[23].gpio.mux_total = 0;
|
||||
b->pins[23].spi.pinmap = 0;
|
||||
b->pins[23].spi.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[24].name, "SPI_CS0", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[24].gpio.pinmap = 8;
|
||||
b->pins[24].gpio.pinmap = pin_base + 8;
|
||||
b->pins[24].gpio.mux_total = 0;
|
||||
b->pins[24].spi.pinmap = 0;
|
||||
b->pins[24].spi.mux_total = 0;
|
||||
@@ -424,7 +518,7 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[26].name, "SPI_CS1", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[26].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
|
||||
b->pins[26].gpio.pinmap = 7;
|
||||
b->pins[26].gpio.pinmap = pin_base + 7;
|
||||
b->pins[26].gpio.mux_total = 0;
|
||||
b->pins[26].spi.pinmap = 0;
|
||||
b->pins[26].spi.mux_total = 0;
|
||||
@@ -439,21 +533,21 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[29].name, "GPIO8", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[29].gpio.pinmap = 8;
|
||||
b->pins[29].gpio.pinmap = pin_base + 8;
|
||||
b->pins[29].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[30].name, "GPIO9", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[30].gpio.pinmap = 9;
|
||||
b->pins[30].gpio.pinmap = pin_base + 9;
|
||||
b->pins[30].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[31].name, "GPIO10", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[31].gpio.pinmap = 10;
|
||||
b->pins[31].gpio.pinmap = pin_base + 10;
|
||||
b->pins[31].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[32].name, "GPIO11", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[32].gpio.pinmap = 11;
|
||||
b->pins[32].gpio.pinmap = pin_base + 11;
|
||||
b->pins[32].gpio.mux_total = 0;
|
||||
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
@@ -490,7 +584,9 @@ mraa_raspberry_pi()
|
||||
|
||||
if ((platform_detected == PLATFORM_RASPBERRY_PI_A_PLUS_REV_1) ||
|
||||
(platform_detected == PLATFORM_RASPBERRY_PI_B_PLUS_REV_1) ||
|
||||
(platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1)) {
|
||||
(platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1) ||
|
||||
(platform_detected == PLATFORM_RASPBERRY_PI3_B) ||
|
||||
(platform_detected == PLATFORM_RASPBERRY_PI_ZERO)) {
|
||||
|
||||
strncpy(b->pins[27].name, "ID_SD", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
@@ -500,7 +596,7 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[29].name, "GPIO05", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[29].gpio.pinmap = 5;
|
||||
b->pins[29].gpio.pinmap = pin_base + 5;
|
||||
b->pins[29].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[30].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
@@ -508,17 +604,17 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[31].name, "GPIO06", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[31].gpio.pinmap = 6;
|
||||
b->pins[31].gpio.pinmap = pin_base + 6;
|
||||
b->pins[31].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[32].name, "GPIO12", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[32].gpio.pinmap = 12;
|
||||
b->pins[32].gpio.pinmap = pin_base + 12;
|
||||
b->pins[32].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[33].name, "GPIO13", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[33].gpio.pinmap = 13;
|
||||
b->pins[33].gpio.pinmap = pin_base + 13;
|
||||
b->pins[33].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
@@ -526,22 +622,22 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[35].name, "GPIO19", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[35].gpio.pinmap = 19;
|
||||
b->pins[35].gpio.pinmap = pin_base + 19;
|
||||
b->pins[35].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[36].name, "GPIO16", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[36].gpio.pinmap = 16;
|
||||
b->pins[36].gpio.pinmap = pin_base + 16;
|
||||
b->pins[36].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[37].name, "GPIO26", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[37].gpio.pinmap = 26;
|
||||
b->pins[37].gpio.pinmap = pin_base + 26;
|
||||
b->pins[37].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[38].name, "GPIO20", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[38].gpio.pinmap = 20;
|
||||
b->pins[38].gpio.pinmap = pin_base + 20;
|
||||
b->pins[38].gpio.mux_total = 0;
|
||||
|
||||
strncpy(b->pins[39].name, "GND", MRAA_PIN_NAME_SIZE);
|
||||
@@ -549,7 +645,7 @@ mraa_raspberry_pi()
|
||||
|
||||
strncpy(b->pins[40].name, "GPIO21", MRAA_PIN_NAME_SIZE);
|
||||
b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
|
||||
b->pins[40].gpio.pinmap = 21;
|
||||
b->pins[40].gpio.pinmap = pin_base + 21;
|
||||
b->pins[40].gpio.mux_total = 0;
|
||||
}
|
||||
|
||||
|
@@ -33,13 +33,19 @@ t_firmata*
|
||||
firmata_new(const char* name)
|
||||
{
|
||||
t_firmata* res;
|
||||
mraa_result_t uart_res = MRAA_ERROR_UNSPECIFIED;
|
||||
|
||||
res = calloc(1, sizeof(t_firmata));
|
||||
if (!res) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ret = pthread_spin_init(&res->lock, PTHREAD_PROCESS_SHARED);
|
||||
if (ret != 0) {
|
||||
syslog(LOG_ERR, "firmata; could not init locking");
|
||||
free(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res->uart = mraa_uart_init_raw(name);
|
||||
if (res->uart == NULL) {
|
||||
syslog(LOG_ERR, "firmata: UART failed to setup");
|
||||
@@ -69,7 +75,7 @@ firmata_close(t_firmata* firmata)
|
||||
int
|
||||
firmata_pull(t_firmata* firmata)
|
||||
{
|
||||
uint8_t buff[FIRMATA_MSG_LEN];
|
||||
char buff[FIRMATA_MSG_LEN];
|
||||
int r;
|
||||
|
||||
r = mraa_uart_data_available(firmata->uart, 40);
|
||||
@@ -79,7 +85,7 @@ firmata_pull(t_firmata* firmata)
|
||||
return 0;
|
||||
}
|
||||
if (r > 0) {
|
||||
firmata_parse(firmata, buff, r);
|
||||
firmata_parse(firmata, (uint8_t*) buff, r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +140,9 @@ firmata_endParse(t_firmata* firmata)
|
||||
int analog_val = firmata->parse_buff[1] | (firmata->parse_buff[2] << 7);
|
||||
for (pin = 0; pin < 128; pin++) {
|
||||
if (firmata->pins[pin].analog_channel == analog_ch) {
|
||||
if (pthread_spin_lock(&firmata->lock) != 0) return;
|
||||
firmata->pins[pin].value = analog_val;
|
||||
if (pthread_spin_unlock(&firmata->lock) != 0) syslog(LOG_ERR, "firmata: Fatal spinlock deadlock");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +156,9 @@ firmata_endParse(t_firmata* firmata)
|
||||
for (mask = 1; mask & 0xFF; mask <<= 1, pin++) {
|
||||
if (firmata->pins[pin].mode == MODE_INPUT) {
|
||||
uint32_t val = (port_val & mask) ? 1 : 0;
|
||||
if (pthread_spin_lock(&firmata->lock)) return;
|
||||
firmata->pins[pin].value = val;
|
||||
if (pthread_spin_unlock(&firmata->lock) != 0) syslog(LOG_ERR, "firmata: Fatal spinlock deadlock");
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -174,7 +184,7 @@ firmata_endParse(t_firmata* firmata)
|
||||
// not ready to communicate for some time, so the only
|
||||
// way to reliably query their capabilities is to wait
|
||||
// until the REPORT_FIRMWARE message is heard.
|
||||
uint8_t buf[80];
|
||||
char buf[80];
|
||||
len = 0;
|
||||
buf[len++] = FIRMATA_START_SYSEX;
|
||||
buf[len++] = FIRMATA_ANALOG_MAPPING_QUERY; // read analog to pin # info
|
||||
@@ -209,7 +219,7 @@ firmata_endParse(t_firmata* firmata)
|
||||
}
|
||||
// send a state query for for every pin with any modes
|
||||
for (pin = 0; pin < 128; pin++) {
|
||||
uint8_t buf[512];
|
||||
char buf[512];
|
||||
int len = 0;
|
||||
if (firmata->pins[pin].supported_modes) {
|
||||
buf[len++] = FIRMATA_START_SYSEX;
|
||||
@@ -241,15 +251,17 @@ firmata_endParse(t_firmata* firmata)
|
||||
int reg = (firmata->parse_buff[4] & 0x7f) | ((firmata->parse_buff[5] & 0x7f) << 7);
|
||||
int i = 6;
|
||||
int ii = 0;
|
||||
for (ii; ii < (firmata->parse_count - 7) / 2; ii++) {
|
||||
if (pthread_spin_lock(&firmata->lock) != 0) syslog(LOG_ERR, "firmata: Fatal spinlock deadlock, skipping i2c msg");
|
||||
for (; ii < (firmata->parse_count - 7) / 2; ii++) {
|
||||
firmata->i2cmsg[addr][reg+ii] = (firmata->parse_buff[i] & 0x7f) | ((firmata->parse_buff[i+1] & 0x7f) << 7);
|
||||
i = i+2;
|
||||
}
|
||||
if (pthread_spin_unlock(&firmata->lock) != 0) syslog(LOG_ERR, "firmata: Fatal spinlock deadlock");
|
||||
} else {
|
||||
if (firmata->devs != NULL) {
|
||||
struct _firmata* devs = firmata->devs[0];
|
||||
int i = 0;
|
||||
for (i; i < firmata->dev_count; i++, devs++) {
|
||||
for (; i < firmata->dev_count; i++, devs++) {
|
||||
if (devs != NULL) {
|
||||
if (firmata->parse_buff[1] == devs->feature) {
|
||||
// call func
|
||||
@@ -284,7 +296,7 @@ firmata_initPins(t_firmata* firmata)
|
||||
int
|
||||
firmata_askFirmware(t_firmata* firmata)
|
||||
{
|
||||
uint8_t buf[3];
|
||||
char buf[3];
|
||||
int res;
|
||||
|
||||
buf[0] = FIRMATA_START_SYSEX;
|
||||
@@ -298,7 +310,7 @@ int
|
||||
firmata_pinMode(t_firmata* firmata, int pin, int mode)
|
||||
{
|
||||
int res;
|
||||
uint8_t buff[4];
|
||||
char buff[4];
|
||||
|
||||
firmata->pins[pin].mode = mode;
|
||||
buff[0] = FIRMATA_SET_PIN_MODE;
|
||||
@@ -313,7 +325,7 @@ firmata_analogWrite(t_firmata* firmata, int pin, int value)
|
||||
{
|
||||
int res;
|
||||
|
||||
uint8_t buff[3];
|
||||
char buff[3];
|
||||
buff[0] = 0xE0 | pin;
|
||||
buff[1] = value & 0x7F;
|
||||
buff[2] = (value >> 7) & 0x7F;
|
||||
@@ -326,7 +338,7 @@ firmata_analogRead(t_firmata *firmata, int pin)
|
||||
{
|
||||
int res;
|
||||
int value = 1;
|
||||
uint8_t buff[2];
|
||||
char buff[2];
|
||||
buff[0] = FIRMATA_REPORT_ANALOG | pin;
|
||||
buff[1] = value;
|
||||
res = mraa_uart_write(firmata->uart, buff, 2);
|
||||
@@ -338,7 +350,7 @@ firmata_digitalWrite(t_firmata* firmata, int pin, int value)
|
||||
{
|
||||
int i;
|
||||
int res;
|
||||
uint8_t buff[4];
|
||||
char buff[4];
|
||||
|
||||
if (pin < 0 || pin > 127)
|
||||
return (0);
|
||||
|
@@ -84,6 +84,7 @@ mraa_result_t
|
||||
mraa_firmata_close(mraa_firmata_context dev)
|
||||
{
|
||||
mraa_firmata_response_stop(dev);
|
||||
pthread_spin_destroy(&firmata_dev->lock);
|
||||
free(dev);
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
@@ -92,7 +93,7 @@ static mraa_result_t
|
||||
mraa_firmata_i2c_init_bus_replace(mraa_i2c_context dev)
|
||||
{
|
||||
int delay = 1; // this should be either 1 or 0, I don't know :)
|
||||
uint8_t buff[4];
|
||||
char buff[4];
|
||||
buff[0] = FIRMATA_START_SYSEX;
|
||||
buff[1] = FIRMATA_I2C_CONFIG;
|
||||
buff[2] = delay & 0xFF, (delay >> 8) & 0xFF;
|
||||
@@ -120,7 +121,7 @@ mraa_firmata_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode)
|
||||
static mraa_result_t
|
||||
mraa_firmata_send_i2c_read_req(mraa_i2c_context dev, int length)
|
||||
{
|
||||
uint8_t* buffer = calloc(7, 0);
|
||||
char* buffer = calloc(7, 0);
|
||||
if (buffer == NULL) {
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
@@ -149,7 +150,7 @@ mraa_firmata_send_i2c_read_req(mraa_i2c_context dev, int length)
|
||||
static mraa_result_t
|
||||
mraa_firmata_send_i2c_read_reg_req(mraa_i2c_context dev, uint8_t command, int length)
|
||||
{
|
||||
uint8_t* buffer = calloc(9, 0);
|
||||
char* buffer = calloc(9, 0);
|
||||
if (buffer == NULL) {
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
@@ -182,11 +183,17 @@ static mraa_result_t
|
||||
mraa_firmata_i2c_wait(int addr, int reg)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; firmata_dev->i2cmsg[addr][reg] == -1; i++) {
|
||||
if (i > 50) {
|
||||
if (pthread_spin_lock(&firmata_dev->lock) != 0) return MRAA_ERROR_UNSPECIFIED;
|
||||
int res = firmata_dev->i2cmsg[addr][reg];
|
||||
if (pthread_spin_unlock(&firmata_dev->lock) != 0) return MRAA_ERROR_UNSPECIFIED;
|
||||
for (; res == -1; i++) {
|
||||
if (i > 1000) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
usleep(500);
|
||||
usleep(50);
|
||||
if (pthread_spin_lock(&firmata_dev->lock) != 0) return MRAA_ERROR_UNSPECIFIED;
|
||||
res = firmata_dev->i2cmsg[addr][reg];
|
||||
if (pthread_spin_unlock(&firmata_dev->lock) != 0) return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
@@ -224,9 +231,16 @@ mraa_firmata_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
|
||||
static int
|
||||
mraa_firmata_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length)
|
||||
{
|
||||
uint32_t *local_storage = (uint32_t*) calloc(length, sizeof(int));
|
||||
if (mraa_firmata_send_i2c_read_reg_req(dev, command, length) == MRAA_SUCCESS) {
|
||||
if (mraa_firmata_i2c_wait(dev->addr, command) == MRAA_SUCCESS) {
|
||||
memcpy(data, &firmata_dev->i2cmsg[dev->addr][command], sizeof(int)*length);
|
||||
memcpy(local_storage, &firmata_dev->i2cmsg[dev->addr][command], sizeof(int)*length);
|
||||
int x = 0;
|
||||
for(; x<length; x++){
|
||||
data[x] = (uint8_t) local_storage[x];
|
||||
}
|
||||
free(local_storage);
|
||||
|
||||
return length;
|
||||
}
|
||||
}
|
||||
@@ -239,7 +253,7 @@ mraa_firmata_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
|
||||
if (mraa_firmata_send_i2c_read_req(dev, length) == MRAA_SUCCESS) {
|
||||
if (mraa_firmata_i2c_wait(dev->addr, 0) == MRAA_SUCCESS) {
|
||||
int i = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
for (; i < length; i++) {
|
||||
data[i] = firmata_dev->i2cmsg[dev->addr][i];
|
||||
}
|
||||
return length;
|
||||
@@ -266,7 +280,7 @@ mraa_firmata_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWri
|
||||
{
|
||||
// buffer needs 5 bytes for firmata, and 2 bytes for every byte of data
|
||||
int buffer_size = (bytesToWrite*2) + 5;
|
||||
uint8_t* buffer = calloc(buffer_size, 0);
|
||||
char* buffer = calloc(buffer_size, 0);
|
||||
if (buffer == NULL) {
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
@@ -277,7 +291,7 @@ mraa_firmata_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWri
|
||||
buffer[2] = dev->addr;
|
||||
buffer[3] = I2C_MODE_WRITE << 3;
|
||||
// we need to write until FIRMATA_END_SYSEX
|
||||
for (i; i < (buffer_size-1); i++) {
|
||||
for (; i < (buffer_size-1); i++) {
|
||||
buffer[ii] = data[i] & 0x7F;
|
||||
buffer[ii+1] = (data[i] >> 7) & 0x7f;
|
||||
ii = ii+2;
|
||||
@@ -291,7 +305,7 @@ mraa_firmata_i2c_write(mraa_i2c_context dev, const uint8_t* data, int bytesToWri
|
||||
static mraa_result_t
|
||||
mraa_firmata_i2c_write_byte(mraa_i2c_context dev, uint8_t data)
|
||||
{
|
||||
uint8_t* buffer = calloc(7, 0);
|
||||
char* buffer = calloc(7, 0);
|
||||
if (buffer == NULL) {
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
@@ -310,7 +324,7 @@ mraa_firmata_i2c_write_byte(mraa_i2c_context dev, uint8_t data)
|
||||
static mraa_result_t
|
||||
mraa_firmata_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
|
||||
{
|
||||
uint8_t* buffer = calloc(9, 0);
|
||||
char* buffer = calloc(9, 0);
|
||||
if (buffer == NULL) {
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
}
|
||||
@@ -345,7 +359,10 @@ mraa_firmata_aio_read(mraa_aio_context dev)
|
||||
{
|
||||
// careful, whilst you need to enable '0' for A0 you then need to read 14
|
||||
// in t_firmata because well that makes sense doesn't it...
|
||||
return (int) firmata_dev->pins[dev->channel].value;
|
||||
if (pthread_spin_lock(&firmata_dev->lock) != 0) return -1;
|
||||
int ret = (int) firmata_dev->pins[dev->channel].value;
|
||||
if (pthread_spin_unlock(&firmata_dev->lock) != 0) return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static mraa_result_t
|
||||
@@ -380,7 +397,10 @@ mraa_firmata_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_t mode)
|
||||
static int
|
||||
mraa_firmata_gpio_read_replace(mraa_gpio_context dev)
|
||||
{
|
||||
return firmata_dev->pins[dev->pin].value;
|
||||
if (pthread_spin_lock(&firmata_dev->lock) != 0) return -1;
|
||||
int res = firmata_dev->pins[dev->pin].value;
|
||||
if (pthread_spin_unlock(&firmata_dev->lock) != 0) return -1;
|
||||
return res;
|
||||
}
|
||||
|
||||
static mraa_result_t
|
||||
@@ -517,6 +537,8 @@ mraa_firmata_pull_handler(void* vp)
|
||||
isr_prev = isr_now;
|
||||
usleep(100);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mraa_board_t*
|
||||
@@ -537,7 +559,7 @@ mraa_firmata_plat_init(const char* uart_dev)
|
||||
|
||||
// if this isn't working then we have an issue with our uart
|
||||
int retry = 20;
|
||||
while (!firmata_dev->isReady && retry--) {
|
||||
while (!firmata_dev->isReady && --retry) {
|
||||
firmata_pull(firmata_dev);
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,7 @@ static mraa_result_t
|
||||
mraa_gpio_get_valfp(mraa_gpio_context dev)
|
||||
{
|
||||
char bu[MAX_SIZE];
|
||||
sprintf(bu, SYSFS_CLASS_GPIO "/gpio%d/value", dev->pin);
|
||||
snprintf(bu, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/value", dev->pin);
|
||||
dev->value_fp = open(bu, O_RDWR);
|
||||
if (dev->value_fp == -1) {
|
||||
syslog(LOG_ERR, "gpio%i: Failed to open 'value': %s", dev->pin, strerror(errno));
|
||||
|
@@ -167,7 +167,7 @@ mraa_i2c_init(int bus)
|
||||
}
|
||||
if (!board->no_bus_mux) {
|
||||
int pos = board->i2c_bus[bus].sda;
|
||||
if (board->pins[pos].i2c.mux_total > 0) {
|
||||
if (pos >=0 && board->pins[pos].i2c.mux_total > 0) {
|
||||
if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) {
|
||||
syslog(LOG_ERR, "i2c%i_init: Failed to set-up i2c sda multiplexer", bus);
|
||||
return NULL;
|
||||
@@ -175,7 +175,7 @@ mraa_i2c_init(int bus)
|
||||
}
|
||||
|
||||
pos = board->i2c_bus[bus].scl;
|
||||
if (board->pins[pos].i2c.mux_total > 0) {
|
||||
if (pos >=0 && board->pins[pos].i2c.mux_total > 0) {
|
||||
if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) {
|
||||
syslog(LOG_ERR, "i2c%i_init: Failed to set-up i2c scl multiplexer", bus);
|
||||
return NULL;
|
||||
@@ -441,6 +441,7 @@ mraa_i2c_stop(mraa_i2c_context dev)
|
||||
return dev->advance_func->i2c_stop_replace(dev);
|
||||
}
|
||||
|
||||
close(dev->fh);
|
||||
free(dev);
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
@@ -309,7 +309,7 @@ mraa_iio_wait_event(int fd, char* data, int* read_size)
|
||||
|
||||
// Wait for it forever or until pthread_cancel
|
||||
// poll is a cancelable point like sleep()
|
||||
int x = poll(&pfd, 1, -1);
|
||||
poll(&pfd, 1, -1);
|
||||
|
||||
memset(data, 0, 100);
|
||||
*read_size = read(fd, data, 100);
|
||||
@@ -376,10 +376,7 @@ mraa_iio_get_event_data(mraa_iio_context dev)
|
||||
char buf[MAX_SIZE];
|
||||
char readbuf[32];
|
||||
int fd;
|
||||
int ret = 0;
|
||||
int padint = 0;
|
||||
int curr_bytes = 0;
|
||||
char shortbuf, signchar;
|
||||
|
||||
memset(buf, 0, MAX_SIZE);
|
||||
memset(readbuf, 0, 32);
|
||||
snprintf(buf, MAX_SIZE, IIO_SYSFS_DEVICE "%d/" IIO_EVENTS, dev->num);
|
||||
@@ -441,7 +438,7 @@ mraa_iio_event_poll_nonblock(int fd, struct iio_event_data* data)
|
||||
|
||||
// Wait for it forever or until pthread_cancel
|
||||
// poll is a cancelable point like sleep()
|
||||
int x = poll(&pfd, 1, -1);
|
||||
poll(&pfd, 1, -1);
|
||||
|
||||
read(fd, data, sizeof(struct iio_event_data));
|
||||
|
||||
@@ -573,9 +570,7 @@ mraa_result_t
|
||||
mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger)
|
||||
{
|
||||
struct stat configfs_status;
|
||||
struct stat trigger_status;
|
||||
char buf[MAX_SIZE];
|
||||
int ret;
|
||||
|
||||
if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) {
|
||||
memset(buf, 0, MAX_SIZE);
|
||||
|
@@ -1,4 +1,11 @@
|
||||
FIND_PACKAGE (JNI REQUIRED)
|
||||
|
||||
if (PERIPHERALMAN)
|
||||
# Override the JNI include directory for Android Things since these
|
||||
# will require an Android-friendly jni.h
|
||||
set(JAVA_INCLUDE_PATH "${ANDROID_SYSROOT}/usr/include")
|
||||
endif()
|
||||
|
||||
include_directories (
|
||||
${JAVA_INCLUDE_PATH}
|
||||
${JAVA_INCLUDE_PATH2}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
%typemap(javain) (uint8_t *txBuf, int length) "$javainput"
|
||||
|
||||
%typemap(in,numinputs=1) (uint8_t *txBuf, int length) {
|
||||
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$2 = JCALL1(GetArrayLength, jenv, $input);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
}
|
||||
|
||||
%typemap(argout) (uint8_t *data, int length) {
|
||||
JCALL3(ReleaseByteArrayElements, jenv, $input, $1, JNI_COMMIT);
|
||||
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, JNI_COMMIT);
|
||||
}
|
||||
|
||||
%typemap(jtype) (const uint8_t *data, int length) "byte[]"
|
||||
@@ -31,7 +31,16 @@
|
||||
%typemap(jni) (const uint8_t *data, int length) "jbyteArray"
|
||||
%typemap(javain) (const uint8_t *data, int length) "$javainput"
|
||||
%typemap(in) (const uint8_t *data, int length) {
|
||||
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$2 = JCALL1(GetArrayLength, jenv, $input);
|
||||
}
|
||||
|
||||
%typemap(jtype) (uint8_t *data, int length) "byte[]"
|
||||
%typemap(jstype) (uint8_t *data, int length) "byte[]"
|
||||
%typemap(jni) (uint8_t *data, int length) "jbyteArray"
|
||||
%typemap(javain) (uint8_t *data, int length) "$javainput"
|
||||
%typemap(in) (uint8_t *data, int length) {
|
||||
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$2 = JCALL1(GetArrayLength, jenv, $input);
|
||||
}
|
||||
|
||||
@@ -97,33 +106,37 @@ class Spi;
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
String javaAPIVersion = mraa.class.getPackage().getSpecificationVersion();
|
||||
String nativeAPIVersion = mraa.getVersion().substring(1);
|
||||
if((mraa.class.getPackage().getSpecificationVersion() != null)
|
||||
&& !(mraa.class.getPackage().getSpecificationVersion().equals("0.0"))
|
||||
&& (mraa.getVersion() != null)){
|
||||
String javaAPIVersion = mraa.class.getPackage().getSpecificationVersion();
|
||||
String nativeAPIVersion = mraa.getVersion().substring(1);
|
||||
|
||||
String javaMajor = javaAPIVersion.substring(0, javaAPIVersion.indexOf('.'));
|
||||
String nativeMajor = nativeAPIVersion.substring(0, nativeAPIVersion.indexOf('.'));
|
||||
String javaMajor = javaAPIVersion.substring(0, javaAPIVersion.indexOf('.'));
|
||||
String nativeMajor = nativeAPIVersion.substring(0, nativeAPIVersion.indexOf('.'));
|
||||
|
||||
if(Integer.parseInt(javaMajor) < Integer.parseInt(nativeMajor)){
|
||||
System.err.println("Java library is out of date. Please update the Java library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
System.exit(1);
|
||||
}
|
||||
if(Integer.parseInt(javaMajor) > Integer.parseInt(nativeMajor)){
|
||||
System.err.println("Native library is out of date. Please update the Native library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
System.exit(1);
|
||||
}
|
||||
if(Integer.parseInt(javaMajor) < Integer.parseInt(nativeMajor)){
|
||||
System.err.println("Java library is out of date. Please update the Java library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
System.exit(1);
|
||||
}
|
||||
if(Integer.parseInt(javaMajor) > Integer.parseInt(nativeMajor)){
|
||||
System.err.println("Native library is out of date. Please update the Native library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
String javaMinor = javaAPIVersion.substring(javaMajor.length() + 1, javaAPIVersion.indexOf('.', javaMajor.length() + 1));
|
||||
String nativeMinor = nativeAPIVersion.substring(nativeMajor.length() + 1, nativeAPIVersion.indexOf('.', nativeMajor.length() + 1));
|
||||
String javaMinor = javaAPIVersion.substring(javaMajor.length() + 1, javaAPIVersion.indexOf('.', javaMajor.length() + 1));
|
||||
String nativeMinor = nativeAPIVersion.substring(nativeMajor.length() + 1, nativeAPIVersion.indexOf('.', nativeMajor.length() + 1));
|
||||
|
||||
if(Integer.parseInt(javaMinor) < Integer.parseInt(nativeMinor)){
|
||||
System.err.println("Java library is out of date. Please consider updating the Java library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
}
|
||||
if(Integer.parseInt(javaMinor) > Integer.parseInt(nativeMinor)){
|
||||
System.err.println("Native library is out of date. Please consider updating the Native library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
if(Integer.parseInt(javaMinor) < Integer.parseInt(nativeMinor)){
|
||||
System.err.println("Java library is out of date. Please consider updating the Java library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
}
|
||||
if(Integer.parseInt(javaMinor) > Integer.parseInt(nativeMinor)){
|
||||
System.err.println("Native library is out of date. Please consider updating the Native library.");
|
||||
System.err.println("Native library version is " + nativeAPIVersion + ". Java library version is " + javaAPIVersion + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
38
src/java/pom.xml.in
Normal file
38
src/java/pom.xml.in
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.mraa</groupId>
|
||||
<artifactId>mraa</artifactId>
|
||||
<version>@VERSION_SHORT@</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mraa</name>
|
||||
<description>Low Level Skeleton Library for IO Communication on GNU/Linux platforms</description>
|
||||
<url>http://mraa.io</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>https://github.com/intel-iot-devkit/mraa/blob/master/COPYING</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Mraa contributors https://github.com/intel-iot-devkit/mraa/graphs/contributors</name>
|
||||
<email>mraa@lists.01.org</email>
|
||||
<organization>Intel IoT Developer kit</organization>
|
||||
<organizationUrl>https://github.com/intel-iot-devkit</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/intel-iot-devkit/mraa.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:intel-iot-devkit/mraa.git</developerConnection>
|
||||
<url>https://github.com/intel-iot-devkit/mraa/tree/master</url>
|
||||
</scm>
|
||||
|
||||
</project>
|
@@ -120,5 +120,5 @@ if (BUILDDOC)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.node
|
||||
install (TARGETS ${SWIG_MODULE_mraajs_REAL_NAME}
|
||||
DESTINATION ${NODE_MODULE_INSTALL_PATH})
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user