Compare commits
352 Commits
pythonmult
...
examples
Author | SHA1 | Date | |
---|---|---|---|
|
eaaebae69d | ||
|
e562c774cf | ||
|
3fb65de4b8 | ||
|
d538bbc91f | ||
|
64fe50ffa8 | ||
|
54c9c1aff1 | ||
|
44bebc4f87 | ||
|
1176fcf671 | ||
|
02963b791a | ||
|
ec26f92fe6 | ||
|
c24a8f8b20 | ||
|
e1382ad845 | ||
|
e7b51f3b66 | ||
|
b5efa0e591 | ||
|
c45ba13ec0 | ||
|
a7a3b39e30 | ||
|
6770be911b | ||
|
668776fbfd | ||
|
c6dbe76116 | ||
|
e9d1b1ef28 | ||
|
c6d49f6255 | ||
|
3f3f657887 | ||
|
99287f40a1 | ||
|
721c5533eb | ||
|
1a4ba6a7d3 | ||
|
eb7238d9af | ||
|
5b2ecd18ae | ||
|
cc55ee6314 | ||
|
c6b1b18a9d | ||
|
64a0db6a50 | ||
|
04a40ed63f | ||
|
6fad8d9888 | ||
|
2e2cd37cfa | ||
|
d78ad91635 | ||
|
45127e04b9 | ||
|
6185f0ac92 | ||
|
8356c2f03d | ||
|
615e0cd83a | ||
|
6a1ed23246 | ||
|
c2787441b4 | ||
|
e2f964a280 | ||
|
65e30bf7d3 | ||
|
1217c5c034 | ||
|
d50b646c35 | ||
|
badf25f289 | ||
|
ba72c5b089 | ||
|
c4e23e1a41 | ||
|
e0a1862ce3 | ||
|
14bf91af44 | ||
|
f71b4be059 | ||
|
0b1ccf526f | ||
|
46e5aab56e | ||
|
8f57b21a26 | ||
|
808d314043 | ||
|
95068c4259 | ||
|
189b959012 | ||
|
4bedd68c4e | ||
|
3d77c86634 | ||
|
5bbea8010e | ||
|
86e7ece2f6 | ||
|
08c7c0215e | ||
|
4f3eae90e8 | ||
|
7d6164c136 | ||
|
be9fcf2b2d | ||
|
fc00fa20d2 | ||
|
caf75a68c0 | ||
|
bd3d9d8cab | ||
|
3f932ac952 | ||
|
d544e3c2f6 | ||
|
30bbb88685 | ||
|
e0052acfa7 | ||
|
3731f88c4f | ||
|
869f76c5c5 | ||
|
e1778c811d | ||
|
09f8b3ac7b | ||
|
32196d10e9 | ||
|
000746c20d | ||
|
4109b8b454 | ||
|
c36e4add5a | ||
|
32340f6819 | ||
|
bb3584fcdb | ||
|
ff03b2de1d | ||
|
79da382832 | ||
|
131ff46a0d | ||
|
f927bffb16 | ||
|
8133de0cc0 | ||
|
ecb53c8501 | ||
|
1d37d3b162 | ||
|
722b83b95c | ||
|
822160b7de | ||
|
98e755d147 | ||
|
2980e211db | ||
|
69f7d09103 | ||
|
56d5666ae9 | ||
|
a6f2464bb1 | ||
|
d6edf76680 | ||
|
b7e8d96945 | ||
|
04c5593cef | ||
|
818ae995c2 | ||
|
47c21e0b6c | ||
|
816be65ba0 | ||
|
b73fdff00d | ||
|
398b851144 | ||
|
5ef3f3ea29 | ||
|
9479843cde | ||
|
dc1255ad75 | ||
|
9545a2e320 | ||
|
0654183b9a | ||
|
918e2b18e2 | ||
|
e7b0a3e809 | ||
|
8ddbcde84e | ||
|
a0332b14b5 | ||
|
def0a6aed1 | ||
|
9d65d6e0f0 | ||
|
4b08887c54 | ||
|
e0a0dac47b | ||
|
6d5b2c0642 | ||
|
075a7b1225 | ||
|
43d9f6c400 | ||
|
1379c1fe33 | ||
|
80335b18b6 | ||
|
be2bd63223 | ||
|
35e17ee25a | ||
|
ef2fddc1e1 | ||
|
ce0edf0f62 | ||
|
038a7c542a | ||
|
aeb293a163 | ||
|
87fda62759 | ||
|
3e19a58710 | ||
|
380d2cf638 | ||
|
1d200840f4 | ||
|
34b4d4a97b | ||
|
913eaf2440 | ||
|
7bc069a8fd | ||
|
beaba463f7 | ||
|
567a92fde5 | ||
|
4270e7a743 | ||
|
a2ee056c7d | ||
|
e607beedda | ||
|
c4555bc4e5 | ||
|
1cec6705d1 | ||
|
9a306fc1f5 | ||
|
8a1c58bc7f | ||
|
76850eb0f4 | ||
|
0ec90a3138 | ||
|
60ca81a3e1 | ||
|
533517a864 | ||
|
69fcd861a7 | ||
|
4c7616fe91 | ||
|
d7fb6c5af9 | ||
|
9cb0440955 | ||
|
2f51627d18 | ||
|
05d4a917e5 | ||
|
0d6700fe50 | ||
|
791fe0c05a | ||
|
ecc64da418 | ||
|
6d004ca80d | ||
|
f911e0620e | ||
|
bf548a3377 | ||
|
cac8f7a47a | ||
|
65f7d2a250 | ||
|
b937c521f6 | ||
|
48fe5cebbb | ||
|
d2bbfe376d | ||
|
a3f5db1d84 | ||
|
2a1590fdf1 | ||
|
5e34a5cd3b | ||
|
6f4b333a31 | ||
|
dd19634889 | ||
|
21e0ff7c02 | ||
|
b24e90db0c | ||
|
1c4b1fc329 | ||
|
f6f124a35f | ||
|
c7a4a6db34 | ||
|
0004dfeefb | ||
|
0470aebee6 | ||
|
23fd11c4f7 | ||
|
875289ab94 | ||
|
c69b6312fa | ||
|
b20fe9163a | ||
|
b453f6633b | ||
|
06359e39cd | ||
|
68c6a8df49 | ||
|
03fb882ce2 | ||
|
ff2eba732e | ||
|
694e6eab23 | ||
|
4264aa5a3b | ||
|
0092e13f57 | ||
|
2c529689ed | ||
|
fc03ea4816 | ||
|
caabca37be | ||
|
2ea68105f0 | ||
|
6fabccf131 | ||
|
19d69b71da | ||
|
e606d1d615 | ||
|
4472ff1629 | ||
|
72261d61bd | ||
|
e38630097e | ||
|
c3332f5542 | ||
|
3bd590c18c | ||
|
17b147ba82 | ||
|
4b22a923cf | ||
|
af051d820a | ||
|
2558866d4a | ||
|
c1017bb6ea | ||
|
1c180e393c | ||
|
250590e1ed | ||
|
68e9399c4c | ||
|
ad6eb53f81 | ||
|
d2f1b068b7 | ||
|
a0332a13b0 | ||
|
a63ad7e10d | ||
|
9de294b389 | ||
|
61d20c7266 | ||
|
d043faf687 | ||
|
6f9b470d8d | ||
|
92188ab950 | ||
|
3d790a8278 | ||
|
dbcba5cbeb | ||
|
ef8102deb1 | ||
|
7b7b11415b | ||
|
5a3f73731c | ||
|
e466d1f890 | ||
|
ae127b19a5 | ||
|
fe76260837 | ||
|
bf4d14ef02 | ||
|
d602196bd6 | ||
|
e387946208 | ||
|
fa35855bb6 | ||
|
4a33aca8fd | ||
|
9d365ce0d6 | ||
|
23e871c5bb | ||
|
3bb17bb7b9 | ||
|
8218e42d41 | ||
|
3971d27f8a | ||
|
c69d1884c9 | ||
|
cada819c39 | ||
|
0b5130335d | ||
|
b4cf93f1f8 | ||
|
c7ff9a5173 | ||
|
c993cf10b4 | ||
|
623fef670e | ||
|
bb5ec8bd10 | ||
|
a3c717553c | ||
|
6ce1b1c4ce | ||
|
9f03afbcbc | ||
|
8a9efd1bcc | ||
|
1b3a9371a1 | ||
|
ccc4185eff | ||
|
6fda865af7 | ||
|
dd33a32744 | ||
|
7d1ee0c6fe | ||
|
19791be2f5 | ||
|
49ef1623b2 | ||
|
37deb5003b | ||
|
980dfce80e | ||
|
08e270818a | ||
|
6bac8594a5 | ||
|
11bbd05533 | ||
|
1d4b19dc4b | ||
|
02a7fbf191 | ||
|
ae15b10997 | ||
|
be22844922 | ||
|
92fdb8aa01 | ||
|
def454e33c | ||
|
122cab1f1e | ||
|
6c85b61daa | ||
|
139d42d084 | ||
|
8e38c762f0 | ||
|
590f733ff9 | ||
|
045ceb084f | ||
|
ff3b3004da | ||
|
5cb2bd220e | ||
|
8ec4fcb333 | ||
|
bf2a504774 | ||
|
9bc91f4b12 | ||
|
6180ddaa8e | ||
|
8a93351f0e | ||
|
1591b92605 | ||
|
22b0f63238 | ||
|
2832909856 | ||
|
636c9feb4f | ||
|
0292c960b3 | ||
|
9ff47aa64a | ||
|
a704a956ea | ||
|
94b7477212 | ||
|
1589389c3f | ||
|
bdbbfd03dd | ||
|
9030ae2eeb | ||
|
3a638caf01 | ||
|
07f6181c91 | ||
|
0630c5f505 | ||
|
4277a3ee23 | ||
|
c976e9f982 | ||
|
d700cae7c4 | ||
|
356096350b | ||
|
b4919de733 | ||
|
49ee1ebef5 | ||
|
c0fbccb3b6 | ||
|
fce4daab02 | ||
|
29be2b64c0 | ||
|
50213f97bc | ||
|
e675123d50 | ||
|
36153ad7ad | ||
|
aed965c27d | ||
|
5d763cb7e5 | ||
|
5d94d0a13c | ||
|
ca0d740ee0 | ||
|
c7570ff7c2 | ||
|
a8a7771a16 | ||
|
1ce0b138d2 | ||
|
8ba8ce3b26 | ||
|
346f447c4d | ||
|
26718a67a2 | ||
|
0021b1aace | ||
|
da3efdc4b9 | ||
|
230b6084ba | ||
|
8cd1a06562 | ||
|
874d0f47bd | ||
|
6c9aeb9b9e | ||
|
63b244cfc3 | ||
|
917a1bd371 | ||
|
e43459d031 | ||
|
eabee5f864 | ||
|
a22ff43f59 | ||
|
1af737f3d9 | ||
|
bcb6adc551 | ||
|
593fd0be54 | ||
|
3992f9d596 | ||
|
43718e7cbf | ||
|
d336e9f8d6 | ||
|
9634f17a2a | ||
|
dfecc68320 | ||
|
b9a6d2a86a | ||
|
bc178b27ee | ||
|
fe9264c98f | ||
|
de0543923c | ||
|
b1d23303f7 | ||
|
c1fd2896c2 | ||
|
5704c15665 | ||
|
b5b84c6186 | ||
|
0bd488bc53 | ||
|
f9bc314223 | ||
|
50e1b568fb | ||
|
a54386c5d3 | ||
|
0577321f4c | ||
|
5f515f7648 | ||
|
3d2163e2cb | ||
|
8af6843566 | ||
|
c413a43d5a | ||
|
03b548c33b | ||
|
5160d909d3 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
build/
|
||||
install/
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
@@ -20,3 +21,9 @@ package.json
|
||||
binding.gyp
|
||||
READMEFIRST
|
||||
npm-debug.log
|
||||
|
||||
# Sonar
|
||||
.scannerwork/
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/
|
||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,4 +1,8 @@
|
||||
[submodule "doxygen2jsdoc"]
|
||||
path = doxygen2jsdoc
|
||||
url = https://github.com/arfoll/doxygen2jsdoc.git
|
||||
url = https://github.com/intel-iot-devkit/doxygen2jsdoc.git
|
||||
branch = master
|
||||
[submodule "doxyport"]
|
||||
path = doxyport
|
||||
url = https://github.com/intel-iot-devkit/doxyport.git
|
||||
branch = master
|
||||
|
133
.travis.yml
133
.travis.yml
@@ -1,34 +1,101 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
language: cpp
|
||||
env:
|
||||
- NODE010=true
|
||||
- NODE012=true
|
||||
- NODE4=true
|
||||
- NODE5=true
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
install:
|
||||
- if [ "${NODE4}" ]; then export CC=gcc-4.8 CXX=g++-4.8; fi
|
||||
- sudo add-apt-repository --yes ppa:kalakris/cmake
|
||||
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y -qq swig3.0 python git cmake
|
||||
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
|
||||
- sudo update-java-alternatives -s java-8-oracle
|
||||
before_script:
|
||||
# Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
|
||||
- if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
|
||||
- if [ "${NODE012}" ]; then nvm install 0.12; fi
|
||||
- if [ "${NODE4}" ]; then nvm install 4.1; fi
|
||||
- if [ "${NODE5}" ]; then nvm install 5; fi
|
||||
# Handle 0.10 NODE_ROOT_DIR differently than other versions
|
||||
- if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
|
||||
script:
|
||||
- echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
|
||||
- mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DCMAKE_INSTALL_PREFIX:PATH=../install .. && make install && make test
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.8
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- sudo rm /usr/local/bin/docker-compose
|
||||
- curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
|
||||
jobs:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: TARGET=ipk
|
||||
include:
|
||||
- &run-with-clang
|
||||
stage: Clang 3.8
|
||||
env: TARGET=python2
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=clang-3.8 CXX=clang++-3.8
|
||||
- docker-compose run ${TARGET}
|
||||
- BUILDARCH=MOCK docker-compose run ${TARGET}
|
||||
- if [[ ${TARGET} != *"node"* ]]; then JSONPLAT=ON docker-compose run ${TARGET}; fi
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=python3
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=node4
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=node5
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=node6
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=java
|
||||
- &run-with-gcc-5
|
||||
stage: Gcc 5
|
||||
env: TARGET=python2
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=gcc-5 CXX=g++-5
|
||||
- docker-compose run ${TARGET}
|
||||
- BUILDARCH=MOCK docker-compose run ${TARGET}
|
||||
- if [[ ${TARGET} != *"node"* ]]; then JSONPLAT=ON docker-compose run ${TARGET}; fi
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=python3
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=node4
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=node5
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=node6
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=java
|
||||
- &run-with-gcc-6
|
||||
stage: Gcc 6
|
||||
env: TARGET=python2
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=gcc-6 CXX=g++-6
|
||||
- docker-compose run ${TARGET}
|
||||
- BUILDARCH=MOCK docker-compose run ${TARGET}
|
||||
- if [[ ${TARGET} != *"node"* ]]; then JSONPLAT=ON docker-compose run ${TARGET}; fi
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=python3
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=node4
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=node5
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=node6
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=java
|
||||
- &run-additional-jobs
|
||||
stage: Additional Jobs
|
||||
env: TARGET=doc
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=clang-3.8 CXX=clang++-3.8
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=android
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=examples
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=usbplat
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=firmata
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=imraa
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=ftdi4442
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=ipk
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=rpm
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=sonar-scan
|
||||
|
61
Android.mk
61
Android.mk
@@ -1,61 +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
|
||||
|
||||
# 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.0.0-dirty")
|
||||
set (VERSION "v1.8.0")
|
||||
endif ()
|
||||
|
||||
message (STATUS "INFO - libmraa Version ${VERSION}")
|
||||
@@ -71,17 +131,19 @@ option (BUILDSWIGJAVA "Build Java API." OFF)
|
||||
option (USBPLAT "Detection USB platform." OFF)
|
||||
option (FIRMATA "Add Firmata support to mraa." OFF)
|
||||
option (ONEWIRE "Add Onewire support to mraa." ON)
|
||||
option (JSONPLAT "Add Platform loading via a json file." ON)
|
||||
option (IMRAA "Add Imraa support to mraa." OFF)
|
||||
option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
|
||||
option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
option (ENABLEEXAMPLES "Disable building of examples" ON)
|
||||
option (INSTALLGPIOTOOL "Install gpio tool" OFF)
|
||||
option (INSTALLTOOLS "Install all tools" OFF)
|
||||
option (BUILDARCH "Override architecture to build for - override" OFF)
|
||||
option (INSTALLTOOLS "Install all tools" ON)
|
||||
option (BUILDTESTS "Override the addition of tests" ON)
|
||||
option (USEPYTHON3TESTS "Force tests to run with python3" OFF)
|
||||
|
||||
set (MRAAPLATFORMFORCE "" CACHE STRING "ALL")
|
||||
set (BUILDARCH "" CACHE STRING "Override architecture to build for")
|
||||
|
||||
set (MRAAPLATFORMFORCE "ALL" CACHE STRING "Override platform to build for")
|
||||
|
||||
if (NOT BUILDSWIG)
|
||||
set (BUILDSWIGPYTHON OFF)
|
||||
@@ -103,8 +165,14 @@ if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
|
||||
set (X86PLAT ON)
|
||||
elseif (DETECTED_ARCH MATCHES "arm.*")
|
||||
set (ARMPLAT ON)
|
||||
elseif (DETECTED_ARCH MATCHES "mips")
|
||||
set (MIPSPLAT ON)
|
||||
elseif (DETECTED_ARCH STREQUAL "MOCK")
|
||||
set (MOCKPLAT ON)
|
||||
elseif (DETECTED_ARCH STREQUAL "PERIPHERALMAN")
|
||||
set (PERIPHERALMAN ON)
|
||||
else ()
|
||||
message (FATAL_ERROR "Only x86 and arm platforms currently supported")
|
||||
message (FATAL_ERROR "Only x86, arm, mips, PERIPHERALMAN and mock platforms currently supported")
|
||||
endif()
|
||||
|
||||
if (BUILDSWIGPYTHON OR BUILDTESTS)
|
||||
@@ -113,8 +181,8 @@ endif ()
|
||||
|
||||
if (BUILDDOC)
|
||||
# add a target to generate API documentation with Doxygen
|
||||
find_package (Doxygen)
|
||||
if (DOXYGEN_FOUND)
|
||||
find_package (Doxygen 1.8 REQUIRED)
|
||||
if (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
if (BUILDSWIGJAVA)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/src/java/Doxyfile @ONLY)
|
||||
@@ -124,7 +192,9 @@ if (BUILDDOC)
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
endif (DOXYGEN_FOUND)
|
||||
else ()
|
||||
message (SEND_ERROR "ERROR - Failed to find a compatible version of Doxygen. API doc will not be generated")
|
||||
endif (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
|
||||
endif ()
|
||||
|
||||
if (IPK)
|
||||
@@ -200,3 +270,7 @@ if (BUILDTESTS AND PYTHON_DEFAULT_EXECUTABLE)
|
||||
enable_testing ()
|
||||
add_subdirectory (tests)
|
||||
endif ()
|
||||
|
||||
if (INSTALLTOOLS)
|
||||
add_subdirectory (tools)
|
||||
endif()
|
||||
|
@@ -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
|
||||
------------
|
||||
|
||||
|
2
COPYING
2
COPYING
@@ -1,5 +1,5 @@
|
||||
The MIT License (MIT)
|
||||
Copyright © 2014-2016 Intel Corporation
|
||||
Copyright © 2014-2018 Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
@@ -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
|
||||
@@ -832,7 +832,7 @@ RECURSIVE = NO
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE =
|
||||
EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/docs/index.java.md
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
@@ -866,7 +866,9 @@ EXCLUDE_SYMBOLS =
|
||||
# command).
|
||||
|
||||
EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/examples/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/examples/c \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/examples/c++/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/examples/platform/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/
|
||||
|
||||
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
|
||||
|
@@ -756,10 +756,9 @@ WARN_LOGFILE =
|
||||
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/api/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/api/mraa/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/CONTRIBUTING.md \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/CONTRIBUTING.md \
|
||||
@CMAKE_BINARY_DIR@/src/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/index.java.md \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/README.md
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/index.java.md
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@@ -797,7 +796,7 @@ RECURSIVE = YES
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE =
|
||||
EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/docs/index.md
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
@@ -1810,18 +1809,6 @@ GENERATE_XML = YES
|
||||
|
||||
XML_OUTPUT = xml
|
||||
|
||||
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_SCHEMA =
|
||||
|
||||
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_DTD =
|
||||
|
||||
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
|
||||
# listings (including syntax highlighting and cross-referencing information) to
|
||||
# the XML output. Note that enabling this will significantly increase the size
|
||||
|
105
README.md
105
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
|
||||
@@ -15,6 +16,8 @@ The intent is to make it easier for developers and sensor manufacturers to map
|
||||
their sensors & actuators on top of supported hardware and to allow control of
|
||||
low level communication protocol by high level languages & constructs.
|
||||
|
||||
[](https://travis-ci.org/intel-iot-devkit/mraa)
|
||||
|
||||
Supported Boards
|
||||
================
|
||||
|
||||
@@ -24,29 +27,111 @@ 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)
|
||||
* [UP Squared](../master/docs/up2.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)
|
||||
|
||||
MIPS
|
||||
---
|
||||
* [Linkit Smart 7688](../master/docs/linkit_7688.md)
|
||||
* [Onion Omega2](../master/docs/omega2.md)
|
||||
|
||||
FPGA
|
||||
----
|
||||
* [DE10-Nano](../master/docs/de_nano_soc.md)
|
||||
|
||||
USB
|
||||
---
|
||||
* [FT4222](../master/docs/ftdi_ft4222.md)
|
||||
* [Firmata](../master/docs/firmata.md)
|
||||
|
||||
I2C
|
||||
---
|
||||
* [GrovePi](../master/docs/grovepi.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 libmraa-java python-mraa python3-mraa node-mraa mraa-tools
|
||||
```
|
||||
|
||||
Running MRAA tools or applications on Ubuntu systems requires elevated permissions
|
||||
(e.g. run with `sudo`).
|
||||
|
||||
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 currently 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
|
||||
```
|
||||
@@ -55,19 +140,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
|
||||
=========
|
||||
|
||||
|
@@ -34,6 +34,7 @@ extern "C" {
|
||||
#include "mraa/i2c.h"
|
||||
#include "mraa/uart.h"
|
||||
#include "mraa/uart_ow.h"
|
||||
#include "mraa/led.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -31,3 +31,4 @@
|
||||
#include "mraa/i2c.hpp"
|
||||
#include "mraa/spi.hpp"
|
||||
#include "mraa/uart.hpp"
|
||||
#include "mraa/led.hpp"
|
||||
|
@@ -30,7 +30,7 @@
|
||||
* AIO is the anlog input & output interface to libmraa. It is used to read or
|
||||
* set the voltage applied to an AIO pin.
|
||||
*
|
||||
* @snippet analogin_a0.c Interesting
|
||||
* @snippet aio.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -51,7 +51,9 @@ extern "C" {
|
||||
typedef struct _aio* mraa_aio_context;
|
||||
|
||||
/**
|
||||
* Initialise an Analog input device, connected to the specified pin
|
||||
* Initialise an Analog input device, connected to the specified pin. Aio pins
|
||||
* are always 0 indexed reguardless of their position. Check your board mapping
|
||||
* for details. An arduino style layout will have A0 as pin14 but AIO0.
|
||||
*
|
||||
* @param pin Channel number to read ADC inputs
|
||||
* @returns aio context or NULL
|
||||
|
@@ -56,9 +56,11 @@ class Aio
|
||||
}
|
||||
/**
|
||||
* Aio Constructor, takes a pointer to the AIO context and initialises
|
||||
* the AIO class
|
||||
* the AIO class. Aio pins are always 0 indexed reguardless of their
|
||||
* position. Check your board mapping for details. An arduino style layout
|
||||
* will have A0 as pin14 but AIO0.
|
||||
*
|
||||
* @param void * to an AIO context
|
||||
* @param aio_context void * to an AIO context
|
||||
*/
|
||||
Aio(void* aio_context)
|
||||
{
|
||||
|
@@ -27,13 +27,19 @@
|
||||
#include <stdint.h>
|
||||
#include "types.h"
|
||||
|
||||
/** Max size off Mraa Platform name */
|
||||
#define MRAA_PLATFORM_NAME_MAX_SIZE 64
|
||||
/** Size off Mraa pin name */
|
||||
#define MRAA_PIN_NAME_SIZE 12
|
||||
|
||||
/** Bit Shift for Mraa sub platform */
|
||||
#define MRAA_SUB_PLATFORM_BIT_SHIFT 9
|
||||
/** Mask for Mraa sub platform */
|
||||
#define MRAA_SUB_PLATFORM_MASK (1<<MRAA_SUB_PLATFORM_BIT_SHIFT)
|
||||
|
||||
/** Mraa main platform offset */
|
||||
#define MRAA_MAIN_PLATFORM_OFFSET 0
|
||||
/** Mraa sub platform offset */
|
||||
#define MRAA_SUB_PLATFORM_OFFSET 1
|
||||
|
||||
/** Executes function func and returns its result in case of error
|
||||
@@ -44,6 +50,7 @@
|
||||
if (res != MRAA_SUCCESS) \
|
||||
return res;} while(0)
|
||||
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared values for libmraa
|
||||
@@ -84,7 +91,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.
|
||||
@@ -105,7 +112,7 @@ unsigned int mraa_adc_raw_bits();
|
||||
/**
|
||||
* Check the specified board's bit size when reading the value
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 foor sub platform
|
||||
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
|
||||
* @return raw bits being read from kernel module. zero if no ADC
|
||||
*/
|
||||
unsigned int mraa_get_platform_adc_raw_bits(uint8_t platform_offset);
|
||||
@@ -120,7 +127,7 @@ unsigned int mraa_adc_supported_bits();
|
||||
/**
|
||||
* Return value that the raw value should be shifted to. Zero if no ADC
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 foor sub platform
|
||||
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
|
||||
* @return return actual bit size the adc value should be understood as.
|
||||
*/
|
||||
unsigned int mraa_get_platform_adc_supported_bits(int platform_offset);
|
||||
@@ -145,7 +152,7 @@ const char* mraa_get_platform_name();
|
||||
* platform and can be NULL. platform_offset has to be given. Do not modify
|
||||
* this pointer
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 for sub platform
|
||||
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
|
||||
* @return platform's versioning string
|
||||
*/
|
||||
const char* mraa_get_platform_version(int platform_offset);
|
||||
@@ -200,6 +207,41 @@ int mraa_get_platform_combined_type();
|
||||
*/
|
||||
unsigned int mraa_get_pin_count();
|
||||
|
||||
/**
|
||||
* Get the number of usable UARTs, board must be initialised.
|
||||
*
|
||||
* @return number of usable UARTs on the platform, returns -1 on failure.
|
||||
*/
|
||||
int mraa_get_uart_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable SPI buses, board must be initialised.
|
||||
*
|
||||
* @return number of usable SPI buses on the platform, returns -1 on failure.
|
||||
*/
|
||||
int mraa_get_spi_bus_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable PWM pins, board must be initialised.
|
||||
*
|
||||
* @return number of PWMs on the current platform, -1 on failure.
|
||||
*/
|
||||
int mraa_get_pwm_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable GPIOs, board must be initialised.
|
||||
*
|
||||
* @return number of usable external GPIO pins on the board, -1 on failure.
|
||||
*/
|
||||
int mraa_get_gpio_count(void);
|
||||
|
||||
/**
|
||||
* Get the number of usable analog pins, board must be initialised.
|
||||
*
|
||||
* @return number of usable ADC inputs on the platform and -1 on failure.
|
||||
*/
|
||||
int mraa_get_aio_bus_count(void);
|
||||
|
||||
/**
|
||||
* Get platform usable I2C bus count, board must be initialised.
|
||||
*
|
||||
@@ -219,7 +261,7 @@ int mraa_get_i2c_bus_id(int i2c_bus);
|
||||
/**
|
||||
* Get specified platform pincount, board must be initialised.
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 foor sub platform
|
||||
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
|
||||
* @return uint of physical pin count on the in-use platform
|
||||
*/
|
||||
unsigned int mraa_get_platform_pin_count(uint8_t platform_offset);
|
||||
@@ -232,6 +274,46 @@ unsigned int mraa_get_platform_pin_count(uint8_t platform_offset);
|
||||
*/
|
||||
char* mraa_get_pin_name(int pin);
|
||||
|
||||
/**
|
||||
* Get GPIO index by pin name, board must be initialised.
|
||||
*
|
||||
* @param pin_name: GPIO pin name. Eg: IO0
|
||||
* @return int of MRAA index for GPIO or -1 if not found.
|
||||
*/
|
||||
int mraa_gpio_lookup(const char* pin_name);
|
||||
|
||||
/**
|
||||
* Get I2C bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param i2c_name: I2C bus name. Eg: I2C6
|
||||
* @return int of MRAA index for I2C bus or -1 if not found.
|
||||
*/
|
||||
int mraa_i2c_lookup(const char* i2c_name);
|
||||
|
||||
/**
|
||||
* Get SPI bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param spi_name: Name of SPI bus. Eg: SPI2
|
||||
* @return int of MRAA index for SPI bus or -1 if not found.
|
||||
*/
|
||||
int mraa_spi_lookup(const char* spi_name);
|
||||
|
||||
/**
|
||||
* Get PWM index by PWM name, board must be initialised.
|
||||
*
|
||||
* @param pwm_name: Name of PWM. Eg:PWM0
|
||||
* @return int of MRAA index for PWM or -1 if not found.
|
||||
*/
|
||||
int mraa_pwm_lookup(const char* pwm_name);
|
||||
|
||||
/**
|
||||
* Get UART index by name, board must be initialised.
|
||||
*
|
||||
* @param uart_name: Name of UART. Eg:UART1
|
||||
* @return int of MRAA index for UART, or -1 if not found.
|
||||
*/
|
||||
int mraa_uart_lookup(const char* uart_name);
|
||||
|
||||
/**
|
||||
* Get default i2c bus, board must be initialised.
|
||||
*
|
||||
@@ -250,7 +332,7 @@ mraa_boolean_t mraa_has_sub_platform();
|
||||
/**
|
||||
* Check if pin or bus id includes sub platform mask.
|
||||
*
|
||||
* @param int pin or bus number
|
||||
* @param pin_or_bus_id pin or bus number
|
||||
*
|
||||
* @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
|
||||
*/
|
||||
@@ -259,7 +341,7 @@ mraa_boolean_t mraa_is_sub_platform_id(int pin_or_bus_id);
|
||||
/**
|
||||
* Convert pin or bus index to corresponding sub platform id.
|
||||
*
|
||||
* @param int pin or bus index
|
||||
* @param pin_or_bus_index pin or bus index
|
||||
*
|
||||
* @return int sub platform pin or bus number
|
||||
*/
|
||||
@@ -268,7 +350,7 @@ int mraa_get_sub_platform_id(int pin_or_bus_index);
|
||||
/**
|
||||
* Convert pin or bus sub platform id to index.
|
||||
*
|
||||
* @param int sub platform pin or bus id
|
||||
* @param pin_or_bus_id sub platform pin or bus id
|
||||
*
|
||||
* @return int pin or bus index
|
||||
*/
|
||||
@@ -277,17 +359,17 @@ int mraa_get_sub_platform_index(int pin_or_bus_id);
|
||||
/**
|
||||
* Add mraa subplatform
|
||||
*
|
||||
* @param subplatform type
|
||||
* @param uart device subplatform is on
|
||||
* @param subplatformtype subplatform type
|
||||
* @param dev uart device or i2c bus subplatform is on
|
||||
*
|
||||
* @return mraa_result_t indicating success
|
||||
*/
|
||||
mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev);
|
||||
mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char* dev);
|
||||
|
||||
/**
|
||||
* Remove a mraa subplatform
|
||||
*
|
||||
* @param subplatform type
|
||||
* @param subplatformtype subplatform type
|
||||
*
|
||||
* @return mraa_result indicating success
|
||||
*/
|
||||
@@ -300,12 +382,22 @@ mraa_result_t mraa_remove_subplatform(mraa_platform_t subplatformtype);
|
||||
* [io]-[raw]-[id]-[pin]
|
||||
* [io]-[raw]-[path]
|
||||
*
|
||||
* @param IO description
|
||||
* @param desc IO description
|
||||
*
|
||||
* @return void* to IO context or NULL
|
||||
*/
|
||||
void* mraa_init_io(const char* desc);
|
||||
|
||||
/**
|
||||
* Instantiate an unknown board using a json file
|
||||
*
|
||||
* @param path Path to the json file, relative to the folder the program
|
||||
* was initially run in or a direct path
|
||||
*
|
||||
* @return mraa_result indicating success
|
||||
*/
|
||||
mraa_result_t mraa_init_json_platform(const char* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include "common.h"
|
||||
#include "types.hpp"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
/**
|
||||
* @namespace mraa namespace
|
||||
@@ -97,7 +99,7 @@ getPlatformType()
|
||||
/**
|
||||
* Print a textual representation of the mraa::Result
|
||||
*
|
||||
* @param Result the Result to print
|
||||
* @param result the Result to print
|
||||
*/
|
||||
inline void
|
||||
printError(Result result)
|
||||
@@ -155,7 +157,7 @@ getPlatformName()
|
||||
/**
|
||||
* Return platform versioning info. Returns NULL if no info present.
|
||||
*
|
||||
* @param optional subplatform identifier
|
||||
* @param platform_offset optional subplatform identifier
|
||||
* @return platform versioning info
|
||||
*/
|
||||
inline std::string
|
||||
@@ -176,6 +178,18 @@ getPinCount()
|
||||
return mraa_get_pin_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform usable UART count, board must be initialised.
|
||||
*
|
||||
* @return number of usable UARTs on the current platform. Function will
|
||||
* return -1 on failure
|
||||
*/
|
||||
inline int
|
||||
getUartCount()
|
||||
{
|
||||
return mraa_get_uart_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform usable I2C bus count, board must be initialised.
|
||||
*
|
||||
@@ -214,6 +228,111 @@ getPinName(int pin)
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GPIO index by pin name, board must be initialised.
|
||||
*
|
||||
* @param pin_name: GPIO pin name. Eg: IO0
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for GPIO
|
||||
*/
|
||||
inline int
|
||||
getGpioLookup(std::string pin_name)
|
||||
{
|
||||
int index = mraa_gpio_lookup(pin_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "Gpio name " << pin_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get I2C bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param i2c_name: I2C bus name. Eg: I2C6
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for I2C bus
|
||||
*/
|
||||
inline int
|
||||
getI2cLookup(std::string i2c_name)
|
||||
{
|
||||
int index = mraa_i2c_lookup(i2c_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "i2c name " << i2c_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SPI bus index by bus name, board must be initialised.
|
||||
*
|
||||
* @param spi_name: Name of SPI bus. Eg: SPI2
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for SPI bus
|
||||
*/
|
||||
inline int
|
||||
getSpiLookup(std::string spi_name)
|
||||
{
|
||||
int index = mraa_spi_lookup(spi_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "Spi name " << spi_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PWM index by PWM name, board must be initialised.
|
||||
*
|
||||
* @param pwm_name: Name of PWM. Eg:PWM0
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return int of MRAA index for PWM
|
||||
*/
|
||||
inline int
|
||||
getPwmLookup(std::string pwm_name)
|
||||
{
|
||||
int index = mraa_pwm_lookup(pwm_name.c_str());
|
||||
|
||||
if (index < 0){
|
||||
std::ostringstream oss;
|
||||
oss << "PWM name " << pwm_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get UART index by UART name, board must be initialised.
|
||||
*
|
||||
* @param uart_name: Name of the UART. Eg: UART2
|
||||
* @throws std::invalid_argument if name is not found
|
||||
* @return MRAA index for the UART
|
||||
*/
|
||||
inline int
|
||||
getUartLookup(std::string uart_name)
|
||||
{
|
||||
int index = mraa_uart_lookup(uart_name.c_str());
|
||||
|
||||
if (index < 0) {
|
||||
std::ostringstream oss;
|
||||
oss << "UART name " << uart_name << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
|
||||
* syslog log levels, see syslog(3) for more information on the levels.
|
||||
@@ -241,7 +360,7 @@ hasSubPlatform()
|
||||
/**
|
||||
* Check if pin or bus id includes sub platform mask.
|
||||
*
|
||||
* @param int pin or bus number
|
||||
* @param pin_or_bus_id pin or bus number
|
||||
*
|
||||
* @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
|
||||
*/
|
||||
@@ -254,7 +373,7 @@ isSubPlatformId(int pin_or_bus_id)
|
||||
/**
|
||||
* Convert pin or bus index to corresponding sub platform id.
|
||||
*
|
||||
* @param int pin or bus index
|
||||
* @param pin_or_bus_index pin or bus index
|
||||
*
|
||||
* @return int sub platform pin or bus number
|
||||
*/
|
||||
@@ -267,7 +386,7 @@ getSubPlatformId(int pin_or_bus_index)
|
||||
/**
|
||||
* Convert pin or bus sub platform id to index.
|
||||
*
|
||||
* @param int sub platform pin or bus id
|
||||
* @param pin_or_bus_id sub platform pin or bus id
|
||||
*
|
||||
* @return int pin or bus index
|
||||
*/
|
||||
@@ -280,7 +399,7 @@ getSubPlatformIndex(int pin_or_bus_id)
|
||||
/**
|
||||
* Get default i2c bus, board must be initialised.
|
||||
*
|
||||
* @param optional subplatform identifier
|
||||
* @param platform_offset optional subplatform identifier
|
||||
* @return default i2c bus for paltform
|
||||
*/
|
||||
inline int
|
||||
@@ -293,16 +412,23 @@ getDefaultI2cBus(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
|
||||
* Add mraa subplatform
|
||||
*
|
||||
* @param subplatformtype the type of subplatform to add
|
||||
* (e.g. MRAA_GENERIC_FIRMATA)
|
||||
* @param uart_dev subplatform device string (e.g. "/dev/ttyACM0")
|
||||
* (e.g. MRAA_GENERIC_FIRMATA or MRAA_GROVEPI)
|
||||
* @param dev subplatform uart device string or i2c bus number (e.g. "/dev/ttyACM0" or "0")
|
||||
* @return Result of operation
|
||||
*/
|
||||
inline Result
|
||||
addSubplatform(Platform subplatformtype, std::string uart_dev)
|
||||
addSubplatform(Platform subplatformtype, std::string dev)
|
||||
{
|
||||
return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, uart_dev.c_str());
|
||||
return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, dev.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove mraa subplatform
|
||||
*
|
||||
* @param subplatformtype the type of subplatform to remove
|
||||
* (e.g. MRAA_GENERIC_FIRMATA)
|
||||
* @return Result of operation
|
||||
*/
|
||||
inline Result
|
||||
removeSubplatform(Platform subplatformtype)
|
||||
{
|
||||
@@ -316,7 +442,7 @@ removeSubplatform(Platform subplatformtype)
|
||||
* [io]-[raw]-[id]-[pin]
|
||||
* [io]-[raw]-[path]
|
||||
*
|
||||
* @param IO description
|
||||
* @param desc description
|
||||
*
|
||||
* @return class T initialised using pointer to IO or NULL
|
||||
*/
|
||||
@@ -327,4 +453,18 @@ initIo(std::string desc)
|
||||
return new T(mraa_init_io(desc.c_str()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate an unknown board using a json file
|
||||
*
|
||||
* @param path Path to the json file, relative to the folder the program
|
||||
* was initially run in or a direct path
|
||||
*
|
||||
* @return Result indicating success
|
||||
*/
|
||||
inline Result
|
||||
initJsonPlatform(std::string path)
|
||||
{
|
||||
return (Result) mraa_init_json_platform(path.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ typedef struct _firmata* mraa_firmata_context;
|
||||
* Initialise firmata context on a feature. This feature is what will be
|
||||
* listened on if you request a response callback
|
||||
*
|
||||
* @param firmata feature
|
||||
* @param feature firmata feature
|
||||
* @return firmata context or NULL
|
||||
*/
|
||||
mraa_firmata_context mraa_firmata_init(int feature);
|
||||
|
@@ -33,7 +33,7 @@
|
||||
* through sysfs), or memory mapped IO via a /dev/uio device or /dev/mem
|
||||
* depending again on the board configuration.
|
||||
*
|
||||
* @snippet gpio_read6.c Interesting
|
||||
* @snippet gpio.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -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
|
||||
|
||||
/**
|
||||
@@ -86,6 +84,23 @@ typedef enum {
|
||||
MRAA_GPIO_EDGE_FALLING = 3 /**< Interrupt on falling only */
|
||||
} mraa_gpio_edge_t;
|
||||
|
||||
/**
|
||||
* Gpio input modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_ACTIVE_HIGH = 0, /**< Resistive High */
|
||||
MRAA_GPIO_ACTIVE_LOW = 1, /**< Resistive Low */
|
||||
} mraa_gpio_input_mode_t;
|
||||
|
||||
|
||||
/**
|
||||
* Gpio output driver modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_OPEN_DRAIN = 0, /**< Open Drain Configuration */
|
||||
MRAA_GPIO_PUSH_PULL = 1, /**< Push Pull Configuration */
|
||||
} mraa_gpio_out_driver_mode_t;
|
||||
|
||||
/**
|
||||
* Initialise gpio_context, based on board number
|
||||
*
|
||||
@@ -220,6 +235,24 @@ int mraa_gpio_get_pin(mraa_gpio_context dev);
|
||||
*/
|
||||
int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Set Gpio input mode
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mode Mode to set input pin state
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_input_mode(mraa_gpio_context dev, mraa_gpio_input_mode_t mode);
|
||||
|
||||
/**
|
||||
* Set Gpio output driver mode. This is not a standard feature, it needs custom implementation for each board
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param mode Set output driver mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_out_driver_mode(mraa_gpio_context dev, mraa_gpio_out_driver_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -69,6 +69,22 @@ typedef enum {
|
||||
EDGE_FALLING = 3 /**< Interrupt on falling only */
|
||||
} Edge;
|
||||
|
||||
/**
|
||||
* Gpio Input modes
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_IN_ACTIVE_HIGH = 0, /**< Resistive High */
|
||||
MODE_IN_ACTIVE_LOW = 1, /**< Resistive Low */
|
||||
} InputMode;
|
||||
|
||||
/**
|
||||
* Gpio output driver modes
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_OUT_OPEN_DRAIN = 0, /**< Open Drain Configuration */
|
||||
MODE_OUT_PUSH_PULL = 1, /**< Push Pull Configuration */
|
||||
} OutputMode;
|
||||
|
||||
/**
|
||||
* @brief API to General Purpose IO
|
||||
*
|
||||
@@ -111,7 +127,7 @@ class Gpio
|
||||
* Gpio Constructor, takes a pointer to the GPIO context and initialises
|
||||
* the GPIO class
|
||||
*
|
||||
* @param void * to GPIO context
|
||||
* @param gpio_context void * to GPIO context
|
||||
*/
|
||||
Gpio(void* gpio_context)
|
||||
{
|
||||
@@ -316,6 +332,30 @@ class Gpio
|
||||
return mraa_gpio_get_pin(m_gpio);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Gpio input mode
|
||||
*
|
||||
* @param mode The mode to change the gpio input
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
inputMode(InputMode mode)
|
||||
{
|
||||
return (Result )mraa_gpio_input_mode(m_gpio, (mraa_gpio_input_mode_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Gpio output driver mode
|
||||
*
|
||||
* @param mode @param mode Set output driver mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
outputMode(OutputMode mode)
|
||||
{
|
||||
return (Result) mraa_gpio_out_driver_mode(m_gpio, (mraa_gpio_out_driver_mode_t) mode);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
|
@@ -32,7 +32,7 @@
|
||||
* communicate to multiple i2c slaves by configuring the address.
|
||||
* @htmlinclude i2c.txt
|
||||
*
|
||||
* @snippet i2c_HMC5883L.c Interesting
|
||||
* @snippet i2c_hmc5883l.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -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
|
||||
@@ -65,7 +65,7 @@ class I2c
|
||||
/**
|
||||
* I2C constructor, takes a pointer to a I2C context and initialises the I2C class
|
||||
*
|
||||
* @param void * to an I2C context
|
||||
* @param i2c_context void * to an I2C context
|
||||
*/
|
||||
I2c(void* i2c_context)
|
||||
{
|
||||
@@ -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.
|
||||
*/
|
||||
|
171
api/mraa/iio.h
171
api/mraa/iio.h
@@ -27,22 +27,37 @@
|
||||
#include "common.h"
|
||||
#include "iio_kernel_headers.h"
|
||||
|
||||
/** Mraa Iio Channels */
|
||||
typedef struct {
|
||||
/** Channel index */
|
||||
int index;
|
||||
/** Channel enabled/disabled */
|
||||
int enabled;
|
||||
/** Channel type */
|
||||
char* type;
|
||||
/** Channel endianes */
|
||||
mraa_boolean_t lendian;
|
||||
/** Channel signed */
|
||||
int signedd;
|
||||
/** Channel offset */
|
||||
unsigned int offset;
|
||||
/** Channel mask */
|
||||
uint64_t mask;
|
||||
/** Channel used bits */
|
||||
unsigned int bits_used;
|
||||
/** Channel bytes */
|
||||
unsigned int bytes;
|
||||
/** Channel shift */
|
||||
unsigned int shift;
|
||||
/** Channel location */
|
||||
unsigned int location;
|
||||
} mraa_iio_channel;
|
||||
|
||||
/** Mraa Iio Event */
|
||||
typedef struct {
|
||||
/** Event name */
|
||||
char* name;
|
||||
/** Event enabled/disabled */
|
||||
int enabled;
|
||||
} mraa_iio_event;
|
||||
|
||||
@@ -52,7 +67,7 @@ typedef struct {
|
||||
*
|
||||
* An iio context represents an IIO device
|
||||
*
|
||||
* @snippet iio_driver.c Interesting
|
||||
* @snippet iio.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -74,44 +89,171 @@ typedef struct _iio* mraa_iio_context;
|
||||
/**
|
||||
* Initialise iio context
|
||||
*
|
||||
* @param bus iio device to use
|
||||
* @param device iio device to use
|
||||
* @return i2c context or NULL
|
||||
*/
|
||||
mraa_iio_context mraa_iio_init(int device);
|
||||
|
||||
mraa_result_t mraa_iio_trigger_buffer(mraa_iio_context dev, void (*fptr)(char* data), void* args);
|
||||
/**
|
||||
* Trigger buffer
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param fptr Callback
|
||||
* @param args Arguments
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_trigger_buffer(mraa_iio_context dev, void (*fptr)(char*, void*), void* args);
|
||||
|
||||
/**
|
||||
* Get device name
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Name of the device
|
||||
*/
|
||||
const char* mraa_iio_get_device_name(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* Get device number
|
||||
*
|
||||
* @param name Name of the device
|
||||
* @return Device Number
|
||||
*/
|
||||
int mraa_iio_get_device_num_by_name(const char* name);
|
||||
|
||||
/**
|
||||
* Read size
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Size
|
||||
*/
|
||||
int mraa_iio_read_size(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* Get channels
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Channels
|
||||
*/
|
||||
mraa_iio_channel* mraa_iio_get_channels(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* Get channels count
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Channels count
|
||||
*/
|
||||
int mraa_iio_get_channel_count(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* Read float from file
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param filename Filename
|
||||
* @param data Data
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_read_float(mraa_iio_context dev, const char* filename, float* data);
|
||||
|
||||
/**
|
||||
* Read int from file
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param filename Filename
|
||||
* @param data Data
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_read_int(mraa_iio_context dev, const char* filename, int* data);
|
||||
|
||||
/**
|
||||
* Read String from file
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param filename Filename
|
||||
* @param data Data
|
||||
* @param max_len Max lenght to read
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_read_string(mraa_iio_context dev, const char* filename, char* data, int max_len);
|
||||
|
||||
/**
|
||||
* Write float
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param attr_chan Channel attributes
|
||||
* @param data Float to write
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_write_float(mraa_iio_context dev, const char* attr_chan, const float data);
|
||||
|
||||
/**
|
||||
* Write int
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param attr_chan Channel attributes
|
||||
* @param data Int to write
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_write_int(mraa_iio_context dev, const char* attr_chan, const int data);
|
||||
|
||||
/**
|
||||
* Write string
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param attr_chan Channel attributes
|
||||
* @param data String to write
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_write_string(mraa_iio_context dev, const char* attr_chan, const char* data);
|
||||
|
||||
/**
|
||||
* Get channel data
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_get_channel_data(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* Get event data
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_get_event_data(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* Event poll
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param data Data
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_event_poll(mraa_iio_context dev, struct iio_event_data* data);
|
||||
|
||||
/**
|
||||
* Setup event callback
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param fptr Callback
|
||||
* @param args Arguments
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t
|
||||
mraa_iio_event_setup_callback(mraa_iio_context dev, void (*fptr)(struct iio_event_data* data, void* args), void* args);
|
||||
|
||||
/**
|
||||
* Extract event
|
||||
*
|
||||
* @param event Event
|
||||
* @param chan_type Channel type
|
||||
* @param modifier Modifier
|
||||
* @param type Type
|
||||
* @param direction Direction
|
||||
* @param channel Channel
|
||||
* @param channel2 Channel2
|
||||
* @param different Different
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
|
||||
int* chan_type,
|
||||
int* modifier,
|
||||
@@ -121,11 +263,32 @@ mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
|
||||
int* channel2,
|
||||
int* different);
|
||||
|
||||
mraa_result_t mraa_iio_get_mounting_matrix(mraa_iio_context dev, float mm[9]);
|
||||
/**
|
||||
* Get mount matrix
|
||||
* @param dev The iio context
|
||||
* @param sysfs_name Sysfs name
|
||||
* @param mm Matrix
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_get_mount_matrix(mraa_iio_context dev, const char *sysfs_name, float mm[9]);
|
||||
|
||||
/**
|
||||
* Create trigger
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @param trigger Trigger name
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger);
|
||||
|
||||
/**
|
||||
* Update channels
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_update_channels(mraa_iio_context dev);
|
||||
|
||||
/**
|
||||
* De-inits an mraa_iio_context device
|
||||
*
|
||||
|
@@ -25,28 +25,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <sstream>
|
||||
#include "iio.h"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/** Iio Event Data */
|
||||
struct IioEventData
|
||||
{
|
||||
/** Channel Type */
|
||||
int channelType;
|
||||
/** Modifier */
|
||||
int modifier;
|
||||
/** Type */
|
||||
int type;
|
||||
/** Direction */
|
||||
int direction;
|
||||
/** Channel */
|
||||
int channel;
|
||||
/** Channel 2 */
|
||||
int channel2;
|
||||
/** Difference */
|
||||
int diff;
|
||||
};
|
||||
|
||||
/** Iio Handler */
|
||||
class IioHandler
|
||||
{
|
||||
public:
|
||||
/** onIioEvent Handler */
|
||||
virtual void onIioEvent(const IioEventData& eventData) = 0;
|
||||
/** Destructor */
|
||||
virtual ~IioHandler() {}; // add an empty destructor to get rid of warning
|
||||
};
|
||||
|
||||
|
||||
@@ -55,7 +67,7 @@ public:
|
||||
*
|
||||
* This file defines the C++ iio interface for libmraa
|
||||
*
|
||||
* @snippet iio_dummy_test.cpp Interesting
|
||||
* @snippet Iio-dummy.cpp Interesting
|
||||
*/
|
||||
class Iio
|
||||
{
|
||||
|
@@ -106,16 +106,20 @@ enum iio_event_direction {
|
||||
};
|
||||
|
||||
//linux/iio/events.h
|
||||
#if defined(MSYS)
|
||||
#define __USE_LINUX_IOCTL_DEFS
|
||||
#include <sys/ioctl.h>
|
||||
#else
|
||||
#include <linux/ioctl.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct iio_event_data - The actual event being pushed to userspace
|
||||
* @id: event identifier
|
||||
* @timestamp: best estimate of time of event occurrence (often from
|
||||
* the interrupt handler)
|
||||
*/
|
||||
struct iio_event_data {
|
||||
/** event identifier */
|
||||
unsigned long long int id;
|
||||
/** best estimate of time of event occurrence (often from the interrupt handler) */
|
||||
long long int timestamp;
|
||||
};
|
||||
|
||||
|
112
api/mraa/led.h
Normal file
112
api/mraa/led.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2017 Linaro Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief LED module
|
||||
*
|
||||
* LED is the Light Emitting Diode interface to libmraa. It is used to
|
||||
* access the on board LED's via sysfs.
|
||||
*
|
||||
* @snippet led.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _led
|
||||
*/
|
||||
typedef struct _led* mraa_led_context;
|
||||
|
||||
/**
|
||||
* Initialise led_context, based on led function name.
|
||||
* The structure of LED entry in sysfs is "devicename:colour:function"
|
||||
* This api expects only one unique LED identifier which would be
|
||||
* "function" name most often. For instance, `mraa_led_init("user4");`
|
||||
*
|
||||
* @param led Name of the LED
|
||||
* @returns LED context or NULL
|
||||
*/
|
||||
mraa_led_context mraa_led_init(const char* led);
|
||||
|
||||
/**
|
||||
* Set LED brightness
|
||||
*
|
||||
* @param dev LED context
|
||||
* @param value Integer value to write
|
||||
* @returns Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_led_set_brightness(mraa_led_context dev, int value);
|
||||
|
||||
/**
|
||||
* Read LED brightness
|
||||
*
|
||||
* @param dev LED context
|
||||
* @returns Brightness value
|
||||
*/
|
||||
int mraa_led_read_brightness(mraa_led_context dev);
|
||||
|
||||
/**
|
||||
* Read LED maximum brightness
|
||||
*
|
||||
* @param dev LED context
|
||||
* @returns Maximum brightness value
|
||||
*/
|
||||
int mraa_led_read_max_brightness(mraa_led_context dev);
|
||||
|
||||
/**
|
||||
* Set LED trigger
|
||||
*
|
||||
* @param dev LED context
|
||||
* @param trigger Type of trigger to set
|
||||
* @returns Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_led_set_trigger(mraa_led_context dev, const char* trigger);
|
||||
|
||||
/**
|
||||
* Clear active LED trigger
|
||||
*
|
||||
* @param dev LED context
|
||||
* @returns Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_led_clear_trigger(mraa_led_context dev);
|
||||
|
||||
/**
|
||||
* Close LED file descriptors and free the context memory
|
||||
*
|
||||
* @param dev LED context
|
||||
* @returns Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_led_close(mraa_led_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
139
api/mraa/led.hpp
Normal file
139
api/mraa/led.hpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2017 Linaro Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "led.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief API to Light Emitting Diode
|
||||
*
|
||||
* This file defines the LED interface for libmraa
|
||||
*
|
||||
*/
|
||||
class Led
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Instantiates an LED object
|
||||
*
|
||||
* @param led LED fuction name to use
|
||||
*/
|
||||
Led(const char* led)
|
||||
{
|
||||
m_led = mraa_led_init(led);
|
||||
|
||||
if (m_led == NULL) {
|
||||
throw std::invalid_argument("Invalid LED name specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LED Constructor, takes a pointer to a LED context and initialises
|
||||
* the LED class
|
||||
*
|
||||
* @param led_context void * to LED context
|
||||
*/
|
||||
Led(void* led_context)
|
||||
{
|
||||
m_led = (mraa_led_context) led_context;
|
||||
if (m_led == NULL) {
|
||||
throw std::invalid_argument("Invalid LED name specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LED object destructor
|
||||
*/
|
||||
~Led()
|
||||
{
|
||||
mraa_led_close(m_led);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LED brightness value
|
||||
*
|
||||
* @param value Value to set LED brightness
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
setBrightness(int value)
|
||||
{
|
||||
return (Result) mraa_led_set_brightness(m_led, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read LED brightness value
|
||||
*
|
||||
* @return LED brightness value
|
||||
*/
|
||||
int
|
||||
readBrightness()
|
||||
{
|
||||
return mraa_led_read_brightness(m_led);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read LED maximum brightness value
|
||||
*
|
||||
* @return LED max brightness value
|
||||
*/
|
||||
int
|
||||
readMaxBrightness()
|
||||
{
|
||||
return mraa_led_read_max_brightness(m_led);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LED trigger
|
||||
*
|
||||
* @param trigger Type of trigger to set
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
trigger(const char* trigger)
|
||||
{
|
||||
return (Result) mraa_led_set_trigger(m_led, trigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear active LED trigger
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
clearTrigger()
|
||||
{
|
||||
return (Result) mraa_led_clear_trigger(m_led);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_led_context m_led;
|
||||
};
|
||||
}
|
@@ -33,7 +33,7 @@
|
||||
* of resolution so make sure you check the board & pin you are using before
|
||||
* hand.
|
||||
*
|
||||
* @snippet cycle-pwm3.c Interesting
|
||||
* @snippet pwm.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -45,6 +45,7 @@ extern "C" {
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/** Mraa Pwm Context */
|
||||
typedef struct _pwm* mraa_pwm_context;
|
||||
|
||||
/**
|
||||
|
@@ -71,7 +71,7 @@ class Pwm
|
||||
* Pwm constructor, takes a pointer to the PWM context and
|
||||
* initialises the class
|
||||
*
|
||||
* @param void * to a PWM context
|
||||
* @param pwm_context void * to a PWM context
|
||||
*/
|
||||
Pwm(void* pwm_context)
|
||||
{
|
||||
|
@@ -34,7 +34,7 @@
|
||||
* more information on spidev devices is available
|
||||
* [here](https://www.kernel.org/doc/Documentation/spi/spidev).
|
||||
*
|
||||
* @snippet spi_mcp4261.c Interesting
|
||||
* @snippet spi.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -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);
|
||||
@@ -83,7 +89,7 @@ class Spi
|
||||
* Spi Constructor, takes a pointer to a SPI context and initialises
|
||||
* the SPI class
|
||||
*
|
||||
* @param void * to SPI context
|
||||
* @param spi_context void * to SPI context
|
||||
*/
|
||||
Spi(void* spi_context)
|
||||
{
|
||||
|
@@ -46,20 +46,32 @@ 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_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 */
|
||||
MRAA_UP2 = 16, /**< The UP^2 Board */
|
||||
MRAA_MTK_LINKIT = 17, /**< Mediatek MT7688 based Linkit boards */
|
||||
MRAA_MTK_OMEGA2 = 18, /**< MT7688 based Onion Omega2 board */
|
||||
|
||||
// USB platform extenders start at 256
|
||||
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
|
||||
|
||||
// contains bit 9 so is subplatform
|
||||
MRAA_GROVEPI = 1024, /**< GrovePi shield i2c bridge */
|
||||
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 */
|
||||
MRAA_UNKNOWN_PLATFORM =
|
||||
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
MRAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} mraa_platform_t;
|
||||
|
||||
/**
|
||||
@@ -236,12 +248,15 @@ typedef enum {
|
||||
MRAA_I2C_HIGH = 2 /**< up to 3.4Mhz */
|
||||
} mraa_i2c_mode_t;
|
||||
|
||||
/**
|
||||
* Enum representing different uart parity states
|
||||
*/
|
||||
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
|
||||
|
@@ -50,14 +50,20 @@ typedef enum {
|
||||
A96BOARDS = 9, /**< Linaro 96boards, A prefix for 'ARM' since not allowed numerical */
|
||||
INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
|
||||
INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
|
||||
INTEL_UP = 12, /**< The UP Board */
|
||||
INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
|
||||
PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
|
||||
DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
|
||||
INTEL_UP2 = 16, /**< The UP^2 Board */
|
||||
|
||||
FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
|
||||
|
||||
GROVEPI = 1024, /**< GrovePi shield 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 */
|
||||
UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} Platform;
|
||||
|
||||
/**
|
||||
@@ -226,7 +232,7 @@ typedef enum {
|
||||
} Pinmodes;
|
||||
|
||||
/**
|
||||
* Enum reprensenting different i2c speeds/modes
|
||||
* Enum representing different i2c speeds/modes
|
||||
*/
|
||||
typedef enum {
|
||||
I2C_STD = 0, /**< up to 100Khz */
|
||||
@@ -234,6 +240,9 @@ typedef enum {
|
||||
I2C_HIGH = 2 /**< up to 3.4Mhz */
|
||||
} I2cMode;
|
||||
|
||||
/**
|
||||
* Enum representing different uart parity states
|
||||
*/
|
||||
typedef enum {
|
||||
UART_PARITY_NONE = 0,
|
||||
UART_PARITY_EVEN = 1,
|
||||
|
@@ -45,6 +45,7 @@ extern "C" {
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/** Mraa Uart Context */
|
||||
typedef struct _uart* mraa_uart_context;
|
||||
|
||||
/**
|
||||
@@ -72,6 +73,18 @@ mraa_uart_context mraa_uart_init_raw(const char* path);
|
||||
*/
|
||||
mraa_result_t mraa_uart_flush(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Send a break to the device.
|
||||
* Blocks until complete.
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param duration When 0, send a break lasting at least 250
|
||||
* milliseconds, and not more than 500 milliseconds. When non zero,
|
||||
* the break duration is implementation specific.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_sendbreak(mraa_uart_context dev, int duration);
|
||||
|
||||
/**
|
||||
* Set the baudrate.
|
||||
* Takes an int and will attempt to decide what baudrate is
|
||||
@@ -136,6 +149,41 @@ mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t n
|
||||
*/
|
||||
const char* mraa_uart_get_dev_path(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Get the current settings of an UART. This is an unintrusive function. Meaning
|
||||
* it intends not to change anything, only read the values without disturbing.
|
||||
*
|
||||
* All but the first index parameter are "outparameters". That means they can
|
||||
* contain values on return. If any parameter is not interesting, a null pointer
|
||||
* can be sent instead as a placeholder.
|
||||
* The devpath parameter can be either in or out parameter. In case of a negative
|
||||
* index, the UART is identified using *devpath instead. This functionality is
|
||||
* intended for and needed by for instance USB serial adapters.
|
||||
*
|
||||
* In case of a non-success return value, the outparameters are undefined.
|
||||
*
|
||||
* @param index uart index to look up, if negative, *devpath will be used instead
|
||||
* @param devpath points to the device path of the UART, eg: /dev/ttyS0
|
||||
* @param name outparameter that on return will point to the name of the UART
|
||||
* @param baudrate pointer to an integer to contain the current baudrate (0--4M)
|
||||
* @param databits pointer to an integer to contain the number databits (5--8)
|
||||
* @param stopbits pointer to an integer to contain the number stopbits (1--2)
|
||||
* @param parity will contain the current parity mode
|
||||
* @param rtscts will point to non-zero if CTS/RTS flow control is enabled, zero otherwise
|
||||
* @param xonxoff will point to a non-zero value if xon/xoff flow control is enabled
|
||||
* @return result
|
||||
*/
|
||||
mraa_result_t
|
||||
mraa_uart_settings(int index,
|
||||
const char **devpath,
|
||||
const char **name,
|
||||
int* baudrate,
|
||||
int* databits,
|
||||
int* stopbits,
|
||||
mraa_uart_parity_t* parity,
|
||||
unsigned int* rtscts,
|
||||
unsigned int* xonxoff);
|
||||
|
||||
/**
|
||||
* Destroy a mraa_uart_context
|
||||
*
|
||||
|
@@ -64,7 +64,7 @@ class Uart
|
||||
* Uart Constructor, takes a string to the path of the serial
|
||||
* interface that is needed.
|
||||
*
|
||||
* @param uart the index of the uart set to use
|
||||
* @param path the index of the uart set to use
|
||||
*/
|
||||
Uart(std::string path)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ class Uart
|
||||
* Uart Constructor, takes a pointer to the UART context and initialises
|
||||
* the UART class
|
||||
*
|
||||
* @param void * to a UART context
|
||||
* @param uart_context void * to a UART context
|
||||
*/
|
||||
Uart(void* uart_context)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ class Uart
|
||||
}
|
||||
|
||||
/**
|
||||
* Write bytes in String object to a device
|
||||
* Write bytes in char* buffer to a device
|
||||
*
|
||||
* @param data buffer pointer
|
||||
* @param length maximum size of buffer
|
||||
@@ -160,7 +160,7 @@ class Uart
|
||||
/**
|
||||
* Write bytes in String object to a device
|
||||
*
|
||||
* @param string to write
|
||||
* @param data string to write
|
||||
* @return the number of bytes written, or -1 if an error occurred
|
||||
*/
|
||||
int
|
||||
@@ -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
|
||||
@@ -258,12 +273,11 @@ class Uart
|
||||
/**
|
||||
* Set the blocking state for write operations
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param nonblock new nonblocking state
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
SetNonBlocking(bool nonblock)
|
||||
setNonBlocking(bool nonblock)
|
||||
{
|
||||
return (Result) mraa_uart_set_non_blocking(m_uart, nonblock);
|
||||
}
|
||||
|
@@ -64,19 +64,23 @@ extern "C" {
|
||||
#include "common.h"
|
||||
#include "uart.h"
|
||||
|
||||
/* for now, we simply use the normal MRAA UART context */
|
||||
/** 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 {
|
||||
/** Uart Context */
|
||||
mraa_uart_context uart;
|
||||
/* search state */
|
||||
unsigned char ROM_NO[8]; /* 8 byte (64b) rom code */
|
||||
/** search state */
|
||||
unsigned char ROM_NO[MRAA_UART_OW_ROMCODE_SIZE]; /* 8 byte (64b) rom code */
|
||||
/** Context laxt discrepancy */
|
||||
int LastDiscrepancy;
|
||||
/** Context las family discrepancy */
|
||||
int LastFamilyDiscrepancy;
|
||||
/** Context las device flag */
|
||||
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
|
||||
*/
|
||||
|
@@ -46,8 +46,8 @@ class UartOW
|
||||
* UartOW Constructor, takes a pin number which will map directly to the
|
||||
* linux uart number, this 'enables' the uart, nothing more
|
||||
*
|
||||
* @throws std::invalid_argument in case of error
|
||||
* @param uart the index of the uart to use
|
||||
* @throws std::invalid_argument in case of error
|
||||
*/
|
||||
UartOW(int uart)
|
||||
{
|
||||
@@ -62,8 +62,8 @@ class UartOW
|
||||
* UartOW Constructor, takes a string to the path of the serial
|
||||
* interface that is needed.
|
||||
*
|
||||
* @throws std::invalid_argument in case of error
|
||||
* @param path the file path for the UART to use
|
||||
* @throws std::invalid_argument in case of error
|
||||
*/
|
||||
UartOW(std::string path)
|
||||
{
|
||||
@@ -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:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# JSON-C_LIBRARIES - library directories
|
||||
|
||||
find_package (PkgConfig)
|
||||
pkg_check_modules (PC_JSON-C QUIET json-c)
|
||||
pkg_search_module (PC_JSON-C QUIET json-c json)
|
||||
|
||||
find_path (JSON-C_INCLUDE_DIR json.h HINTS ${PC_JSON-C_INCLUDEDIR}
|
||||
${PC_JSON-C_INCLUDE_DIRS} PATH_SUFFIXES json-c json)
|
||||
|
@@ -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")
|
||||
|
@@ -11,4 +11,16 @@ find_package_handle_standard_args (Sphinx DEFAULT_MSG
|
||||
SPHINX_EXECUTABLE
|
||||
)
|
||||
|
||||
# Get Sphinx Version
|
||||
if (SPHINX_EXECUTABLE)
|
||||
execute_process(COMMAND ${SPHINX_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE SPHINX_VERSION_STRING
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if (SPHINX_VERSION_STRING)
|
||||
string(REPLACE "Sphinx (sphinx-build) " "" SPHINX_VERSION ${SPHINX_VERSION_STRING})
|
||||
message (STATUS "Sphinx version is ${SPHINX_VERSION}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (SPHINX_EXECUTABLE)
|
||||
|
@@ -14,8 +14,12 @@ find_package_handle_standard_args (Yuidoc DEFAULT_MSG
|
||||
# Get Yuidoc version
|
||||
if (YUIDOC_EXECUTABLE)
|
||||
execute_process(COMMAND ${YUIDOC_EXECUTABLE} --version
|
||||
ERROR_VARIABLE YUIDOC_VERSION)
|
||||
message ("INFO - Yuidoc version is " ${YUIDOC_VERSION})
|
||||
ERROR_VARIABLE YUIDOC_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if (YUIDOC_VERSION)
|
||||
message (STATUS "Yuidoc version is ${YUIDOC_VERSION}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (YUIDOC_EXECUTABLE)
|
||||
|
@@ -132,6 +132,9 @@ if(NOT ${found})
|
||||
endif()
|
||||
endfunction(find_python)
|
||||
|
||||
set(MIN_VER_PYTHON2 2.7)
|
||||
set(MIN_VER_PYTHON3 3.2)
|
||||
|
||||
find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
|
||||
PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
|
||||
PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
|
||||
@@ -146,7 +149,6 @@ find_python(3 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
|
||||
PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH
|
||||
PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH)
|
||||
|
||||
|
||||
if(PYTHON_DEFAULT_EXECUTABLE)
|
||||
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
|
||||
elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter
|
||||
|
@@ -45,6 +45,8 @@ set(archdetect_c_code "
|
||||
#error cmake_ARCH x86_64
|
||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#error cmake_ARCH ia64
|
||||
#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000)
|
||||
#error cmake_ARCH mips
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||
|
165
docker-compose.yaml
Normal file
165
docker-compose.yaml
Normal file
@@ -0,0 +1,165 @@
|
||||
version: '2.1'
|
||||
|
||||
services:
|
||||
|
||||
base:
|
||||
image: inteliotdevkit/mraa-base
|
||||
environment:
|
||||
- http_proxy
|
||||
- https_proxy
|
||||
- no_proxy
|
||||
- BUILDDOC=${BUILDDOC:-OFF}
|
||||
- BUILDSWIG=${BUILDSWIG:-OFF}
|
||||
- BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF}
|
||||
- BUILDTESTS=${BUILDTESTS:-ON}
|
||||
- USEPYTHON3TESTS=${USEPYTHON3TESTS:-OFF}
|
||||
- BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF}
|
||||
- BUILDSWIGNODE=${BUILDSWIGNODE:-OFF}
|
||||
- USBPLAT=${USBPLAT:-OFF}
|
||||
- FIRMATA=${FIRMATA:-OFF}
|
||||
- ONEWIRE=${ONEWIRE:-ON}
|
||||
- JSONPLAT=${JSONPLAT:-OFF}
|
||||
- IMRAA=${IMRAA:-OFF}
|
||||
- FTDI4222=${FTDI4222:-OFF}
|
||||
- IPK=${IPK:-OFF}
|
||||
- RPM=${RPM:-OFF}
|
||||
- ENABLEEXAMPLES=${ENABLEEXAMPLES:-OFF}
|
||||
- INSTALLTOOLS=${INSTALLTOOLS:-ON}
|
||||
- CC=${CC:-clang-3.8}
|
||||
- CXX=${CXX:-clang++-3.8}
|
||||
- BUILDARCH=${BUILDARCH}
|
||||
volumes:
|
||||
- .:${MRAA_SRC_DIR:-/usr/src/app}
|
||||
|
||||
all:
|
||||
extends: base
|
||||
image: inteliotdevkit/mraa-all
|
||||
|
||||
doc:
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- BUILDDOC=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && ./scripts/build-doc.sh"
|
||||
|
||||
examples:
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- ENABLEEXAMPLES=ON
|
||||
- USBPLAT=ON
|
||||
- FIRMATA=ON
|
||||
- ONEWIRE=ON
|
||||
- IMRAA=ON
|
||||
- FTDI4222=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
|
||||
sonar-scan:
|
||||
extends: all
|
||||
environment:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGPYTHON=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
- ENABLEEXAMPLES=ON
|
||||
- ONEWIRE=ON
|
||||
- JSONPLAT=ON
|
||||
- SONAR_TOKEN
|
||||
- SONAR_ORG
|
||||
- SONAR_PROJ_KEY
|
||||
- TRAVIS_BRANCH
|
||||
- TRAVIS_PULL_REQUEST
|
||||
- TRAVIS_REPO_SLUG
|
||||
- TRAVIS_PULL_REQUEST_SLUG
|
||||
- GITHUB_TOKEN
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && ../scripts/sonar-scan.sh"
|
||||
|
||||
usbplat:
|
||||
extends: all
|
||||
environment:
|
||||
- USBPLAT=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
|
||||
firmata:
|
||||
extends: all
|
||||
environment:
|
||||
- FIRMATA=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
|
||||
imraa:
|
||||
extends: all
|
||||
environment:
|
||||
- IMRAA=ON
|
||||
- FIRMATA=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
|
||||
ftdi4442:
|
||||
extends: all
|
||||
environment:
|
||||
- FTDI4222=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
|
||||
|
||||
ipk:
|
||||
extends: all
|
||||
environment:
|
||||
- IPK=ON
|
||||
- ENABLEEXAMPLES=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild package"
|
||||
|
||||
rpm:
|
||||
extends: all
|
||||
environment:
|
||||
- RPM=ON
|
||||
- ENABLEEXAMPLES=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild package"
|
||||
|
||||
python2:
|
||||
extends: base
|
||||
image: inteliotdevkit/mraa-python
|
||||
environment:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGPYTHON=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make _python2-mraa && ctest --output-on-failure"
|
||||
|
||||
python3:
|
||||
extends: python2
|
||||
environment:
|
||||
- USEPYTHON3TESTS=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make _python3-mraa && ctest --output-on-failure"
|
||||
|
||||
java:
|
||||
extends: base
|
||||
image: inteliotdevkit/mraa-java
|
||||
environment:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGJAVA=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && cd build && make mraajava && ctest --output-on-failure"
|
||||
|
||||
android:
|
||||
extends: java
|
||||
image: inteliotdevkit/mraa-android
|
||||
environment:
|
||||
- BUILDARCH=PERIPHERALMAN
|
||||
command: bash -c "./scripts/build-android.sh"
|
||||
|
||||
node4:
|
||||
extends: base
|
||||
image: inteliotdevkit/mraa-node4
|
||||
environment:
|
||||
- BUILDSWIG=ON
|
||||
- BUILDSWIGNODE=ON
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild npmpkg && node-gyp configure && node-gyp build && npm test"
|
||||
|
||||
node5:
|
||||
extends: node4
|
||||
image: inteliotdevkit/mraa-node5
|
||||
|
||||
node6:
|
||||
extends: node4
|
||||
image: inteliotdevkit/mraa-node6
|
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)
|
192
docs/building.md
192
docs/building.md
@@ -4,20 +4,23 @@ libmraa uses cmake in order to make compilation relatively painless. CMake runs
|
||||
build out of tree so the recommended way is to clone from git and make a `build/`
|
||||
directory inside the clone directory.
|
||||
|
||||
For building imraa check [building imraa](./imraa.md)
|
||||
For building imraa check @ref buildingimraa page.
|
||||
|
||||
## Build dependencies
|
||||
|
||||
Not all these are required but if you're unsure of what you're doing this is
|
||||
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:
|
||||
@@ -25,7 +28,6 @@ To build the documentation you'll also need:
|
||||
* [Graphviz](http://graphviz.org/) 2+ (For Doxygen graph generation)
|
||||
* [Sphinx](http://sphinx-doc.org/) 1.1.3+ (For Python docs)
|
||||
|
||||
|
||||
## Basic build steps
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
@@ -52,8 +54,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
|
||||
@@ -75,7 +78,7 @@ A few recommended options:
|
||||
Changing install path from `/usr/local` to `/usr`:
|
||||
`-DCMAKE_INSTALL_PREFIX:PATH=/usr`
|
||||
|
||||
Building debug build - adds `-g` and disables optimisations - this will force a
|
||||
Building debug build - adds `-g` and disables optimizations - this will force a
|
||||
full rebuild:
|
||||
`-DCMAKE_BUILD_TYPE=DEBUG`
|
||||
|
||||
@@ -91,30 +94,37 @@ 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`
|
||||
Then from doxygen2jsdoc dir:
|
||||
`npm install`
|
||||
Then from doxyport dir:
|
||||
`make setup`
|
||||
|
||||
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 library, 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
|
||||
describe --tag` to make it easy for identification. 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 +141,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.
|
||||
|
||||
@@ -143,6 +152,7 @@ tar caf mraa.tar.bz2 cov-int
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
## Building Java bindings
|
||||
|
||||
Have JAVA_HOME set to JDK install directory. Most distributions set this from `/etc/profile.d/`
|
||||
and have a way of switching between alternatives. We support both OpenJDK and Oracle's JDK.
|
||||
On Arch Linux with OpenJDK 8 you'll have to set this yourself like this:
|
||||
@@ -157,10 +167,10 @@ javac -cp $DIR_WHERE_YOU_INSTALLED_MRAA/mraa.jar:. Example.java
|
||||
~~~~~~~~~~~~~
|
||||
To run, make sure `libmraajava.so` is in `LD_LIBRARY_PATH`
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
jave -cp $DIR_WHERE_YOU_INSTALLED_MRAA/mraa.jar:. Example
|
||||
java -cp $DIR_WHERE_YOU_INSTALLED_MRAA/mraa.jar:. Example
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
If you want to add or improve Java bindings for mraa, please follow the [Creating Java Bindings Guide](https://github.com/intel-iot-devkit/upm/blob/master/docs/creating_java_bindings.md).
|
||||
If you want to add or improve Java bindings for mraa, please follow the <a href="https://github.com/intel-iot-devkit/upm/blob/master/docs/creating_java_bindings.md">Creating Java Bindings Guide</a>.
|
||||
|
||||
## Building an IPK/RPM package using `cpack`
|
||||
|
||||
@@ -178,3 +188,143 @@ 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) >= 0.5.1
|
||||
* [Android NDK](https://developer.android.com/ndk/downloads/index.html) >= 14b
|
||||
|
||||
The [Android NDK](https://developer.android.com/ndk/downloads/index.html) contains a CMake find_package module
|
||||
`FindAndroidThings.cmake`. Make sure the directory containing this module is
|
||||
added to the `CMAKE_MODULE_PATH`.
|
||||
|
||||
### Android NDK r14b
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
NDK_HOME="/path/to/android-ndk-r14b"
|
||||
ANDROIDTHINGS_NATIVE_LIB="/path/to/native-libandroidthings-0.5.1-devpreview"
|
||||
|
||||
cmake -DBUILDSWIG=ON \
|
||||
-DBUILDSWIGPYTHON=OFF \
|
||||
-DBUILDSWIGNODE=OFF \
|
||||
-DBUILDSWIGJAVA=ON \
|
||||
-DANDROID_COMPILER_FLAGS_CXX='-std=c++11' \
|
||||
-DANDROID_PIE=1 \
|
||||
-DANDROID_PLATFORM=android-24 \
|
||||
-DANDROID_STL_FORCE_FEATURES=ON \
|
||||
-DANDROID_STL=c++_shared \
|
||||
-DANDROID_TOOLCHAIN_NAME=x86-i686 \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
|
||||
-DCMAKE_FIND_ROOT_PATH=$NDK_HOME/platforms/android-24/arch-x86/ \
|
||||
-DCMAKE_MODULE_PATH=$ANDROIDTHINGS_NATIVE_LIB \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
|
||||
-DBUILDARCH=PERIPHERALMAN \
|
||||
..
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
## Building with Docker
|
||||
|
||||
You can use `docker` and `docker-compose` to generate a complete build environment
|
||||
for mraa without having to install any other tool.
|
||||
|
||||
Requirements:
|
||||
* [docker](https://www.docker.com/get-docker) >= 1.12.6
|
||||
* [docker-compose](https://docs.docker.com/compose/install/) >= 1.9.0
|
||||
|
||||
**NOTE:** docker-compose is an optional requirement. It actually make running complex
|
||||
docker build and run command easier. But you can just use docker to build and run.
|
||||
|
||||
### Using Docker Images to build Mraa
|
||||
|
||||
**tl;dr:** Just use this commands to build mraa:
|
||||
|
||||
```sh
|
||||
# Build mraa documentation
|
||||
$ docker-compose run doc
|
||||
# Build mraa python2 package and run python2 tests
|
||||
$ docker-compose run python2
|
||||
# Build mraa python3 package and run python3 tests
|
||||
$ docker-compose run python3
|
||||
# Build mraa java package and run java tests
|
||||
$ docker-compose run java
|
||||
# Build mraa node4 package
|
||||
$ docker-compose run node4
|
||||
# Build mraa node5 package
|
||||
$ docker-compose run node5
|
||||
# Build mraa node6 package
|
||||
$ docker-compose run node6
|
||||
# Build mraa for android things package
|
||||
$ docker-compose run android
|
||||
# Run Sonar Qube Scans for mraa
|
||||
$ docker-compose run sonar-scan
|
||||
```
|
||||
|
||||
**docker-compose** will take a look at the `docker-compose.yaml` file in the repository
|
||||
root directory, pull the required docker image, and run an specific command to build
|
||||
mraa for the requested target.
|
||||
Once the build is completed, you will have a `build/` folder in the repository root with all
|
||||
the compiled code. This `build/` folder is created by using a docker volume. The `build\`
|
||||
folder contents is reused each time you execute `docker-compose run [TARGET]`.
|
||||
To know more about volumes in Docker, visit the [Docker Volume Documentation](https://docs.docker.com/engine/tutorials/dockervolumes/).
|
||||
|
||||
You can also start an interactive session inside the docker container if you need to run some
|
||||
custom build commands:
|
||||
|
||||
```sh
|
||||
# Start an interactive bash shell inside the container
|
||||
$ docker-compose run python2 bash
|
||||
# From now, all the commands are executed inside the container
|
||||
$ cd build && cmake -DBUILDSWIGPYTHON=ON .. && make clean all
|
||||
```
|
||||
|
||||
If you don't want to use docker-compose, you can also use `docker run` to build mraa.
|
||||
For example, to build mraa for python2, you can do:
|
||||
|
||||
```sh
|
||||
# From the repository root folder
|
||||
$ docker run \
|
||||
--volume=$(pwd):/usr/src/app \
|
||||
--env BUILDSWIG=ON \
|
||||
--env BUILDSWIGPYTHON=ON \
|
||||
--env BUILDSWIGJAVA=OFF \
|
||||
--env BUILDSWIGNODE=OFF \
|
||||
inteliotdevkit/mraa-python \
|
||||
bash -c "./scripts/run-cmake.sh && make -Cbuild _python2-mraa"
|
||||
```
|
||||
|
||||
### Proxy considerations
|
||||
|
||||
If, for some reason, you are behind a proxy, find below a list of common problems related
|
||||
to proxy settings:
|
||||
|
||||
**docker cannot pull images from docker.io**
|
||||
|
||||
Visit [this link](https://docs.docker.com/engine/admin/systemd/#httphttps-proxy)
|
||||
to configure docker daemon behind a proxy.
|
||||
|
||||
**docker run fails to access the internet**
|
||||
|
||||
Docker-compose will automatically take `http_proxy`, `https_proxy`, and `no_proxy`
|
||||
environment variables and use it as build arguments. Be sure to properly configure
|
||||
this variables before building.
|
||||
|
||||
Docker, unlike docker-compose, does not take the proxy settings from the environment
|
||||
automatically. You need to send them as environment arguments:
|
||||
|
||||
```sh
|
||||
# From the repository root folder
|
||||
$ docker run \
|
||||
--volume=$(pwd):/usr/src/app \
|
||||
--env BUILDSWIG=ON \
|
||||
--env BUILDSWIGPYTHON=ON \
|
||||
--env BUILDSWIGJAVA=OFF \
|
||||
--env BUILDSWIGNODE=OFF \
|
||||
--env http_proxy=$http_proxy \
|
||||
--env https_proxy=$https_proxy \
|
||||
--env no_proxy=$no_proxy \
|
||||
inteliotdevkit/mraa-python \
|
||||
bash -c "./scripts/run-cmake.sh && make -Cbuild _python2-mraa"
|
||||
```
|
||||
|
@@ -5,6 +5,94 @@ 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.8.0**
|
||||
* Added Up2 support & grovePi subplatform support
|
||||
* Various improvements on 96board, rpi, beaglebone & Up boards
|
||||
* CMake 3.8+ improvements
|
||||
* Peripheral I/O improvements
|
||||
* Json platform improvements
|
||||
* Static analysis cleanup using SonarQube
|
||||
|
||||
**1.7.0**
|
||||
* Peripheral I/O support for Android Things
|
||||
* Deprecation of node v0.10.x and 0.12.x
|
||||
* Documentation 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
|
||||
|
||||
**1.2.2**
|
||||
* remove jsonplat from prehashed npm builds (see docs/npm.md for details)
|
||||
* internal spelling fix
|
||||
|
||||
**1.2.1**
|
||||
* Fix npm pkg build - no other fix
|
||||
|
||||
**1.2.0**
|
||||
* JSON platform support
|
||||
* mock I2c functionality
|
||||
* Intel Joule PWM fix
|
||||
* AIO firmata bug fix
|
||||
|
||||
**1.1.2**
|
||||
* Mock platform support
|
||||
* mraa-i2c treats i2c buses by default as linux
|
||||
* Intel Joule i2c fixes
|
||||
* travis now uses 14.04 instead of 12.04
|
||||
|
||||
**1.1.1**
|
||||
* IIO 4.6 kernel matrix support
|
||||
* Intel Joule radio led support
|
||||
* mraa_init_io() examples
|
||||
* MRAAPLATFORMFORCE fixes
|
||||
* fix python documentation
|
||||
|
||||
**1.1.0**
|
||||
* build python2 & python3 bindings
|
||||
* Intel Joule support
|
||||
* mraa_init_io() generic funtion
|
||||
* mraa-gpio fixes
|
||||
* edison PWM 0% improvements
|
||||
* iio location maping fix
|
||||
|
||||
**1.0.0**
|
||||
* Change API to enhance error checking in C. Changes include:
|
||||
- mraa_aio_read
|
||||
|
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
|
||||
```
|
@@ -8,8 +8,11 @@ this list as it's the first thing we'll ask you to do.
|
||||
|
||||
Getting the exact version of libmraa you're running is really important to us.
|
||||
The best way to get this is to call mraa_get_version() or mraa.getVersion(). If
|
||||
mraa returns x.x.x-dirty then your version was not built from a git tree or you
|
||||
built out of tree (see our building doc) - or you don't have git installed.
|
||||
you built from git then please tell us which commit hash you used. Mraa no
|
||||
longer tags itself as 'dirty' if built as a non tagged version but simply uses
|
||||
the latest version number listed in the top level CMakeLists.txt file. Note
|
||||
that you may have to wipe the build/ dir for git sha version to be absolutely
|
||||
correct.
|
||||
|
||||
### Finding error logs
|
||||
|
||||
@@ -22,10 +25,12 @@ systemd likely your log is in /var/log/messages or a similar location.
|
||||
|
||||
### Common errors to check for
|
||||
|
||||
* Not running as root
|
||||
* Not running as a user with permissions to the physical char devices/files
|
||||
that require access. Check quickly if it works as root and you likely have
|
||||
such an issue. The log file will reflect this
|
||||
* Incorrect IO pin numbers, mraa uses physical connector pin numbering see your
|
||||
platform documentation for details
|
||||
* Your platform is unsupported
|
||||
* Your platform is unsupported or has been detected wrongly (logfile will show this)
|
||||
* Using the wrong pin, check pin capabilities either using the API or your
|
||||
platform documentation
|
||||
|
||||
|
6
docs/grossetete.md
Normal file
6
docs/grossetete.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Grosstete {#grossetete}
|
||||
=========
|
||||
|
||||
You probably meant to go here: @ref joule.
|
||||
|
||||
Note: This page will be deleted in the future, don't link to it!
|
66
docs/grovepi.md
Normal file
66
docs/grovepi.md
Normal file
@@ -0,0 +1,66 @@
|
||||
GrovePi Shield {#grovepi}
|
||||
=============================
|
||||
|
||||
Mraa can use a GrovePi shield as a subplatform. This means one can utilize the
|
||||
shield IO as well as the IO on the carrier board. The GrovePi shield is meant
|
||||
for RPi boards and compatibles such as UP and UP2. It provides convenient GrovePi
|
||||
style connectors that can be used with various Grove sensors.
|
||||
|
||||
Communication with the shield is achieved over I2C using a custom firmware. It
|
||||
provides access to extra GPIO, AIO and PWM pins.
|
||||
|
||||
### Using the subplatform API ###
|
||||
|
||||
Using the subplatform API is relatively simple, simply add '512', the platform
|
||||
offset, to any IO calls.
|
||||
|
||||
Example:
|
||||
* D3 becomes GPIO 512 + 3 = 515
|
||||
* A2 becomes pin 512 + 2 = 514
|
||||
|
||||
Keep in mind that the I2C ports on the GrovePi shield are merely a level shifted
|
||||
extension of the carrier board's I2C bus, hence I2C sensors do not require an
|
||||
offset.
|
||||
|
||||
The API works from UPM or mraa in any of the supported languages and is compiled
|
||||
with mraa by default. Multiple subplatforms are not yet supported.
|
||||
|
||||
### Pinout ###
|
||||
|
||||
For a complete diagram of the pins available on these shields please refer to
|
||||
the hardware section of the [GrovePi Github repository](https://github.com/DexterInd/GrovePi).
|
||||
|
||||
### Simple code example ###
|
||||
|
||||
This piece of code fades an LED connected to D3 based on the position of a
|
||||
rotary potentiometer on A2:
|
||||
|
||||
```c
|
||||
#include <stdbool.h>
|
||||
#include "mraa.h"
|
||||
|
||||
void main (int argc, char** argv)
|
||||
{
|
||||
mraa_add_subplatform(MRAA_GROVEPI, "0");
|
||||
|
||||
mraa_aio_context aio = mraa_aio_init(514);
|
||||
mraa_pwm_context pwm = mraa_pwm_init(515);
|
||||
|
||||
while(true) {
|
||||
mraa_pwm_write(pwm, mraa_aio_read(aio)/1023.0);
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note that the I2C bus number needs to be passed in as a string to
|
||||
`mraa_add_subplatform`.
|
||||
|
||||
### Limitations & features to be added ###
|
||||
|
||||
Currently there is no support for ISRs or the option to query the shield's
|
||||
firmware version, but these features may be added at a later point.
|
||||
|
||||
Theoretically GrovePi Zero shields are compatible too, however they were not
|
||||
tested. Obviously, only a subset of the IO pins can be used due to the reduced
|
||||
footprint of this shield.
|
@@ -6,7 +6,7 @@ MRAA_GENERIC_FIRMATA subplatform to the first process that calls imraa_init
|
||||
|
||||
## Build dependencies
|
||||
To build imraa, you'll need to build mraa with -DIMRAA=ON and all the normal
|
||||
dependencies for build mraa, see [Building mraa](./building.md).
|
||||
dependencies for build mraa, see @ref building page.
|
||||
You'll also need the following:
|
||||
* [dfu-utils-cross](https://github.com/arduino/dfu-utils-cross) or dfu 0.8 (0.9
|
||||
does not work well with the 101). Precompiled binaries can be found on
|
||||
@@ -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).
|
||||
|
@@ -19,9 +19,10 @@ Java classes directly wrap the C/C++ API and provide a near 1:1 mapping of
|
||||
functionality.
|
||||
|
||||
<center>
|
||||
| C API Modules | Java API Classes |
|
||||
| C API Modules | Java API Classes |
|
||||
|:----------------------:|:----------------------------:|
|
||||
| @ref gpio.h "gpio" | @ref mraa::Gpio "Gpio class" |
|
||||
| @ref led.h "led" | @ref mraa::Led "Led class" |
|
||||
| @ref i2c.h "i2c" | @ref mraa::I2c "I2c class" |
|
||||
| @ref aio.h "aio" | @ref mraa::Aio "Aio class" |
|
||||
| @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" |
|
||||
@@ -45,7 +46,10 @@ Specific platform information for supported platforms is documented here:
|
||||
- @ref rasppi
|
||||
- @ref bananapi
|
||||
- @ref beaglebone
|
||||
- @ref phyboard-wega
|
||||
- @ref nuc5
|
||||
- @ref up
|
||||
- @ref joule
|
||||
- @ref ft4222
|
||||
|
||||
## DEBUGGING
|
||||
@@ -53,7 +57,7 @@ Specific platform information for supported platforms is documented here:
|
||||
Sometimes it just doesn't want to work, let us try and help you, you can file
|
||||
issues in github or join us in #mraa on freenode IRC, hang around for a little
|
||||
while because we're not necessarily on 24/7, but we'll get back to you! Have a
|
||||
glance at our @debugging page too
|
||||
glance at our @ref debugging page too
|
||||
|
||||
## COMPILING
|
||||
|
||||
|
@@ -22,6 +22,7 @@ functionality.
|
||||
| C API Modules | C++ API Classes |
|
||||
|:----------------------:|:----------------------------:|
|
||||
| @ref gpio.h "gpio" | @ref mraa::Gpio "Gpio class" |
|
||||
| @ref led.h "led" | @ref mraa::Led "Led class" |
|
||||
| @ref i2c.h "i2c" | @ref mraa::I2c "I2c class" |
|
||||
| @ref aio.h "aio" | @ref mraa::Aio "Aio class" |
|
||||
| @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" |
|
||||
@@ -45,16 +46,26 @@ Specific platform information for supported platforms is documented here:
|
||||
- @ref rasppi
|
||||
- @ref bananapi
|
||||
- @ref beaglebone
|
||||
- @ref phyboard-wega
|
||||
- @ref nuc5
|
||||
- @ref up
|
||||
- @ref up2
|
||||
- @ref joule
|
||||
- @ref ft4222
|
||||
- @ref _96boards
|
||||
- @ref de10-nano
|
||||
- @ref firmata
|
||||
- @ref grovepi
|
||||
- @ref mock
|
||||
- @ref linkit_7688
|
||||
- @ref omega2
|
||||
|
||||
## DEBUGGING
|
||||
|
||||
Sometimes it just doesn't want to work, let us try and help you, you can file
|
||||
issues in github or join us in #mraa on freenode IRC, hang around for a little
|
||||
while because we're not necessarily on 24/7, but we'll get back to you! Have a
|
||||
glance at our @debugging page too
|
||||
glance at our @ref debugging page too
|
||||
|
||||
## COMPILING
|
||||
|
||||
|
@@ -166,6 +166,10 @@ conversions and memory allocations are performed so the performance of using
|
||||
these functions compared to the C/C++ equivalent will likely be a little lower,
|
||||
however it is much more natural than using carrays.i typemap library.
|
||||
|
||||
Note that node v7.x.x is not yet supported in SWIG, however this is a patchset
|
||||
in SWIG that enables this and does enable mraa to compile and work against a
|
||||
newer nodejs version.
|
||||
|
||||
### NPM ###
|
||||
|
||||
mraa is published on NPM, there is a target to prebuild a mraa src tarball that
|
||||
|
138
docs/joule.md
Normal file
138
docs/joule.md
Normal file
@@ -0,0 +1,138 @@
|
||||
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, one with three and another one with two chipselects.
|
||||
In MRAA terms an SPI "bus" (denoted by a number) is a combination
|
||||
of an actual bus + specific chipselect on this bus. In view of that + taking
|
||||
into account that SPI1CS1 is not available on the board, in MRAA the above
|
||||
translates into five available bus numbers - from 0 to 4, covering SPI0CS0 to SPI1CS2.
|
||||
|
||||
Pins listed are MRAA numbered pins. You will need the `spidev` kernel module loaded
|
||||
with appropriate board configuration for binding, Ref-OS-IoT does not enable this by default.
|
||||
|
||||
MRAA bus # | Ref-OS-IoT bus # | Joule docs bus # | MOSI | MISO | CLK | CS
|
||||
-----------|------------------|------------------|------|------|-----|----
|
||||
0 | 32766 | SPI0 | 67 (J13-27)| 69 (J13-29) | 65 (J13-25) | 59 (J13-19)
|
||||
1 | 32766 | SPI0 | 67 (J13-27)| 69 (J13-29) | 65 (J13-25) | 61 (J13-21)
|
||||
2 | 32766 | SPI0 | 67 (J13-27)| 69 (J13-29) | 65 (J13-25) | 63 (J13-23)
|
||||
3 | 32765 | SPI1 | 4 (J12-4)| 2 (J12-2) | 10 (J12-10) | 6 (J12-6)
|
||||
4 | 32765 | SPI1 | 4 (J12-4)| 2 (J12-2) | 10 (J12-10) | 8 (J12-8)
|
||||
|
||||
**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 (11 characters max) |
|
||||
|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 |
|
65
docs/linkit_7688.md
Normal file
65
docs/linkit_7688.md
Normal file
@@ -0,0 +1,65 @@
|
||||
Linkit Smart 7688 {#linkit_7688}
|
||||
=================
|
||||
|
||||
The Linkit Smart 7688 is based on the MediaTek MT7688 system on a chip, which
|
||||
includes a MIPS 24KEc 580 MHz processor and 128 megabytes of RAM.
|
||||
|
||||
Features:
|
||||
* 20 GPIO pins
|
||||
* 4 PWM pins
|
||||
* 3 UART ports
|
||||
* 1 SPI master port
|
||||
* 1 SPI slave port (not supported by libmraa)
|
||||
* 1 I2C port
|
||||
* 1 I2S port (not supported by libmraa)
|
||||
|
||||

|
||||
|
||||
|
||||
Revision Support
|
||||
----------------
|
||||
* Linkit Smart 7688
|
||||
* Linkit Smart 7688 Duo
|
||||
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
| MRAA Number | Physical Pin | Function |
|
||||
|-------------|--------------|------------------------|
|
||||
| --- | P0 | (Reset) |
|
||||
| 1 | P1 | GPIO43 (Eth LED) |
|
||||
| --- | P2 | (Eth RD+) |
|
||||
| --- | P3 | (Eth RD-) |
|
||||
| --- | P4 | (Eth TD+) |
|
||||
| --- | P5 | (Eth TD-) |
|
||||
| --- | P6 | (USB D+) |
|
||||
| --- | P7 | (USB D-) |
|
||||
| 8 | P8 | GPIO20, UART TX2, PWM2 |
|
||||
| 9 | P9 | GPIO21, UART RX2, PWM3 |
|
||||
| --- | GND | GND |
|
||||
| --- | 3V3 | 3V3 |
|
||||
| --- | VCC | VCC |
|
||||
| --- | 5V | 5V |
|
||||
| 10 | P10 | GPIO2, (I2S WS) |
|
||||
| 11 | P11 | GPIO3, (I2S CLK) |
|
||||
| 12 | P12 | GPIO0, (I2S SDI) |
|
||||
| 13 | P13 | GPIO1, (I2S SDO) |
|
||||
| 14 | P14 | GPIO37 (REF_CLK) |
|
||||
| 15 | P15 | GPIO44 (WiFi LED) |
|
||||
| 16 | P16 | GPIO46, UART RX1 |
|
||||
| 17 | P17 | GPIO45, UART TX1 |
|
||||
| 18 | P18 | GPIO13, UART RX0 |
|
||||
| 19 | P19 | GPIO12, UART TX0 |
|
||||
| 20 | P20 | GPIO5, I2C SDA |
|
||||
| 21 | P21 | GPIO4, I2C SCL |
|
||||
| 22 | P22 | SPI MOSI |
|
||||
| 23 | P23 | SPI MISO |
|
||||
| 24 | P24 | SPI SCK |
|
||||
| 25 | P25 | GPIO6, SPI CS |
|
||||
| 26 | P26 | GPIO18, PWM0 |
|
||||
| 27 | P27 | GPIO19, PWM1 |
|
||||
| 28 | P28 | GPIO17, (SPIS MOSI) |
|
||||
| 29 | P29 | GPIO16, (SPIS MISO) |
|
||||
| 30 | P30 | GPIO15, (SPIS SCK) |
|
||||
| 31 | P31 | GPIO14, (SPIS CS) |
|
@@ -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
|
||||
|
105
docs/mock.md
Normal file
105
docs/mock.md
Normal file
@@ -0,0 +1,105 @@
|
||||
Mock platform {#mock}
|
||||
=============
|
||||
|
||||
Mocking capability allows libmraa user to work with the library without any real
|
||||
hardware available. Enabling this requires library recompilation with architecture
|
||||
override (see Building section below). When mock is enabled, library simulates
|
||||
actual HW operations at the backend so that for the application it looks
|
||||
like a usual board. Being implemented at the backend, the functionality is available
|
||||
in all language bindings libmraa supports.
|
||||
|
||||
Board configuration
|
||||
-------------------
|
||||
|
||||
This feature is yet in the experimental mode and not all functionality is available.
|
||||
Right now we simulate a single generic board with:
|
||||
* GPIO (without ISR)
|
||||
* ADC with 10 (std)/12 (max) bit resolution, which returns random values on read
|
||||
* Single I2C bus with one device at address 0x33 and 10 bytes of register space,
|
||||
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 are more than welcome. See our
|
||||
@ref contributing page for more information.
|
||||
|
||||
See the table below for pin layout and features
|
||||
|
||||
| MRAA Number | Pin Name | Notes |
|
||||
|-------------|----------|---------------------------------------|
|
||||
| 0 | GPIO0 | GPIO pin, no muxing, no ISR |
|
||||
| 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
|
||||
--------
|
||||
|
||||
Generally all the building steps are the same as listed
|
||||
in the main @ref building guide, you just need to set some specific
|
||||
CMake options.
|
||||
|
||||
### Linux
|
||||
|
||||
To build under Linux, follow standard instructions, just make sure to set
|
||||
the `-DBUILDARCH="MOCK"` CMake option.
|
||||
|
||||
### Windows
|
||||
|
||||
Mocking capability allows us to build and use libmraa under Windows. That helps
|
||||
if you e.g. don't want to leave your customary Windows-based Python IDE, but
|
||||
want to develop libmraa-based programs.
|
||||
|
||||
Building Node.js bindings was not yet tested under Windows as MSYS2
|
||||
does not have a ready-made package. Java was not tested either.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
You'll need the following to build libmraa under Windows:
|
||||
|
||||
* [MSYS2](http://mingw-w64.org/doku.php/download/msys2) basic installation
|
||||
* Several additional packages, install them by running
|
||||
|
||||
```bash
|
||||
pacman -S cmake base-devel gcc git
|
||||
```
|
||||
|
||||
#### Compiling
|
||||
|
||||
The procedure is conceptually the same as under Linux - you first need to run
|
||||
CMake with specific options to generate makefiles and then run make to build everything.
|
||||
|
||||
* Run MSYS2 shell (not a MinGW one)
|
||||
* Clone the libmraa git repo (let's assume into `/home/test/mraa/mraa-src` dir)
|
||||
* Create a build directory outside of the clone one (let's say `/home/test/mraa/mraa-build`)
|
||||
* Run CMake, switching off unsupported options and enabling mock platform:
|
||||
|
||||
```bash
|
||||
cmake ../mraa-src/ -DBUILDARCH="MOCK" -DBUILDSWIGNODE=OFF -DENABLEEXAMPLES=OFF
|
||||
```
|
||||
|
||||
* Make, install and test:
|
||||
|
||||
```bash
|
||||
make clean && make install && make test
|
||||
```
|
||||
|
||||
All tests should pass.
|
||||
|
||||
**Note:** To have autocompletion in Python IDE, just point it to MSYS2's Python
|
||||
and make sure to specify any additional paths pointing to site-packages dir
|
||||
with mraa module if IDE requires that ("Interpreter Paths" in PyCharm).
|
||||
With the above settings the module will be installed into `/usr/local/lib/python2.7/site-packages`
|
||||
and the libmraa itself - into `/usr/local/bin`.
|
@@ -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
|
||||
----------------------
|
||||
|
||||
|
67
docs/omega2.md
Normal file
67
docs/omega2.md
Normal file
@@ -0,0 +1,67 @@
|
||||
Onion Omega2 {#omega2}
|
||||
============
|
||||
|
||||
The Omega2 board is based on the MediaTek MT7688 system on a chip, which
|
||||
includes a MIPS 24KEc 580 MHz processor and 128 megabytes of RAM.
|
||||
|
||||
Features:
|
||||
* 15 GPIO pins
|
||||
* 2 PWM pins
|
||||
* 2 UART ports
|
||||
* 1 SPI master port
|
||||
* 1 I2C port
|
||||
* 1 I2S port (not supported by libmraa)
|
||||
|
||||

|
||||
|
||||
|
||||
Revision Support
|
||||
----------------
|
||||
* Omega2
|
||||
* Omega2+
|
||||
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
Left side:
|
||||
|
||||
| MRAA Number | Function |
|
||||
|-------------|------------------------|
|
||||
| --- | GND |
|
||||
| 1 | GPIO11 |
|
||||
| 2 | GPIO3, (I2S CLK) |
|
||||
| 3 | GPIO2, (I2S WS) |
|
||||
| 4 | GPIO17 |
|
||||
| 5 | GPIO16 |
|
||||
| 6 | GPIO15 |
|
||||
| 7 | GPIO46, UART RX1 |
|
||||
| 8 | GPIO45, UART TX1 |
|
||||
| 9 | SPI MISO |
|
||||
| 10 | SPI MOSI |
|
||||
| 11 | SPI SCK |
|
||||
| 12 | GPIO6, SPI CS |
|
||||
| 13 | GPIO1, (I2S SDO) |
|
||||
| 14 | GPIO0, (I2S SDI) |
|
||||
| --- | (Reset) |
|
||||
|
||||
Right side:
|
||||
|
||||
| MRAA Number | Function |
|
||||
|-------------|------------------------|
|
||||
| --- | GND |
|
||||
| --- | VIN 3V3 |
|
||||
| --- | (USB D+) |
|
||||
| --- | (USB D-) |
|
||||
| 20 | GPIO13, UART RX0 |
|
||||
| 21 | GPIO12, UART TX0 |
|
||||
| 22 | FW RST |
|
||||
| --- | VOUT 3V3 |
|
||||
| --- | (Eth TX-) |
|
||||
| --- | (Eth TX+) |
|
||||
| --- | (Eth RX-) |
|
||||
| --- | (Eth RX+) |
|
||||
| 28 | GPIO18, PWM0 |
|
||||
| 29 | GPIO19, PWM1 |
|
||||
| 30 | GPIO4, I2C SCL |
|
||||
| 31 | GPIO5, I2C SDA |
|
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!
|
107
docs/up.md
107
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
|
||||
-----------
|
||||
@@ -40,45 +43,45 @@ model 2 and B+ numbering scheme.
|
||||
|
||||
Note that there is an enum to use wiringPi style numbers.
|
||||
|
||||
| MRAA Number | Physical Pin | Function | Sysfs GPIO | Notes |
|
||||
|-------------|--------------|----------|------------|----------------------|
|
||||
| 1 | P1-01 | 3V3 VCC | | |
|
||||
| 2 | P1-02 | 5V VCC | | |
|
||||
| 3 | P1-03 | I2C SDA1 | 2 | I2C1 (/dev/i2c-1) |
|
||||
| 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 | |
|
||||
| 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) |
|
||||
| 14 | P1-14 | GND | | |
|
||||
| 15 | P1-15 | GPIO(22) | 22 | |
|
||||
| 16 | P1-16 | GPIO(23) | 23 | |
|
||||
| 17 | P1-17 | 3V3 VCC | | |
|
||||
| 18 | P1-18 | GPIO(24) | 24 | |
|
||||
| 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) |
|
||||
| 23 | P1-23 | SPI SCL | 11 | SPI2 (/dev/spidev2.x)|
|
||||
| 24 | P1-24 | SPI CS0 | 8 | SPI2 (/dev/spidev2.0)|
|
||||
| 25 | P1-25 | GND | | |
|
||||
| 26 | P1-26 | SPI CS1 | 7 | SPI2 (/dev/spidev2.1)|
|
||||
| 27 | P1-27 | I2C SDA0 | 0 | I2C0 (/dev/i2c-0) |
|
||||
| 28 | P1-28 | I2C SCL0 | 1 | I2C0 (/dev/i2c-0) |
|
||||
| 29 | P1-29 | GPIO(5) | 5 | |
|
||||
| 30 | P1-30 | GND | | |
|
||||
| 31 | P1-31 | GPIO(6) | 6 | |
|
||||
| 32 | P1-32 | PWM0 | 12 | PWM Chip 0 Channel 0 |
|
||||
| 33 | P1-33 | PWM1 | 13 | PWM Chip 1 Channel 0 |
|
||||
| 34 | P1-34 | GND | | |
|
||||
| 35 | P1-35 | I2S FRM | 19 | I2S0 (PCM Audio) |
|
||||
| 36 | P1-36 | GPIO(16) | 16 | |
|
||||
| 37 | P1-37 | GPIO(26) | 26 | |
|
||||
| 38 | P1-38 | I2S DIN | 20 | I2S0 (PCM Audio) |
|
||||
| 39 | P1-39 | GND | | |
|
||||
| 40 | P1-40 | I2S DOUT | 21 | I2S0 (PCM Audio) |
|
||||
| MRAA Number | Physical Pin | Function | Sysfs GPIO | mraa device |
|
||||
|-------------|--------------|-------------|------------|----------------------|
|
||||
| 1 | P1-01 | 3V3 VCC | | |
|
||||
| 2 | P1-02 | 5V VCC | | |
|
||||
| 3 | P1-03 | I2C SDA | 2 | I2C0 |
|
||||
| 4 | P1-04 | 5V VCC | | |
|
||||
| 5 | P1-05 | I2C SCL | 3 | I2C0 |
|
||||
| 6 | P1-06 | GND | | |
|
||||
| 7 | P1-07 | GPIO(4) | 4 | ADC0 (iio:device0) |
|
||||
| 8 | P1-08 | UART TX | 14 | UART0 |
|
||||
| 9 | P1-09 | GND | | |
|
||||
| 10 | P1-10 | UART RX | 15 | UART0 |
|
||||
| 11 | P1-11 | UART_RTS | 17 | UART0 |
|
||||
| 12 | P1-12 | I2S CLK | 18 | |
|
||||
| 13 | P1-13 | GPIO(27) | 27 | |
|
||||
| 14 | P1-14 | GND | | |
|
||||
| 15 | P1-15 | GPIO(22) | 22 | |
|
||||
| 16 | P1-16 | GPIO(23) | 23 | |
|
||||
| 17 | P1-17 | 3V3 VCC | | |
|
||||
| 18 | P1-18 | GPIO(24) | 24 | |
|
||||
| 19 | P1-19 | SPI MOSI | 10 | SPI0,1 |
|
||||
| 20 | P1-20 | GND | | |
|
||||
| 21 | P1-21 | SPI MISO | 9 | SPI0,1 |
|
||||
| 22 | P1-22 | GPIO(25) | 25 | |
|
||||
| 23 | P1-23 | SPI SCL | 11 | SPI0,1 |
|
||||
| 24 | P1-24 | SPI CS0 | 8 | SPI0 |
|
||||
| 25 | P1-25 | GND | | |
|
||||
| 26 | P1-26 | SPI CS1 | 7 | SPI1 |
|
||||
| 27 | P1-27 | I2C SDA0 | 0 | I2C1 |
|
||||
| 28 | P1-28 | I2C SCL0 | 1 | I2C1 |
|
||||
| 29 | P1-29 | GPIO(5) | 5 | |
|
||||
| 30 | P1-30 | GND | | |
|
||||
| 31 | P1-31 | GPIO(6) | 6 | |
|
||||
| 32 | P1-32 | PWM0 | 12 | PWM0 |
|
||||
| 33 | P1-33 | PWM1 | 13 | PWM1 |
|
||||
| 34 | P1-34 | GND | | |
|
||||
| 35 | P1-35 | I2S FRM | 19 | |
|
||||
| 36 | P1-36 | UART_CTS | 16 | UART0 |
|
||||
| 37 | P1-37 | GPIO(26) | 26 | |
|
||||
| 38 | P1-38 | I2S DIN | 20 | |
|
||||
| 39 | P1-39 | GND | | |
|
||||
| 40 | P1-40 | I2S DOUT | 21 | |
|
||||
|
88
docs/up2.md
Normal file
88
docs/up2.md
Normal file
@@ -0,0 +1,88 @@
|
||||
UP Squared Board {#up2}
|
||||
================================
|
||||
UP Squared is based on the Intel® Celeron™ N3350 or the Intel® Pentium™ N4200, formerly ApolloLake™.
|
||||
|
||||
For the full specification please refer to the main specification page here:
|
||||
|
||||
http://www.up-board.org/upsquared/specifications-up2
|
||||
|
||||
Interface notes
|
||||
-----------------------
|
||||
The Up Squared present one Raspberry Pi compatible HAT connector and a 60 pin exHAT connector. Currently this implementation only support the interfaces through the HAT connector.
|
||||
|
||||
**I2C**
|
||||
- 2 channels
|
||||
- Support: standard-mode (100kHz), fast-mode (400kHz), Fast-mode plus (1MHz), High-speed mode (3.4MHz)
|
||||
- Bus frequency can be selected in BIOS settings
|
||||
- The default i2c channel is the one connected to the pin 3,5 of the hat
|
||||
- On some OSes the i2c-dev kernel module may need to be loaded manually to export the i2c device nodes
|
||||
|
||||
**SPI**
|
||||
- Bus frequencies up to 10MHz are supported
|
||||
- 3 chip-selects
|
||||
- To enable SPI device nodes the ACPI tables need to be overwritten as explained [here](https://up-community.org/wiki/Pinout_UP2#SPI_Ports)
|
||||
|
||||
**PWM**
|
||||
- Up to 3 channel of PWM
|
||||
|
||||
**UART**
|
||||
- 1 high-speed UART is available
|
||||
- Supporting baud rates up to 3686400 baud
|
||||
- Hardware flow-control signals are available on pins 11/36 (RTS/CTS)
|
||||
|
||||
Please note that a kernel with UP board support is required to enable the I/O
|
||||
interfaces above.
|
||||
|
||||
Refer to http://www.up-community.org for more information.
|
||||
|
||||
Pin Mapping
|
||||
--------------------
|
||||
The GPIO numbering in the following pin mapping is based on the Raspberry Pi
|
||||
model 2 and B+ numbering scheme.
|
||||
|
||||
NOTE: the i2c device numbering depend on various factor and cannot be trusted:
|
||||
the right way of determining i2c (and other devices) numbering is through PCI
|
||||
physical device names. See the source code in src/x86/up2.c for details.
|
||||
|
||||
| MRAA no. | Function | Rpi GPIO | Sysfs GPIO | mraa device |
|
||||
|----------|--------------|------------|------------|-----------------|
|
||||
| 1 | 3V3 VCC | | | |
|
||||
| 2 | 5V VCC | | | |
|
||||
| 3 | I2C_SDA | 2 | 462 | I2C0 |
|
||||
| 4 | 5V VCC | | | |
|
||||
| 5 | I2C_SCL | 3 | 463 | I2C0 |
|
||||
| 6 | GND | | | |
|
||||
| 7 | GPIO(4) | 4 | 433 | |
|
||||
| 8 | UART_TX | 14 | 477 | UART0 |
|
||||
| 9 | GND | | | |
|
||||
| 10 | UART_RX | 15 | 476 | UART0 |
|
||||
| 11 | UART_RTS | 17 | 478 | UART0 |
|
||||
| 12 | I2S_CLK | 18 | 326 | |
|
||||
| 13 | GPIO(27) | 27 | 432 | |
|
||||
| 14 | GND | | | |
|
||||
| 15 | GPIO(22) | 22 | 431 | |
|
||||
| 16 | PWM3 | 23 | 471 | PWM3 |
|
||||
| 17 | 3V3 VCC | | | |
|
||||
| 18 | GPIO(24) | 24 | 405 | |
|
||||
| 19 | SPI0_MOSI | 10 | 422 | SPI0 |
|
||||
| 20 | GND | | | |
|
||||
| 21 | SPI0_MISO | 9 | 421 | SPI0 |
|
||||
| 22 | GPIO(25) | 25 | 402 | |
|
||||
| 23 | SPI0_SCL | 11 | 418 | SPI0 |
|
||||
| 24 | SPI0_CS0 | 8 | 419 | SPI0 |
|
||||
| 25 | GND | | | |
|
||||
| 26 | SPI0_CS1 | 7 | 420 | SPI0 |
|
||||
| 27 | ID_SD | 0 | 464 | I2C1 |
|
||||
| 28 | ID_SC | 1 | 465 | I2C1 |
|
||||
| 29 | GPIO(5) | 5 | 430 | |
|
||||
| 30 | GND | | | |
|
||||
| 31 | GPIO(6) | 6 | 404 | |
|
||||
| 32 | PWM0 | 12 | 468 | PWM0 |
|
||||
| 33 | PWM1 | 13 | 469 | PWM1 |
|
||||
| 34 | GND | | | |
|
||||
| 35 | I2S_FRM | 19 | 327 | |
|
||||
| 36 | UART_CTS | 16 | 479 | UART0 |
|
||||
| 37 | GPIO(26) | 26 | 403 | |
|
||||
| 38 | I2S_DIN | 20 | 328 | |
|
||||
| 39 | GND | | | |
|
||||
| 40 | I2S_DOUT | 21 | 329 | |
|
Submodule doxygen2jsdoc updated: 9cc90b7976...67cad69272
1
doxyport
Submodule
1
doxyport
Submodule
Submodule doxyport added at db3e1a6eb8
@@ -1,61 +1,8 @@
|
||||
add_executable (i2c_HMC5883L i2c_HMC5883L.c)
|
||||
add_executable (hellomraa hellomraa.c)
|
||||
add_executable (cycle-pwm3 cycle-pwm3.c)
|
||||
add_executable (blink-io blink-io.c)
|
||||
add_executable (analogin_a0 analogin_a0.c)
|
||||
add_executable (isr_pin6 isr_pin6.c)
|
||||
add_executable (gpio_read6 gpio_read6.c)
|
||||
add_executable (spi_mcp4261 spi_mcp4261.c)
|
||||
add_executable (mmap-io2 mmap-io2.c)
|
||||
add_executable (blink_onboard blink_onboard.c)
|
||||
add_executable (uart uart.c)
|
||||
add_executable (mraa-gpio mraa-gpio.c)
|
||||
add_executable (mraa-i2c mraa-i2c.c)
|
||||
add_executable (spi_max7219 spi_max7219.c)
|
||||
add_executable (iio_driver iio_driver.c)
|
||||
add_subdirectory (c)
|
||||
add_subdirectory (platform)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
# FIXME Hack to access mraa internal types used by mraa-i2c
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api/mraa)
|
||||
|
||||
target_link_libraries (hellomraa mraa)
|
||||
target_link_libraries (i2c_HMC5883L mraa m)
|
||||
target_link_libraries (cycle-pwm3 mraa)
|
||||
target_link_libraries (blink-io mraa)
|
||||
target_link_libraries (analogin_a0 mraa)
|
||||
target_link_libraries (isr_pin6 mraa)
|
||||
target_link_libraries (gpio_read6 mraa)
|
||||
target_link_libraries (spi_mcp4261 mraa)
|
||||
target_link_libraries (mmap-io2 mraa)
|
||||
target_link_libraries (blink_onboard mraa)
|
||||
target_link_libraries (uart mraa)
|
||||
target_link_libraries (mraa-gpio mraa)
|
||||
target_link_libraries (mraa-i2c mraa)
|
||||
target_link_libraries (spi_max7219 mraa)
|
||||
target_link_libraries (iio_driver mraa)
|
||||
|
||||
if (ONEWIRE)
|
||||
add_executable (uart_ow uart_ow.c)
|
||||
target_link_libraries (uart_ow mraa)
|
||||
if (NOT ANDROID_TOOLCHAIN)
|
||||
add_subdirectory (c++)
|
||||
endif ()
|
||||
|
||||
if (FIRMATA)
|
||||
add_executable (firmata_curie_imu firmata_curie_imu.c)
|
||||
add_executable (i2c_firmata i2c_firmata.c)
|
||||
target_link_libraries (firmata_curie_imu mraa)
|
||||
target_link_libraries (i2c_firmata mraa)
|
||||
endif ()
|
||||
|
||||
add_subdirectory (c++)
|
||||
|
||||
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/mraa/examples)
|
||||
|
||||
if (INSTALLGPIOTOOL AND NOT INSTALLTOOLS)
|
||||
install (TARGETS mraa-gpio DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if (INSTALLTOOLS)
|
||||
install (TARGETS mraa-gpio DESTINATION bin)
|
||||
install (TARGETS mraa-i2c DESTINATION bin)
|
||||
endif()
|
||||
|
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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 <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mraa.h"
|
||||
|
||||
#define DEFAULT_IOPIN 8
|
||||
|
||||
int running = 0;
|
||||
static int iopin;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
printf("closing IO%d nicely\n", iopin);
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t r = MRAA_SUCCESS;
|
||||
iopin = DEFAULT_IOPIN;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Provide an int arg if you want to flash on something other than %d\n", DEFAULT_IOPIN);
|
||||
} else {
|
||||
iopin = strtol(argv[1], NULL, 10);
|
||||
}
|
||||
|
||||
mraa_init();
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Blinking on IO%d\n", mraa_get_version(), iopin);
|
||||
|
||||
mraa_gpio_context gpio;
|
||||
gpio = mraa_gpio_init(iopin);
|
||||
if (gpio == NULL) {
|
||||
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", iopin);
|
||||
exit(1);
|
||||
}
|
||||
printf("Initialised pin%d\n", iopin);
|
||||
|
||||
// set direction to OUT
|
||||
r = mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (running == 0) {
|
||||
r = mraa_gpio_write(gpio, 0);
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
} else {
|
||||
printf("off\n");
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
r = mraa_gpio_write(gpio, 1);
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
} else {
|
||||
printf("on\n");
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
r = mraa_gpio_close(gpio);
|
||||
if (r != MRAA_SUCCESS) {
|
||||
mraa_result_print(r);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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 <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa/gpio.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_platform_t platform = mraa_get_platform_type();
|
||||
mraa_gpio_context gpio, gpio_in = NULL;
|
||||
const char* board_name = mraa_get_platform_name();
|
||||
int ledstate = 0;
|
||||
|
||||
switch (platform) {
|
||||
case MRAA_INTEL_GALILEO_GEN1:
|
||||
gpio = mraa_gpio_init_raw(3);
|
||||
break;
|
||||
case MRAA_INTEL_MINNOWBOARD_MAX:
|
||||
// there is no onboard LED that we can flash on the minnowboard max
|
||||
// but on the calamari lure pin 21 is an LED. If you don't have the
|
||||
// lure put an LED on pin 21
|
||||
gpio = mraa_gpio_init(21);
|
||||
break;
|
||||
default:
|
||||
gpio = mraa_gpio_init(13);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
|
||||
|
||||
|
||||
if (gpio == NULL) {
|
||||
fprintf(stdout, "Could not initilaize gpio\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// on platforms with physical button use gpio_in
|
||||
if (platform == MRAA_INTEL_MINNOWBOARD_MAX) {
|
||||
gpio_in = mraa_gpio_init(14);
|
||||
if (gpio_in != NULL) {
|
||||
mraa_gpio_dir(gpio_in, MRAA_GPIO_IN);
|
||||
// S1 on minnowboardmax's calamari lure maps to pin 14, SW1 != S1
|
||||
fprintf(stdout, "Press and hold S1 to stop, Press SW1 to shutdown!\n");
|
||||
}
|
||||
}
|
||||
|
||||
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
|
||||
|
||||
for (;;) {
|
||||
if (gpio_in != NULL && mraa_gpio_read(gpio_in) == 0) {
|
||||
return 0;
|
||||
}
|
||||
ledstate = !ledstate;
|
||||
mraa_gpio_write(gpio, !ledstate);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributors: Alex Tereschenko <alex.mkrs@gmail.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -22,26 +23,36 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//! [Interesting]
|
||||
#include <signal.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
int running = 0;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT) {
|
||||
printf("closing down nicely\n");
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main()
|
||||
{
|
||||
uint16_t adc_value;
|
||||
float adc_value_float;
|
||||
mraa::Aio* a0;
|
||||
mraa::Aio a0(0);
|
||||
|
||||
a0 = new mraa::Aio(0);
|
||||
if (a0 == NULL) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
for (;;) {
|
||||
adc_value = a0->read();
|
||||
adc_value_float = a0->readFloat();
|
||||
while (running == 0) {
|
||||
adc_value = a0.read();
|
||||
adc_value_float = a0.readFloat();
|
||||
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f (Ctrl+C to exit)\n", adc_value_float);
|
||||
}
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
|
@@ -55,23 +55,19 @@ main(int argc, char** argv)
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
mraa::Gpio* gpio = new mraa::Gpio(iopin);
|
||||
if (gpio == NULL) {
|
||||
return mraa::ERROR_UNSPECIFIED;
|
||||
}
|
||||
mraa::Result response = gpio->dir(mraa::DIR_OUT);
|
||||
mraa::Gpio gpio(iopin);
|
||||
mraa::Result response = gpio.dir(mraa::DIR_OUT);
|
||||
if (response != mraa::SUCCESS) {
|
||||
mraa::printError(response);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (running == 0) {
|
||||
response = gpio->write(1);
|
||||
response = gpio.write(1);
|
||||
sleep(1);
|
||||
response = gpio->write(0);
|
||||
response = gpio.write(0);
|
||||
sleep(1);
|
||||
}
|
||||
delete gpio;
|
||||
return response;
|
||||
//! [Interesting]
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ add_executable (Isr-pin6 Isr-pin6.cpp)
|
||||
add_executable (Iio-dummy Iio-dummy.cpp)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api/mraa)
|
||||
|
||||
target_link_libraries (AioA0 mraa stdc++)
|
||||
target_link_libraries (blink-io-cpp mraa stdc++)
|
||||
|
@@ -23,11 +23,11 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
#include "math.h"
|
||||
#include "mraa.hpp"
|
||||
|
||||
#define MAX_BUFFER_LENGTH 6
|
||||
#define HMC5883L_I2C_ADDR 0x1E
|
||||
@@ -99,28 +99,27 @@ main()
|
||||
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
|
||||
//! [Interesting]
|
||||
mraa::I2c* i2c;
|
||||
i2c = new mraa::I2c(0);
|
||||
mraa::I2c i2c(0);
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
rx_tx_buf[1] = GA_1_3_REG;
|
||||
i2c->write(rx_tx_buf, 2);
|
||||
i2c.write(rx_tx_buf, 2);
|
||||
//! [Interesting]
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
i2c->write(rx_tx_buf, 2);
|
||||
i2c.write(rx_tx_buf, 2);
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
while (running == 0) {
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c->writeByte(HMC5883L_DATA_REG);
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.writeByte(HMC5883L_DATA_REG);
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c->read(rx_tx_buf, DATA_REG_SIZE);
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.read(rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
||||
@@ -138,7 +137,6 @@ main()
|
||||
printf("Heading : %f\n", direction * 180 / M_PI);
|
||||
sleep(1);
|
||||
}
|
||||
delete i2c;
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
@@ -22,63 +22,65 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "mraa/iio.hpp"
|
||||
#include <float.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include "mraa/iio.hpp"
|
||||
#include <unistd.h>
|
||||
|
||||
#define EXPECT_FAILURE 0
|
||||
#define EXPECT_SUCCESS 1
|
||||
|
||||
#define IIO_TRY(func) \
|
||||
{ \
|
||||
bool success = true; \
|
||||
try { \
|
||||
iio_device->func; \
|
||||
} catch (std::exception& e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, "", true, success); \
|
||||
}
|
||||
#define IIO_TRY(func) \
|
||||
{ \
|
||||
bool success = true; \
|
||||
try { \
|
||||
iio_device->func; \
|
||||
} catch (std::exception & e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, "", true, success); \
|
||||
}
|
||||
|
||||
// Macro to run IIO method on attribute and log output
|
||||
#define IIO_RUN(func, attr, value, expect) \
|
||||
{ \
|
||||
std::string attr_name = attr; \
|
||||
bool success = true; \
|
||||
try { \
|
||||
iio_device->func(attr_name, value); \
|
||||
} catch (std::exception& e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, attr_name, expect, success); \
|
||||
}
|
||||
#define IIO_RUN(func, attr, value, expect) \
|
||||
{ \
|
||||
std::string attr_name = attr; \
|
||||
bool success = true; \
|
||||
try { \
|
||||
iio_device->func(attr_name, value); \
|
||||
} catch (std::exception & e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, attr_name, expect, success); \
|
||||
}
|
||||
|
||||
// Macro to run IIO method on attribute and check for expected result and log output
|
||||
#define IIO_TEST(func, attr, value, expect) \
|
||||
{ \
|
||||
std::string attr_name = attr; \
|
||||
bool success = false; \
|
||||
try { \
|
||||
success = fabs(iio_device->func(attr_name) - value) < FLT_EPSILON; \
|
||||
} catch (std::exception& e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, attr_name, expect, success); \
|
||||
}
|
||||
#define IIO_TEST(func, attr, value, expect) \
|
||||
{ \
|
||||
std::string attr_name = attr; \
|
||||
bool success = false; \
|
||||
try { \
|
||||
success = fabs(iio_device->func(attr_name) - value) < FLT_EPSILON; \
|
||||
} catch (std::exception & e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, attr_name, expect, success); \
|
||||
}
|
||||
|
||||
mraa::Iio* iio_device;
|
||||
int eventCount = 0;
|
||||
|
||||
// Log result of test. Note a "fail" (i.e. success is false) will be displayed as a pass if a fail was expected
|
||||
void log_result(std::string test_name, std::string attr_name, bool expect_success, bool success)
|
||||
// Log result of test. Note a "fail" (i.e. success is false) will be displayed as a pass if a fail
|
||||
// was expected
|
||||
void
|
||||
log_result(std::string test_name, std::string attr_name, bool expect_success, bool success)
|
||||
{
|
||||
std::string result;
|
||||
if (expect_success)
|
||||
result = success ? "PASS" : "FAIL";
|
||||
result = success ? "PASS" : "FAIL";
|
||||
else
|
||||
result = success ? "FAIL" : "PASS";
|
||||
result = success ? "FAIL" : "PASS";
|
||||
if (attr_name.empty())
|
||||
fprintf(stdout, "%s: %s\n", test_name.c_str(), result.c_str());
|
||||
else
|
||||
@@ -86,9 +88,10 @@ void log_result(std::string test_name, std::string attr_name, bool expect_succes
|
||||
}
|
||||
|
||||
// Generate iio_dummy driver event by writing a string to a specific sysfs node
|
||||
bool generate_event()
|
||||
bool
|
||||
generate_event()
|
||||
{
|
||||
FILE *fp = fopen("/sys/bus/iio/devices/iio_evgen/poke_ev0", "w");
|
||||
FILE* fp = fopen("/sys/bus/iio/devices/iio_evgen/poke_ev0", "w");
|
||||
if (fp == NULL)
|
||||
return false;
|
||||
fprintf(fp, "1\n");
|
||||
@@ -100,13 +103,17 @@ bool generate_event()
|
||||
// IIO event handler that checks for event from dummy_iio_evgen driver
|
||||
class IioTestHandler : public mraa::IioHandler
|
||||
{
|
||||
protected:
|
||||
void onIioEvent(const mraa::IioEventData& eventData) {
|
||||
if (eventData.channelType == IIO_VOLTAGE && eventData.direction == IIO_EV_DIR_RISING && eventData.type == IIO_EV_TYPE_THRESH)
|
||||
protected:
|
||||
void
|
||||
onIioEvent(const mraa::IioEventData& eventData)
|
||||
{
|
||||
if (eventData.channelType == IIO_VOLTAGE && eventData.direction == IIO_EV_DIR_RISING &&
|
||||
eventData.type == IIO_EV_TYPE_THRESH)
|
||||
eventCount++;
|
||||
}
|
||||
};
|
||||
|
||||
//! [Interesting]
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -154,4 +161,4 @@ main()
|
||||
delete iio_device;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -38,13 +39,14 @@ interrupt(void* args)
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa::Gpio* x = new mraa::Gpio(6);
|
||||
mraa::Gpio x(6);
|
||||
|
||||
x->dir(mraa::DIR_IN);
|
||||
x.dir(mraa::DIR_IN);
|
||||
|
||||
x->isr(mraa::EDGE_BOTH, &interrupt, NULL);
|
||||
x.isr(mraa::EDGE_BOTH, &interrupt, NULL);
|
||||
|
||||
for (;;) {
|
||||
int i = 100;
|
||||
for (; i > 0; --i) {
|
||||
if (counter != oldcounter) {
|
||||
fprintf(stdout, "timeout counter == %d\n", counter);
|
||||
oldcounter = counter;
|
||||
@@ -53,5 +55,5 @@ main()
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
@@ -22,8 +22,8 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
@@ -43,25 +43,19 @@ main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
mraa::Pwm* pwm;
|
||||
|
||||
pwm = new mraa::Pwm(3);
|
||||
if (pwm == NULL) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
mraa::Pwm pwm(3);
|
||||
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
|
||||
pwm->enable(true);
|
||||
pwm.enable(true);
|
||||
|
||||
float value = 0.0f;
|
||||
while (running == 0) {
|
||||
value = value + 0.01f;
|
||||
pwm->write(value);
|
||||
pwm.write(value);
|
||||
usleep(50000);
|
||||
if (value >= 1.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
}
|
||||
delete pwm;
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
|
@@ -22,9 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
@@ -45,9 +45,7 @@ main()
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
mraa::Spi* spi;
|
||||
|
||||
spi = new mraa::Spi(0);
|
||||
mraa::Spi spi(0);
|
||||
|
||||
uint8_t data[] = { 0x00, 100 };
|
||||
uint8_t rxBuf[2];
|
||||
@@ -56,7 +54,7 @@ main()
|
||||
int i;
|
||||
for (i = 90; i < 130; i++) {
|
||||
data[1] = i;
|
||||
recv = spi->write(data, 2);
|
||||
recv = spi.write(data, 2);
|
||||
printf("Writing -%i", i);
|
||||
if (recv) {
|
||||
printf("RECIVED-%i-%i\n", recv[0], recv[1]);
|
||||
@@ -66,14 +64,13 @@ main()
|
||||
}
|
||||
for (i = 130; i > 90; i--) {
|
||||
data[1] = i;
|
||||
if (spi->transfer(data, rxBuf, 2) == mraa::SUCCESS) {
|
||||
if (spi.transfer(data, rxBuf, 2) == mraa::SUCCESS) {
|
||||
printf("Writing -%i", i);
|
||||
printf("RECIVED-%i-%i\n", rxBuf[0], rxBuf[1]);
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
||||
delete spi;
|
||||
//! [Interesting]
|
||||
|
||||
return mraa::SUCCESS;
|
||||
|
@@ -22,9 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
|
@@ -22,44 +22,42 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
#include "iostream"
|
||||
#include "stdio.h"
|
||||
//! [Interesting]
|
||||
#include "uart_ow.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa::UartOW* uart = new mraa::UartOW(0);
|
||||
mraa::UartOW uart(0);
|
||||
|
||||
// Reset the ow bus and see if anything is present
|
||||
mraa::Result rv;
|
||||
|
||||
if ((rv = uart->reset()) == mraa::SUCCESS) {
|
||||
cout << "Reset succeeded, device(s) detected!" << endl;
|
||||
if ((rv = uart.reset()) == mraa::SUCCESS) {
|
||||
std::cout << "Reset succeeded, device(s) detected!" << std::endl;
|
||||
} else {
|
||||
cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl;
|
||||
std::cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
cout << "Looking for devices..." << endl;
|
||||
std::cout << "Looking for devices..." << std::endl;
|
||||
;
|
||||
|
||||
uint8_t count = 0;
|
||||
// start the search from scratch
|
||||
string id = uart->search(true);
|
||||
std::string id = uart.search(true);
|
||||
|
||||
if (id.empty()) {
|
||||
cout << "No devices detected." << endl;
|
||||
std::cout << "No devices detected." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!id.empty()) {
|
||||
// hack so we don't need to cast each element of the romcode
|
||||
// for printf purposes
|
||||
uint8_t* ptr = (uint8_t*) id.c_str();
|
||||
uint8_t* ptr = (uint8_t*) id.data();
|
||||
|
||||
// The first byte (0) is the device type (family) code.
|
||||
// The last byte (7) is the rom code CRC value. The
|
||||
@@ -70,12 +68,10 @@ main(int argc, char** argv)
|
||||
count++;
|
||||
|
||||
// continue the search with start argument set to false
|
||||
id = uart->search(false);
|
||||
id = uart.search(false);
|
||||
}
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete uart;
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
69
examples/c++/initio.cpp
Normal file
69
examples/c++/initio.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Author: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
// GPIO-PIN
|
||||
mraa::Gpio* gpio = mraa::initIo<mraa::Gpio>("gpio-1");
|
||||
// GPIO-RAW-RAWPIN
|
||||
mmraa::Gpio* gpioraw = mraa::initIo<mraa::Gpio> initIo("gpio-raw-131");
|
||||
// AIO-PIN
|
||||
mraa::Aio aio = mraa::initIo<mraa::Aio>("aio-0");
|
||||
// PWM-PIN
|
||||
mraa::Pwm pwm = mraa::initIo<mraa::Pwm>("pwm-6");
|
||||
// PWM-RAW-CHIPID-PIN
|
||||
mraa::Pwm pwmraw = mraa::initIo<mraa::Pwm>("pwm-raw-0,1");
|
||||
// UART-INDEX: the index is the one represented internally in the uart_dev array
|
||||
mraa::Uart uart = mraa::initIo<mraa::Uart>("uart-1");
|
||||
// UART-RAW-PATH
|
||||
mraa::Uart uartraw = mraa::initIo<mraa::Uart>("uart-raw-/dev/ttyS0");
|
||||
// SPI-INDEX: same as UART
|
||||
mraa::Spi spi = mraa::initIo<mraa::Spi>("spi-0");
|
||||
// SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
|
||||
mraa::Spi spiraw = mraa::initIo<mraa::Spi>("spi-raw-0-1");
|
||||
// I2C-INDEX: same as UART
|
||||
mraa::I2c i2c = mraa::initIo<mraa::I2c>("i2c-0");
|
||||
// I2C-RAW-BUS
|
||||
mraa::I2c i2craw = mraa::initIo<mraa::I2c>("i2c-raw-0");
|
||||
|
||||
// FREE STUFF
|
||||
delete gpio;
|
||||
delete gpioraw;
|
||||
delete aio;
|
||||
delete pwm;
|
||||
delete pwmraw;
|
||||
delete uart;
|
||||
delete uartraw;
|
||||
delete spi;
|
||||
delete spiraw;
|
||||
delete i2c;
|
||||
delete i2craw;
|
||||
}
|
36
examples/c/CMakeLists.txt
Normal file
36
examples/c/CMakeLists.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
add_executable(aio aio.c)
|
||||
add_executable(gpio gpio.c)
|
||||
add_executable(gpio_advanced gpio_advanced.c)
|
||||
add_executable(hellomraa hellomraa.c)
|
||||
add_executable(i2c_hmc5883l i2c_hmc5883l.c)
|
||||
add_executable(i2c_mpu6050 i2c_mpu6050.c)
|
||||
add_executable(led led.c)
|
||||
add_executable(pwm pwm.c)
|
||||
add_executable(spi spi.c)
|
||||
add_executable(uart uart.c)
|
||||
add_executable(uart_advanced uart_advanced.c)
|
||||
if (NOT ANDROID_TOOLCHAIN)
|
||||
add_executable(iio iio.c)
|
||||
endif()
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api/mraa)
|
||||
|
||||
target_link_libraries(aio mraa)
|
||||
target_link_libraries(gpio mraa)
|
||||
target_link_libraries(gpio_advanced mraa)
|
||||
target_link_libraries(hellomraa mraa)
|
||||
target_link_libraries(i2c_hmc5883l mraa m)
|
||||
target_link_libraries(i2c_mpu6050 mraa)
|
||||
target_link_libraries(led mraa)
|
||||
target_link_libraries(pwm mraa)
|
||||
target_link_libraries(spi mraa)
|
||||
target_link_libraries(uart mraa)
|
||||
target_link_libraries(uart_advanced mraa)
|
||||
if (NOT ANDROID_TOOLCHAIN)
|
||||
target_link_libraries(iio mraa)
|
||||
endif()
|
||||
if (ONEWIRE)
|
||||
add_executable (uart_ow uart_ow.c)
|
||||
target_link_libraries (uart_ow mraa)
|
||||
endif ()
|
99
examples/c/aio.c
Normal file
99
examples/c/aio.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Author: Nandkishor Sonar
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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.
|
||||
*
|
||||
* Example usage: Reads ADC A0 value continuously. Press Ctrl+C to exit.
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/aio.h"
|
||||
|
||||
/* AIO port */
|
||||
#define AIO_PORT 0
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_aio_context aio;
|
||||
uint16_t value = 0;
|
||||
float float_value = 0.0;
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize AIO */
|
||||
aio = mraa_aio_init(AIO_PORT);
|
||||
if (aio == NULL) {
|
||||
fprintf(stderr, "Failed to initialize AIO\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while (flag) {
|
||||
value = mraa_aio_read(aio);
|
||||
float_value = mraa_aio_read_float(aio);
|
||||
fprintf(stdout, "ADC A0 read %X - %d\n", value, value);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f\n", float_value);
|
||||
}
|
||||
|
||||
/* close AIO */
|
||||
status = mraa_aio_close(aio);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
147
examples/c/gpio.c
Normal file
147
examples/c/gpio.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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.
|
||||
*
|
||||
* Example usage: Toggles GPIO's 23 and 24 recursively. Press Ctrl+C to exit
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/gpio.h"
|
||||
|
||||
/* gpio declaration */
|
||||
#define GPIO_PIN_1 23
|
||||
#define GPIO_PIN_2 24
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_gpio_context gpio_1, gpio_2;
|
||||
|
||||
/* install signal handler */
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize GPIO pin */
|
||||
gpio_1 = mraa_gpio_init(GPIO_PIN_1);
|
||||
if (gpio_1 == NULL) {
|
||||
fprintf(stderr, "Failed to initialize GPIO %d\n", GPIO_PIN_1);
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* initialize GPIO pin */
|
||||
gpio_2 = mraa_gpio_init(GPIO_PIN_2);
|
||||
if (gpio_2 == NULL) {
|
||||
fprintf(stderr, "Failed to initialize GPIO %d\n", GPIO_PIN_2);
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set GPIO to output */
|
||||
status = mraa_gpio_dir(gpio_1, MRAA_GPIO_OUT);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* set GPIO to output */
|
||||
status = mraa_gpio_dir(gpio_2, MRAA_GPIO_OUT);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* toggle both GPIO's */
|
||||
while (flag) {
|
||||
status = mraa_gpio_write(gpio_1, 1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
status = mraa_gpio_write(gpio_2, 0);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
status = mraa_gpio_write(gpio_1, 0);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
status = mraa_gpio_write(gpio_2, 1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
/* release gpio's */
|
||||
status = mraa_gpio_close(gpio_1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* close GPIO */
|
||||
status = mraa_gpio_close(gpio_2);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
94
examples/c/gpio_advanced.c
Normal file
94
examples/c/gpio_advanced.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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.
|
||||
*
|
||||
* Example usage: Configures GPIO pin for interrupt and waits 30 seconds for the isr to trigger
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/gpio.h"
|
||||
|
||||
#define GPIO_PIN 6
|
||||
|
||||
void
|
||||
int_handler(void* args)
|
||||
{
|
||||
fprintf(stdout, "ISR triggered\n");
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_gpio_context gpio;
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize GPIO pin */
|
||||
gpio = mraa_gpio_init(GPIO_PIN);
|
||||
if (gpio == NULL) {
|
||||
fprintf(stderr, "Failed to initialize GPIO %d\n", GPIO_PIN);
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set GPIO to input */
|
||||
status = mraa_gpio_dir(gpio, MRAA_GPIO_IN);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* configure ISR for GPIO */
|
||||
status = mraa_gpio_isr(gpio, MRAA_GPIO_EDGE_BOTH, &int_handler, NULL);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* wait 30 seconds isr trigger */
|
||||
sleep(30);
|
||||
|
||||
/* close GPIO */
|
||||
mraa_gpio_close(gpio);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
@@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
//! [Interesting]
|
||||
#include "mraa.h"
|
||||
|
@@ -20,22 +20,33 @@
|
||||
* 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.
|
||||
*
|
||||
* Example usage: Outputs X,Y,Z co-ordinates and direction recursively using
|
||||
* HMC5883L. Press Ctrl+C to exit.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mraa.h"
|
||||
#include "math.h"
|
||||
/* standard headers */
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/i2c.h"
|
||||
|
||||
#define MAX_BUFFER_LENGTH 6
|
||||
#define HMC5883L_I2C_ADDR 0x1E
|
||||
|
||||
// configuration registers
|
||||
/* configuration registers */
|
||||
#define HMC5883L_CONF_REG_A 0x00
|
||||
#define HMC5883L_CONF_REG_B 0x01
|
||||
|
||||
// mode register
|
||||
/* mode register */
|
||||
#define HMC5883L_MODE_REG 0x02
|
||||
|
||||
// data register
|
||||
/* data register */
|
||||
#define HMC5883L_X_MSB_REG 0
|
||||
#define HMC5883L_X_LSB_REG 1
|
||||
#define HMC5883L_Z_MSB_REG 2
|
||||
@@ -44,10 +55,10 @@
|
||||
#define HMC5883L_Y_LSB_REG 5
|
||||
#define DATA_REG_SIZE 6
|
||||
|
||||
// status register
|
||||
/* status register */
|
||||
#define HMC5883L_STATUS_REG 0x09
|
||||
|
||||
// ID registers
|
||||
/* ID registers */
|
||||
#define HMC5883L_ID_A_REG 0x0A
|
||||
#define HMC5883L_ID_B_REG 0x0B
|
||||
#define HMC5883L_ID_C_REG 0x0C
|
||||
@@ -55,7 +66,7 @@
|
||||
#define HMC5883L_CONT_MODE 0x00
|
||||
#define HMC5883L_DATA_REG 0x03
|
||||
|
||||
// scales
|
||||
/* scales */
|
||||
#define GA_0_88_REG 0x00 << 5
|
||||
#define GA_1_3_REG 0x01 << 5
|
||||
#define GA_1_9_REG 0x02 << 5
|
||||
@@ -65,7 +76,7 @@
|
||||
#define GA_5_6_REG 0x06 << 5
|
||||
#define GA_8_1_REG 0x07 << 5
|
||||
|
||||
// digital resolutions
|
||||
/* digital resolutions */
|
||||
#define SCALE_0_73_MG 0.73
|
||||
#define SCALE_0_92_MG 0.92
|
||||
#define SCALE_1_22_MG 1.22
|
||||
@@ -75,62 +86,139 @@
|
||||
#define SCALE_3_03_MG 3.03
|
||||
#define SCALE_4_35_MG 4.35
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
#define I2C_BUS 0
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
mraa_init();
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_i2c_context i2c;
|
||||
float direction = 0;
|
||||
int16_t x = 0, y = 0, z = 0;
|
||||
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
|
||||
//! [Interesting]
|
||||
mraa_i2c_context i2c;
|
||||
i2c = mraa_i2c_init(0);
|
||||
/* install signal handler */
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
i2c = mraa_i2c_init(I2C_BUS);
|
||||
if (i2c == NULL) {
|
||||
fprintf(stderr, "Failed to initialize I2C\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set slave address */
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* set device gain */
|
||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
rx_tx_buf[1] = GA_1_3_REG;
|
||||
mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
//! [Interesting]
|
||||
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
status = mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
status = mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* set continuous mode */
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
|
||||
for (;;) {
|
||||
status = mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
while (flag) {
|
||||
#if 0
|
||||
int i = 0;
|
||||
//alternative, equivalent method which helps to understand exactly what
|
||||
//the below does
|
||||
/*
|
||||
* alternative, equivalent method which helps to understand exactly what
|
||||
* the below does
|
||||
*/
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
for (i = 0; i < DATA_REG_SIZE; i++) {
|
||||
mraa_i2c_read_byte_data(i2c, HMC5883L_DATA_REG+i);
|
||||
}
|
||||
#endif
|
||||
// first 'select' the register we want to read from
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
mraa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
||||
/* select data register to read */
|
||||
status = mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
// then we read from that register incrementing with every read the
|
||||
// chosen register
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
// this call behaves very similarly to the Wire receive() call
|
||||
status = mraa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* do a incremental read from the chosen address */
|
||||
status = mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* this call behaves very similarly to the Wire receive() call */
|
||||
mraa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
|
||||
|
||||
// scale and calculate direction
|
||||
/* scale and calculate direction */
|
||||
direction = atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
||||
|
||||
// check if the signs are reversed
|
||||
if (direction < 0)
|
||||
/* check if the signs are reversed */
|
||||
if (direction < 0) {
|
||||
direction += 2 * M_PI;
|
||||
}
|
||||
|
||||
printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
|
||||
z * SCALE_0_92_MG);
|
||||
printf("Heading : %f\n", direction * 180 / M_PI);
|
||||
fprintf(stdout, "Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG,
|
||||
y * SCALE_0_92_MG, z * SCALE_0_92_MG);
|
||||
fprintf(stdout, "Heading : %f\n", direction * 180 / M_PI);
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
/* stop i2c */
|
||||
mraa_i2c_stop(i2c);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* stop i2c */
|
||||
mraa_i2c_stop(i2c);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
170
examples/c/i2c_mpu6050.c
Normal file
170
examples/c/i2c_mpu6050.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2018, Linaro Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Example usage: Outputs Accelerometer and Gyroscope value from MPU6050 recursively.
|
||||
* Press Ctrl+C to exit.
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/i2c.h"
|
||||
|
||||
#define I2C_BUS 0
|
||||
|
||||
/* register definitions */
|
||||
#define MPU6050_ADDR 0x68
|
||||
#define MPU6050_REG_PWR_MGMT_1 0x6b
|
||||
#define MPU6050_REG_RAW_ACCEL_X 0x3b
|
||||
#define MPU6050_REG_RAW_ACCEL_Y 0x3d
|
||||
#define MPU6050_REG_RAW_ACCEL_Z 0x3f
|
||||
#define MPU6050_REG_RAW_GYRO_X 0x43
|
||||
#define MPU6050_REG_RAW_GYRO_Y 0x45
|
||||
#define MPU6050_REG_RAW_GYRO_Z 0x47
|
||||
|
||||
/* bit definitions */
|
||||
#define MPU6050_RESET 0x80
|
||||
#define MPU6050_SLEEP (1 << 6)
|
||||
#define MPU6050_PLL_GYRO_X (1 << 1)
|
||||
|
||||
/* accelerometer scale factor for (+/-)2g */
|
||||
#define MPU6050_ACCEL_SCALE 16384.0
|
||||
|
||||
/* gyroscope scale factor for (+/-)250/s */
|
||||
#define MPU6050_GYRO_SCALE 131.0
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int16_t
|
||||
i2c_read_word(mraa_i2c_context dev, uint8_t command)
|
||||
{
|
||||
return be16toh(mraa_i2c_read_word_data(dev, command));
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_i2c_context i2c;
|
||||
uint8_t data;
|
||||
int16_t accel_data[3];
|
||||
int16_t gyro_data[3];
|
||||
int ret;
|
||||
|
||||
/* install signal handler */
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize I2C bus */
|
||||
i2c = mraa_i2c_init(I2C_BUS);
|
||||
if (i2c == NULL) {
|
||||
fprintf(stderr, "Failed to initialize I2C\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set slave address */
|
||||
status = mraa_i2c_address(i2c, MPU6050_ADDR);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* reset the sensor */
|
||||
status = mraa_i2c_write_byte_data(i2c, MPU6050_RESET, MPU6050_REG_PWR_MGMT_1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
sleep(5);
|
||||
|
||||
/* configure power management register */
|
||||
ret = mraa_i2c_read_byte_data(i2c, MPU6050_REG_PWR_MGMT_1);
|
||||
if (ret == -1) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
data = ret;
|
||||
data |= MPU6050_PLL_GYRO_X;
|
||||
data &= ~(MPU6050_SLEEP);
|
||||
|
||||
status = mraa_i2c_write_byte_data(i2c, data, MPU6050_REG_PWR_MGMT_1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
sleep(5);
|
||||
|
||||
while (flag) {
|
||||
/* read raw accel data */
|
||||
accel_data[0] = i2c_read_word(i2c, MPU6050_REG_RAW_ACCEL_X) / MPU6050_ACCEL_SCALE;
|
||||
accel_data[1] = i2c_read_word(i2c, MPU6050_REG_RAW_ACCEL_Y) / MPU6050_ACCEL_SCALE;
|
||||
accel_data[2] = i2c_read_word(i2c, MPU6050_REG_RAW_ACCEL_Z) / MPU6050_ACCEL_SCALE;
|
||||
|
||||
/* read raw gyro data */
|
||||
gyro_data[0] = i2c_read_word(i2c, MPU6050_REG_RAW_GYRO_X) / MPU6050_GYRO_SCALE;
|
||||
gyro_data[1] = i2c_read_word(i2c, MPU6050_REG_RAW_GYRO_Y) / MPU6050_GYRO_SCALE;
|
||||
gyro_data[2] = i2c_read_word(i2c, MPU6050_REG_RAW_GYRO_Z) / MPU6050_GYRO_SCALE;
|
||||
|
||||
fprintf(stdout, "accel: x:%d y:%d z:%d\n", accel_data[0], accel_data[1], accel_data[2]);
|
||||
fprintf(stdout, "gyro: x:%d y:%d z:%d\n\n", gyro_data[0], gyro_data[1], gyro_data[2]);
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
/* stop i2c */
|
||||
mraa_i2c_stop(i2c);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* stop i2c */
|
||||
mraa_i2c_stop(i2c);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
172
examples/c/iio.c
Normal file
172
examples/c/iio.c
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Example usage: Sets accelerometer scale, enables the x axis measurement and sets the trigger.
|
||||
* Waits 100 seconds for the buffer trigger to happen.
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/iio.h"
|
||||
|
||||
/* IIO device */
|
||||
#define IIO_DEV 0
|
||||
|
||||
static void
|
||||
printword(uint16_t input, mraa_iio_channel* chan)
|
||||
{
|
||||
int16_t res;
|
||||
|
||||
if (!chan->lendian) {
|
||||
input = be16toh(input);
|
||||
} else {
|
||||
input = le16toh(input);
|
||||
}
|
||||
|
||||
input >>= chan->shift;
|
||||
input &= chan->mask;
|
||||
if (chan->signedd) {
|
||||
res = (int16_t)(input << (16 - chan->bits_used)) >> (16 - chan->bits_used);
|
||||
} else {
|
||||
res = input;
|
||||
}
|
||||
fprintf(stdout, " value = %05f\n", (float) res);
|
||||
}
|
||||
|
||||
void
|
||||
interrupt(char* data, void* args)
|
||||
{
|
||||
mraa_iio_context thisdevice = (mraa_iio_context) args;
|
||||
mraa_iio_channel* channels = mraa_iio_get_channels(thisdevice);
|
||||
int i = 0;
|
||||
|
||||
for (; i < mraa_iio_get_channel_count(thisdevice); i++) {
|
||||
if (channels[i].enabled) {
|
||||
fprintf(stdout, "channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
|
||||
switch (channels[i].bytes) {
|
||||
case 2:
|
||||
printword(*(uint16_t*) (data + channels[i].location), &channels[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
event_interrupt(struct iio_event_data* data)
|
||||
{
|
||||
int chan_type;
|
||||
int modifier;
|
||||
int type;
|
||||
int direction;
|
||||
int channel;
|
||||
int channel2;
|
||||
int different;
|
||||
mraa_iio_event_extract_event(data, &chan_type, &modifier, &type, &direction, &channel, &channel2, &different);
|
||||
|
||||
fprintf(stdout,
|
||||
"event time %lld id %lld extracted chan_type %d modifier %d type %d direction %d "
|
||||
"channel %d channel2 %d different %d\n",
|
||||
data->timestamp, data->id, chan_type, modifier, type, direction, channel, channel2, different);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_iio_context iio;
|
||||
float iio_float;
|
||||
int iio_int;
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize iio */
|
||||
iio = mraa_iio_init(IIO_DEV);
|
||||
if (iio == NULL) {
|
||||
fprintf(stderr, "Failed to initialize IIO device\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
status = mraa_iio_write_float(iio, "in_accel_scale", 0.019163);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "Failed to write scale to IIO device\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
status = mraa_iio_read_float(iio, "in_accel_scale", &iio_float);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "Failed to read scale from IIO device\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
fprintf(stdout, "IIO scale: %f\n", iio_float);
|
||||
|
||||
status = mraa_iio_write_int(iio, "scan_elements/in_accel_x_en", 1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "Failed to enable axis of the IIO device\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
status = mraa_iio_read_int(iio, "scan_elements/in_accel_x_en", &iio_int);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "Failed to read enable status from IIO device\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
fprintf(stdout, "IIO enable status: %d\n", iio_int);
|
||||
|
||||
status = mraa_iio_trigger_buffer(iio, interrupt, (void*) iio);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "Failed to set IIO buffer trigger\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* wait for the trigger */
|
||||
fprintf(stdout, "Waiting for the trigger...\n");
|
||||
sleep(100);
|
||||
|
||||
/* close IIO device */
|
||||
mraa_iio_close(iio);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* close IIO device */
|
||||
mraa_iio_close(iio);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
108
examples/c/led.c
Normal file
108
examples/c/led.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2018, Linaro Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Example usage: Reads maximum brightness value for user led and turns it
|
||||
* on/off depending on current state. Then sets led trigger
|
||||
* to heartbeat.
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/led.h"
|
||||
|
||||
/* LED name */
|
||||
#define USER_LED "user1"
|
||||
|
||||
/* trigger type */
|
||||
#define LED_TRIGGER "heartbeat"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_led_context led;
|
||||
int val;
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the time) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize LED */
|
||||
led = mraa_led_init(USER_LED);
|
||||
if (led == NULL) {
|
||||
fprintf(stderr, "Failed to initialize LED\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* read maximum brightness */
|
||||
val = mraa_led_read_max_brightness(led);
|
||||
fprintf(stdout, "maximum brightness value for LED is: %d\n", val);
|
||||
if (val >= 1) {
|
||||
val = 0;
|
||||
} else {
|
||||
/* never reached mostly */
|
||||
val = 1;
|
||||
}
|
||||
|
||||
/* turn LED on/off depending on max_brightness value */
|
||||
status = mraa_led_set_brightness(led, val);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "unable to set LED brightness\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* sleep for 5 seconds */
|
||||
sleep(5);
|
||||
|
||||
/* set LED trigger to heartbeat */
|
||||
status = mraa_led_set_trigger(led, LED_TRIGGER);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stderr, "unable to set LED trigger to: heartbeat\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
fprintf(stdout, "LED trigger set to: heartbeat\n");
|
||||
|
||||
/* close LED */
|
||||
mraa_led_close(led);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
124
examples/c/pwm.c
Normal file
124
examples/c/pwm.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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.
|
||||
*
|
||||
* Example usage: Generates PWM signal of period 200us with variable dutycyle
|
||||
* repeately. Press Ctrl+C to exit
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/pwm.h"
|
||||
|
||||
/* PWM declaration */
|
||||
#define PWM 3
|
||||
|
||||
/* PWM period in us */
|
||||
#define PWM_FREQ 200
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_pwm_context pwm;
|
||||
float value = 0.0f;
|
||||
float output;
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
pwm = mraa_pwm_init(PWM);
|
||||
if (pwm == NULL) {
|
||||
fprintf(stderr, "Failed to initialize PWM\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set PWM period */
|
||||
status = mraa_pwm_period_us(pwm, PWM_FREQ);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* enable PWM */
|
||||
status = mraa_pwm_enable(pwm, 1);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
while (flag) {
|
||||
value = value + 0.01f;
|
||||
|
||||
/* write PWM duty cyle */
|
||||
status = mraa_pwm_write(pwm, value);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
usleep(50000);
|
||||
|
||||
if (value >= 1.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
|
||||
/* read PWM duty cyle */
|
||||
output = mraa_pwm_read(pwm);
|
||||
fprintf(stdout, "PWM value is %f\n", output);
|
||||
}
|
||||
|
||||
/* close PWM */
|
||||
mraa_pwm_close(pwm);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* close PWM */
|
||||
mraa_pwm_close(pwm);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
154
examples/c/spi.c
Normal file
154
examples/c/spi.c
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Author: Michael Ring <mail@michael-ring.org>
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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.
|
||||
*
|
||||
* Example usage: Display set of patterns on MAX7219 repeately.
|
||||
* Press Ctrl+C to exit
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/spi.h"
|
||||
|
||||
/* SPI declaration */
|
||||
#define SPI_BUS 0
|
||||
|
||||
/* SPI frequency in Hz */
|
||||
#define SPI_FREQ 400000
|
||||
|
||||
uint16_t pat[] = { 0x01aa, 0x0255, 0x03aa, 0x0455, 0x05aa, 0x0655, 0x07aa, 0x0855 };
|
||||
uint16_t pat_inv[] = { 0x0155, 0x02aa, 0x0355, 0x04aa, 0x0555, 0x06aa, 0x0755, 0x08aa };
|
||||
uint16_t pat_clear[] = { 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700, 0x0800 };
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_spi_context spi;
|
||||
int i, j;
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize SPI bus */
|
||||
spi = mraa_spi_init(SPI_BUS);
|
||||
if (spi == NULL) {
|
||||
fprintf(stderr, "Failed to initialize SPI\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set SPI frequency */
|
||||
status = mraa_spi_frequency(spi, SPI_FREQ);
|
||||
if (status != MRAA_SUCCESS)
|
||||
goto err_exit;
|
||||
|
||||
/* set big endian mode */
|
||||
status = mraa_spi_lsbmode(spi, 0);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* MAX7219/21 chip needs the data in word size */
|
||||
status = mraa_spi_bit_per_word(spi, 16);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
fprintf(stdout, "Failed to set SPI Device to 16Bit mode\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* do not decode bits */
|
||||
mraa_spi_write_word(spi, 0x0900);
|
||||
|
||||
/* brightness of LEDs */
|
||||
mraa_spi_write_word(spi, 0x0a05);
|
||||
|
||||
/* show all scan lines */
|
||||
mraa_spi_write_word(spi, 0x0b07);
|
||||
|
||||
/* set display on */
|
||||
mraa_spi_write_word(spi, 0x0c01);
|
||||
|
||||
/* testmode off */
|
||||
mraa_spi_write_word(spi, 0x0f00);
|
||||
|
||||
while (flag) {
|
||||
/* set display pattern */
|
||||
mraa_spi_write_buf_word(spi, pat, 16);
|
||||
|
||||
sleep(2);
|
||||
|
||||
/* set inverted display pattern */
|
||||
mraa_spi_write_buf_word(spi, pat_inv, 16);
|
||||
|
||||
sleep(2);
|
||||
|
||||
/* clear the LED's */
|
||||
mraa_spi_write_buf_word(spi, pat_clear, 16);
|
||||
|
||||
/* cycle through all LED's */
|
||||
for (i = 1; i <= 8; i++) {
|
||||
for (j = 0; j < 8; j++) {
|
||||
mraa_spi_write_word(spi, (i << 8) + (1 << j));
|
||||
sleep(1);
|
||||
}
|
||||
mraa_spi_write_word(spi, i << 8);
|
||||
}
|
||||
}
|
||||
|
||||
/* stop spi */
|
||||
mraa_spi_stop(spi);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* stop spi */
|
||||
mraa_spi_stop(spi);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
93
examples/c/uart.c
Normal file
93
examples/c/uart.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2014, 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "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.
|
||||
*
|
||||
* Example usage: Prints "Hello Mraa!" recursively. Press Ctrl+C to exit
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/uart.h"
|
||||
|
||||
#define UART 0
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_uart_context uart;
|
||||
char buffer[] = "Hello Mraa!";
|
||||
|
||||
/* install signal handler */
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the times) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize UART */
|
||||
uart = mraa_uart_init(UART);
|
||||
if (uart == NULL) {
|
||||
fprintf(stderr, "Failed to initialize UART\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
while (flag) {
|
||||
/* send data through UART */
|
||||
mraa_uart_write(uart, buffer, sizeof(buffer));
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
/* stop UART */
|
||||
mraa_uart_stop(uart);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
115
examples/c/uart_advanced.c
Normal file
115
examples/c/uart_advanced.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
* Copyright (c) 2018, Linaro Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Example usage: Prints "Hello Mraa!" recursively. Press Ctrl+C to exit
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa/uart.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
/* UART port name */
|
||||
const char* dev_path = "/dev/ttyS0";
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if (signum == SIGINT) {
|
||||
fprintf(stdout, "Exiting...\n");
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t status = MRAA_SUCCESS;
|
||||
mraa_uart_context uart;
|
||||
char buffer[] = "Hello Mraa!";
|
||||
|
||||
int baudrate = 9600, stopbits = 1, databits = 8;
|
||||
mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE;
|
||||
unsigned int ctsrts = FALSE, xonxoff = FALSE;
|
||||
const char* name = NULL;
|
||||
|
||||
/* install signal handler */
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
/* initialize mraa for the platform (not needed most of the time) */
|
||||
mraa_init();
|
||||
|
||||
//! [Interesting]
|
||||
/* initialize uart */
|
||||
uart = mraa_uart_init_raw(dev_path);
|
||||
if (uart == NULL) {
|
||||
fprintf(stderr, "Failed to initialize UART\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* set serial port parameters */
|
||||
status =
|
||||
mraa_uart_settings(-1, &dev_path, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
while (flag) {
|
||||
/* send data through uart */
|
||||
mraa_uart_write(uart, buffer, sizeof(buffer));
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
/* stop uart */
|
||||
mraa_uart_stop(uart);
|
||||
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the time) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* stop uart */
|
||||
mraa_uart_stop(uart);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
@@ -20,73 +20,86 @@
|
||||
* 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.
|
||||
*
|
||||
* Example usage: Search and print the found OW device ID recursively.
|
||||
*
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include "stdio.h"
|
||||
//! [Interesting]
|
||||
|
||||
/* mraa header */
|
||||
#include "mraa.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
main(void)
|
||||
{
|
||||
mraa_uart_ow_context uart;
|
||||
uart = mraa_uart_ow_init(0);
|
||||
mraa_uart_ow_context uart_ow;
|
||||
mraa_result_t status;
|
||||
uint8_t id[MRAA_UART_OW_ROMCODE_SIZE];
|
||||
uint8_t count = 0;
|
||||
|
||||
if (!uart) {
|
||||
printf("mraa_uart_ow_init() failed\n");
|
||||
return 1;
|
||||
//! [Interesting]
|
||||
uart_ow = mraa_uart_ow_init(0);
|
||||
if (uart_ow == NULL) {
|
||||
fprintf(stderr, "Failed to initialize UART OW\n");
|
||||
mraa_deinit();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Reset the ow bus and see if anything is present
|
||||
mraa_result_t rv;
|
||||
|
||||
if ((rv = mraa_uart_ow_reset(uart)) == MRAA_SUCCESS) {
|
||||
printf("Reset succeeded, device(s) detected!\n");
|
||||
status = mraa_uart_ow_reset(uart_ow);
|
||||
if (status == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "Reset succeeded, device(s) detected!\n");
|
||||
} else {
|
||||
printf("Reset failed, returned %d. No devices on bus?\n", rv);
|
||||
return 1;
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
printf("Looking for devices...\n");
|
||||
uint8_t id[MRAA_UART_OW_ROMCODE_SIZE];
|
||||
fprintf(stdout, "Looking for devices...\n");
|
||||
|
||||
/* we are essentially doing a binary tree search through the 64
|
||||
/*
|
||||
* we are essentially doing a binary tree search through the 64
|
||||
* bit address space. id is modified during this search, and will
|
||||
* be set to the valid rom code for each device found.
|
||||
*
|
||||
* start the search from scratch
|
||||
*/
|
||||
|
||||
uint8_t count = 0;
|
||||
|
||||
// start the search from scratch
|
||||
mraa_result_t result = mraa_uart_ow_rom_search(uart, 1, id);
|
||||
if (result == MRAA_ERROR_UART_OW_NO_DEVICES) {
|
||||
printf("No devices detected.\n");
|
||||
return 1;
|
||||
status = mraa_uart_ow_rom_search(uart_ow, 1, id);
|
||||
if (status != MRAA_SUCCESS) {
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
if (result == MRAA_ERROR_UART_OW_DATA_ERROR) {
|
||||
printf("Bus/Data error.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (result == MRAA_SUCCESS) {
|
||||
while (status == MRAA_SUCCESS) {
|
||||
/* The first byte (id[0]]) is the device type (family) code.
|
||||
* The last byte (id[7]) is the rom code CRC value. The
|
||||
* intervening bytes (id[1]-id[6]) are the unique 48 bit
|
||||
* device ID.
|
||||
*/
|
||||
printf("Device %02d Type 0x%02x ID %02x%02x%02x%02x%02x%02x CRC 0x%02x\n", count, id[0],
|
||||
id[6], id[5], id[4], id[3], id[2], id[1], id[7]);
|
||||
fprintf(stdout, "Device %02d Type 0x%02x ID %02x%02x%02x%02x%02x%02x CRC 0x%02x\n", count,
|
||||
id[0], id[6], id[5], id[4], id[3], id[2], id[1], id[7]);
|
||||
count++;
|
||||
|
||||
// continue the search with start argument set to 0
|
||||
result = mraa_uart_ow_rom_search(uart, 0, id);
|
||||
status = mraa_uart_ow_rom_search(uart_ow, 0, id);
|
||||
}
|
||||
|
||||
printf("Exiting...\n");
|
||||
/* stop uart_ow */
|
||||
mraa_uart_ow_stop(uart_ow);
|
||||
|
||||
mraa_uart_ow_stop(uart);
|
||||
//! [Interesting]
|
||||
/* deinitialize mraa for the platform (not needed most of the time) */
|
||||
mraa_deinit();
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
err_exit:
|
||||
mraa_result_print(status);
|
||||
|
||||
/* stop uart_ow */
|
||||
mraa_uart_ow_stop(uart_ow);
|
||||
|
||||
/* deinitialize mraa for the platform (not needed most of the times) */
|
||||
mraa_deinit();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//! [Interesting]
|
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "mraa/iio.h"
|
||||
|
||||
static void
|
||||
printword(uint16_t input, mraa_iio_channel* chan)
|
||||
{
|
||||
int16_t res;
|
||||
|
||||
if (!chan->lendian) {
|
||||
input = be16toh(input);
|
||||
} else {
|
||||
input = le16toh(input);
|
||||
}
|
||||
|
||||
input >>= chan->shift;
|
||||
input &= chan->mask;
|
||||
if (chan->signedd) {
|
||||
res = (int16_t)(input << (16 - chan->bits_used)) >> (16 - chan->bits_used);
|
||||
} else {
|
||||
res = input;
|
||||
}
|
||||
printf(" value = %05f\n", (float) res);
|
||||
}
|
||||
|
||||
mraa_iio_context iio_device0;
|
||||
mraa_iio_context iio_device6;
|
||||
|
||||
void
|
||||
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++) {
|
||||
if (channels[i].enabled) {
|
||||
printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
|
||||
switch (channels[i].bytes) {
|
||||
case 2:
|
||||
printword(*(uint16_t*) (data + channels[i].location), &channels[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
event_interrupt(struct iio_event_data* data)
|
||||
{
|
||||
int chan_type;
|
||||
int modifier;
|
||||
int type;
|
||||
int direction;
|
||||
int channel;
|
||||
int channel2;
|
||||
int different;
|
||||
mraa_iio_event_extract_event(data, &chan_type, &modifier, &type, &direction, &channel, &channel2, &different);
|
||||
|
||||
printf("event time %lld id %lld extracted chan_type %d modifier %d type %d direction %d "
|
||||
"channel %d channel2 %d different %d\n",
|
||||
data->timestamp, data->id, chan_type, modifier, type, direction, channel, channel2, different);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
//! [Interesting]
|
||||
iio_device0 = mraa_iio_init(0);
|
||||
if (iio_device0 == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
float iio_float;
|
||||
int iio_int;
|
||||
mraa_result_t ret;
|
||||
|
||||
ret = mraa_iio_write_float(iio_device0, "in_accel_scale", 0.019163);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO write success\n");
|
||||
}
|
||||
|
||||
ret = mraa_iio_read_float(iio_device0, "in_accel_scale", &iio_float);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO read %f\n", iio_float);
|
||||
}
|
||||
|
||||
ret = mraa_iio_write_int(iio_device0, "scan_elements/in_accel_x_en", 1);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO write success\n");
|
||||
}
|
||||
|
||||
ret = mraa_iio_read_int(iio_device0, "scan_elements/in_accel_x_en", &iio_int);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO read %d\n", iio_int);
|
||||
}
|
||||
|
||||
if (mraa_iio_trigger_buffer(iio_device0, interrupt, NULL) == MRAA_SUCCESS) {
|
||||
sleep(100);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
struct iio_event_data event;
|
||||
iio_device6 = mraa_iio_init(6);
|
||||
if (iio_device6 == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mraa_iio_write_int(iio_device6, "events/in_proximity2_thresh_either_en", 1);
|
||||
|
||||
|
||||
// Blocking until event fired
|
||||
if (mraa_iio_event_poll(iio_device6, &event) == MRAA_SUCCESS) {
|
||||
event_interrupt(&event); //just to show data
|
||||
}
|
||||
|
||||
if (mraa_iio_event_setup_callback(iio_device6, event_interrupt, NULL) == MRAA_SUCCESS) {
|
||||
sleep(100);
|
||||
return EXIT_SUCCESS;
|
||||
}*/
|
||||
|
||||
//! [Interesting]
|
||||
return EXIT_FAILURE;
|
||||
}
|
@@ -44,11 +44,12 @@ public class AioA0 {
|
||||
public static void main(String[] args) {
|
||||
Aio a0 = new Aio(0);
|
||||
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
int adc_value = a0.read();
|
||||
float adc_value_float = a0.readFloat();
|
||||
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
|
||||
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ public class BlinkIO {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
gpio.write(1);
|
||||
Thread.sleep(1000);
|
||||
gpio.write(0);
|
||||
|
@@ -64,7 +64,7 @@ public class BlinkOnboard {
|
||||
}
|
||||
|
||||
boolean state = false;
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
if (gpio_in != null && gpio_in.read() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ public class CyclePwm3 {
|
||||
pwm.enable(true);
|
||||
|
||||
float value = 0;
|
||||
while (true) {
|
||||
for (int i = 100; i > 0; --i) {
|
||||
value += 0.01;
|
||||
pwm.write(value);
|
||||
Thread.sleep(50);
|
||||
|
@@ -50,8 +50,8 @@ public class FTDITest {
|
||||
/* Blink FTDI board LED */
|
||||
Gpio led = new Gpio(514);
|
||||
led.dir(Dir.DIR_OUT);
|
||||
for (int i = 0;; i = (i + 1) % 2) {
|
||||
led.write(i);
|
||||
for (int i = 100; i > 0; --i) {
|
||||
led.write(i % 2);
|
||||
Thread.sleep(500);
|
||||
}
|
||||
} else {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user