Compare commits

...

459 Commits

Author SHA1 Message Date
e79ddf0c7a include/version.h aktualisiert 2024-01-11 20:31:36 +01:00
5439d73032 CMakeLists.txt aktualisiert 2024-01-11 20:31:06 +01:00
nascs
d59936ffd4 Add ROCK 4 Java support (#16) 2023-03-24 14:50:47 +08:00
Alvin
f854463c34 add ROCK 3C support
Signed-off-by: Alvin <alvin@radxa.com>
2022-10-22 11:30:34 +08:00
Zhang Xinyu
45c4aa7cee add ROCK 4C+ support
Signed-off-by: Zhang Xinyu <zhangxinyu@radxa.com>
2022-10-21 15:54:23 +08:00
nascs
fc8c9061a6 Add support for Radxa CM3 IO base board (#14) 2022-09-28 16:33:05 +08:00
alvin
b34cd50d31 modify: add model name: Radxa ROCK 3 Model A/B
Signed-off-by: Alvin <alvin@radxa.com.com>
2022-09-16 18:59:48 +08:00
alvin
700eece628 modify: model name: Radxa ROCK3 Model A/B
Signed-off-by: Alvin <alvin@radxa.com.com>
2022-08-30 17:48:47 +08:00
steph
9ea5a29b6f Merge pull request #10 from ken-vms/master
Add support for rock3a.

Fix the issue of mismatch of spi device on ROCK Pi 4.
2022-01-14 15:10:18 +08:00
Ken
40791fa309 fix the issue of mismatch of spi device on ROCK Pi 4
With mainline linux , SPI 1 device on ROCK Pi 4 is /dev/spi1.0.
And SPI 2 device is /dev/spi2.0.

Signed-off-by: Ken <ken@radxa.com.com>
2022-01-14 15:04:38 +08:00
Ken
ad0cb85903 add support for rock3a
Signed-off-by: Ken <ken@radxa.com.com>
2021-12-09 15:00:07 +08:00
steph
10adedc0e6 Merge pull request #9 from ken-vms/master
add support for radxa zero
2021-10-27 20:31:45 +08:00
Ken
9aa7ac1f65 add support for radxa zero
Signed-off-by: Ken <ken@radxa.com>
2021-10-27 20:29:45 +08:00
steph
03d305998b Merge pull request #6 from wzj2346584/master
rock-pi-s :add support for v1.3
2021-08-16 11:23:37 +08:00
wzj
dbf1b29382 rock-pi-s :add support for v1.3
Signed-off-by: wzj <wzj2346584@163.com>
2021-08-10 15:06:11 +08:00
steph
7eca0c738d Merge pull request #4 from wzj2346584/master
rockpix: correct pin12 gpio number
2021-06-18 20:31:30 +08:00
wzj
9c6df90550 rockpix: correct pin12 gpio number
Signed-off-by: wzj <wzj2346584@163.com>
2021-06-18 20:12:53 +08:00
Shine
06b2be27c7 Add support for ROCK Pi X
Signed-off-by: Shine <yll@radxa.com>
2020-12-08 10:30:43 +08:00
Shine
587866260b Add support for java examples programs compilation
Signed-off-by: Shine <yll@radxa.com>
2020-12-08 10:28:47 +08:00
akgnah
12d13ab9e6 rockpi4: add model c support
Signed-off-by: akgnah <1024@setq.me>
2020-12-08 10:26:09 +08:00
Shine
f9673ea531 Add support for ROCK Pi E
Signed-off-by: Shine <yll@radxa.com>
2020-12-08 09:53:16 +08:00
zzl
803b486f42 Add support for ROCK Pi N10
Signed-off-by: zzl <zzl@radxa.com>
2020-10-12 10:37:05 +08:00
zzl
a99dce5140 Add support for ROCK Pi S
Signed-off-by: zzl <zzl@radxa.com>
2020-09-12 11:18:13 +08:00
Mihai Tudor Panu
f9da60fda1 sonar-scan: disable preview mode for internal PR
No longer supported by sonar scans, the preview feature is now disabled and internal PRs from project contributors are also scanned for vulnerabilities/bugs as part of CI

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-05-29 13:47:59 -07:00
Propanu
85d6279228 readme.md: update instructions for openSUSE
Describes in more detail how to install MRAA for developers on openSUSE and SLE.
2020-05-29 13:47:59 -07:00
Mihai Tudor Panu
e52c5bb7c3 readme.md: fix typo and mention packages may be compatible
For testing purposes it should be possible to share .deb packages across a variety of Debian builds or .rpm packages across systems that have dnf/yum available

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-05-07 14:10:17 -07:00
Mihai Tudor Panu
e70198f659 readme.md: replace node section with RHEL/CentOS
Removed installing for node.js section as latest versions of node have issues building until Swig is patched. Also make it clear some mainstream Linux don't have binaries available in official repos.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-05-07 13:36:32 -07:00
Chuckduey
c10e72b494 Added V1.2 for Pi 4 2GB and 4GB
Signed-off-by: Chuckduey <cduey@msn.com>
2020-05-07 13:36:03 -07:00
Mihai Tudor Panu
e15ce6fbc7 mraa: Update to v2.1.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-01-16 11:45:05 -08:00
Chuck Duey
f58cdc9da4 Added Raspberry Pi 4 1GB 2GB and 4GB to the list of detected platforms
Signed-off-by: Chuck Duey <cduey@msn.com>
2020-01-10 09:33:19 -08:00
kathaashok
bb736e762b fixing indentation issues reported by eclipse mraa
Signed-off-by: kathaashok <katha.ashok@adlinktech.com>
2020-01-10 07:33:18 -08:00
ryanzj.huang@adlinktech.com
276868185d modify the content of adlink_ipi_arm.md
Signed-off-by: ryanzj.huang@adlinktech.com <ryanzj.huang@adlinktech.com>
2020-01-10 07:33:18 -08:00
katha ashok
ef8c0fb541 Fixing minor issues. supporting LEC-AL-AI board
Signed-off-by: katha ashok <katha.ashok@adlinktech.com>
2020-01-10 07:33:18 -08:00
ryanzj.huang@adlinktech.com
eb9b55bd99 modify pin 26 function to n/a
Signed-off-by: ryanzj.huang@adlinktech.com <ryanzj.huang@adlinktech.com>
2020-01-10 07:33:18 -08:00
Brian Lee
63de2c4c3a rockpi4.c: fixed pwm issue
e.g.:
    cv2 import at the beginning throws the error:
    import cv2
    import mraa
    import time
    ...

    Error:
    ValueError: Error initialising PWM on pin

Signed-off-by: Brian Lee <brian@vamrs.com>
2020-01-09 10:11:58 -08:00
Michael Campion
1d18da9a22 upxtreme: add spdx tags to source files
Remove MIT notice and replace with SPDX tags in UP Xtreme sources.

Signed-off-by: Michael Campion <michael.campion@emutex.com>
2020-01-06 15:17:55 +00:00
Michael Campion
3d781603f3 upxtreme: Match UP Xtreme Platform enum value
After rebase UP Xtreme supported platform enum value was changed
to 24 in types.h, this commit updates the enum value in types.hpp
to this value.

Signed-off-by: Michael Campion <michael.campion@emutex.com>
2020-01-06 15:17:55 +00:00
Michael Campion
d954599045 upxtreme: Add UP Xtreme support
UP Xtreme is based on the Intel(R) Core(TM) i3/i5/i7 Whiskey Lake SoCs.
The UP Xtreme presents one Raspberry Pi compatible HAT connector.

This implementaion supports i2c, spi, uart, adc and gpio through the
40pin HAT connector.

Gpio chardev capabilities have been disabled in this implementation. When
gpio chardev capabilities are enabled an input becomes unreadable after an
isr has been registered to the pin. See here for details:

https://github.com/intel-iot-devkit/mraa/issues/937

Tested on UP Xtreme, with UP Board Linux kernel 5.0.0
Features tested: gpio, gpio interrupts, i2c, spi, adc and uart.

Signed-off-by: Michael Campion <michael.campion@emutex.com>
2020-01-06 15:17:55 +00:00
Carsten Menke
79043568dd made Rock Pi 4 working again with recent 5.x kernels
Signed-off-by: Carsten Menke <cm@p-i-u.de>
2019-12-29 20:14:42 +00:00
Carsten Menke
5b8ec38440 added readme for Rock Pi
Signed-off-by: Carsten Menke <cm@p-i-u.de>
2019-12-29 20:14:42 +00:00
gowtham.r
4ba5da1144 adding Adlink IPi SMARC x86/ARM support
Signed-off-by: gowtham.r <gowtham.r@adlinktech.com>
2019-12-03 07:52:58 -08:00
Benxi Liu
3b2f80b6e2 uart: fix xonxoff value in mraa_uart_settings()
the value of xonxoff(IXON|IXOFF) resides in the c_iflag field in
struct termios, not c_cflag.

Signed-off-by: Benxi Liu <bxliu@linux.alibaba.com>
2019-12-03 07:52:58 -08:00
Thomas Ingleby
c1eeb8ab87 eclipse: change Java namespace
io.mraa -> org.eclipse.mraa

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-11-13 13:14:20 -08:00
Thomas Ingleby
170bdd104f spdx: add spdx tags to most files
Large change that removes the duplicated MIT notice withe a spdx tag

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-05-23 10:09:12 -07:00
Thomas Ingleby
6d2ca4b97a CMake: add spdx tags to modules
Helps to be explict what license each module is under

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-05-23 10:09:12 -07:00
Thomas Ingleby
c4d8dd2524 mraa; rename to Eclipse Mraa
* Updated CONTRIBUTING.md to refer to the ECA

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-05-23 10:09:12 -07:00
Manivannan Sadhasivam
0a12c5a017 gpio: Introduce mraa_gpio_init_by_name API
This commit introduces mraa_gpio_init_by_name API for initializing
a GPIO by its line name provided by the kernel. This feature depends
on the GPIO chardev support and also the line names present in devicetree
or board files. Accessing GPIO using its line name, removes the dependency
from MRAA specific pin mapping and provides a cleaner way to access GPIOs.
This will solve the issue created by an external gpiochip probing before
the SoC's internal gpio controller and thereby making the MRAA pin mapping
wrong.

Currently, this API only supports initializing a single GPIO at a time.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2019-05-10 16:29:13 +05:30
Manivannan Sadhasivam
111e6be8f7 96boards: Add chardev support to Rock960
Add chardev support to Rock960 96Boards.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2019-05-10 16:24:41 +05:30
Thomas Ingleby
ffa3dcdfc0 oe-sdk_cross: remove in favour of devtool
Added a note to explain where it's gone and the preserve some Java
specifics

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-05-08 11:14:07 -07:00
Thomas Ingleby
47643bffdd TargetArch: remove cmake module
Favour CMAKE_SYSTEM_PROCESSOR for detecting target arch

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-05-08 11:14:07 -07:00
Mihai Tudor Panu
cad3a03d0d readme: update project status to reflect Eclipse transition
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-05-07 16:48:45 -07:00
Thomas Ingleby
8d65c2c72b jsstub: add MIT header to source
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-03-28 13:16:06 -07:00
Brian Lee
b8349c0ffe rockpi4: Add rockpi4 support
Closes #958

Signed-off-by: Brian Lee <brian@vamrs.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-03-28 13:09:46 -07:00
Mihai Tudor Panu
8942117b2e x86.c: add missing platform init call when MRAAPLATFORMFORCE is set to IEI Tank
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-26 22:17:25 -07:00
Mihai Tudor Panu
7f8d3876e3 clang-format: reapply to recently modified sources
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 13:14:09 -08:00
Cosmin Popescu
41fc378099 initio.c: Fix for null pointer passed as parameter
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:13:01 -08:00
Cosmin Popescu
c821c19899 mraa:c Fix dereference of null pointer
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:12:52 -08:00
Cosmin Popescu
89473e5ba4 gpio.c: Add fix for closing of uninitialzed fds
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:12:43 -08:00
Cosmin Popescu
d60bab2082 gpio:c fix for gpio_group memory leak
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:12:34 -08:00
Cosmin Popescu
18b4ac5663 mraa.c: Fix memory leak
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:12:25 -08:00
Adelin Dobre
4ec830fcc6 jsonplatform.c: Add fix for passing null as parameter
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:12:17 -08:00
Adelin Dobre
6e85bcd902 jsonplatform.c: Add fix for dereferencing of a null pointer
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:12:08 -08:00
Adelin Dobre
5d6f0ef296 examples/c++/uart.cpp: Add fix for potential memory leak
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:11:59 -08:00
Adelin Dobre
1278089e84 initio.c: Add fix for potential leak memory
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:11:50 -08:00
Adelin Dobre
ba201fcad2 initio.c: Add fix for passing null as parameter
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:11:42 -08:00
Adelin Dobre
8ded6f1f6d initio.c: Add fix for passing null pointer as argument
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:11:33 -08:00
Cosmin Popescu
88a8bb22b6 mraa.c: Add fix for dereferencing of a null pointer
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:11:21 -08:00
Cosmin Popescu
9fe2883e6a gpio.c: Add fix for dereferencing of a null pointer
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:11:10 -08:00
Cosmin Popescu
5169021afd mraa.c: Add fix for potential memory leak
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:10:59 -08:00
Cosmin Popescu
6252d25729 x86/intel_galileo_rev_g.c: Removed switch break after return
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:10:48 -08:00
Cosmin Popescu
b75731d9d3 iio/iio.c: Fix typo
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:10:35 -08:00
Cosmin Popescu
9cb508f5d2 iio/iio.c: Add fix for access of variable before error check
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:10:06 -08:00
Cosmin Popescu
2bb200aa04 iio/iio.c: Add fix for division by 0 bug
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2019-03-06 12:09:51 -08:00
Sai Hari Chandana Kalluri
b425c99030 [PATCH] Ultra96: Add support for ultra96
Add support for Ultra96 board: Ultra96 is an Arm-based, Xilinx Zynq
UltraScale+ MPSoC development board based on the Linaro 96Boards
Consumer Edition specification.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Peter Ryser <peter.ryser@xilinx.com>
Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
Signed-off-by: Sai Hari Chandana Kalluri <chandana.kalluri@xilinx.com>
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2019-02-23 20:46:49 +01:00
Burak Han
08b2cefebe DE10-Nano: Detection For Different Kernels
To detect DE10-Nano with default config.

Signed-off-by: Burak Han Corak<burakhancorak@gmail.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-02-21 10:10:35 -08:00
Adelin Dobre
d0c884e67d initio.c: Fix parse issue inside mraa_io_init
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-02-21 09:53:54 -08:00
Adelin Dobre
678e540291 initio: Add safety checks inside MraaIo destructor
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-02-21 09:53:54 -08:00
Chuck Duey
eae4a0cfbf BeagleBone Fix detection of emmc and PCM for mraa pins 74-77
This fixes the problem of detecting if pins 74-77 are available for gpio/spi use.  These pins were sown to be used by the emmc, but actually used by the sound pcm.  If the sound PCM is disabled and the emmc is enabled the pinse can now be used.  mraa-gpio list output Pins 74-77
73     GPIO115: GPIO
74     GPIO113: GPIO SPI
75     GPIO111: GPIO SPI
76     GPIO112: GPIO SPI
77     GPIO110: GPIO SPI

to build:
1. clone repo
2. sudo apt-get install build-essential python-dev cmake automake libpcre3 libpcre3-dev byacc flex swig3.0
3. cd mraa, mkdir build, cd build
4. cmake -D CMAKE_INSTALL_PREFIX=/usr ..
5. make
6. sudo make install

This has been verified to work on BBGW, and BBBW with 9.0-9.5 with emmc enabled and PCM aduio turned off.  It is so nice to have control of these pins when running with out an SD card.

Closes #953

Signed-off-by: Chuck Duey <cduey@msn.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-02-21 09:50:11 -08:00
Brett Haines
7a1db249fe rpi: Added Raspberry Pi 3 A+ definitions
Signed-off-by: Brett Haines <bhaines418@gmail.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2018-11-29 09:53:11 -08:00
Chuck Duey
d3207769e7 rpi: Added Raspberry Pi 3 B+ to Hardware Versions with corrections
Signed-off-by: Chuck Duey <cduey@msn.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-10-09 09:58:36 -07:00
Peter Robinson
66c2478183 Add instructions for Fedora
mraa is packaged in Fedora so add details for how people can consume mraa on that
distribution.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2018-09-20 10:13:05 +02:00
Thomas Ingleby
156fea550c up2: update docs to point to new wiki link
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2018-09-20 10:06:50 +02:00
Thomas Ingleby
3e7a468a8a README: update PPA instructions for mraa2
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2018-09-11 14:00:20 +02:00
Mihai Tudor Panu
967585c9ea mraa: Update to v2.0.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-09-06 05:34:41 -07:00
Manivannan Sadhasivam
b07633c38a 96boards: Add onboard LED support for Dragonboard410c
Add onboard LED support for Dragonboard410c. There are 4 user LEDs and
two LEDs for BT and WLAN.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-09-05 09:05:26 +05:30
Manivannan Sadhasivam
806c17f664 examples: c: led: Initialize LED based on index
Since the LEDs are initialized based on index, modify the USER_LED
to index 0.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-09-05 09:05:26 +05:30
Manivannan Sadhasivam
6fcd882d58 led: Add support for initializing onboard LEDs based on board definition
1. Add support for initializing onboard LEDs based on board definition.
Maximum LED count has been set to 12.

2. Introduce mraa_led_init_raw API for initializing LEDs based on
function name. This API can be used by platforms which doesn't have mapping
in board definition.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-09-05 09:05:26 +05:30
Manivannan Sadhasivam
6c0ec10ba1 96boards: Configure SPI0_CS pin as GPIO for Dragonboard410c
On Dragonboard410c, configure SPI0_CS pin as GPIO for enabling the
user to control it without adding chip select property in Devicetree.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-08-30 22:23:15 +05:30
Manivannan Sadhasivam
77d4676616 mraa: fix mraa_gpio_lookup function
1. Extend the lookup count to phy_pin_count to cover all physical pins
   exposed on the board
2. Ignore the non GPIO pins by checking for GPIO capability

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-08-15 08:53:04 +05:30
Noel Eck
d24457f9a1 ioinit: Update to build/test C++ ioinit
Multiple changes necessary to enable this.  The main goal is to build
and run the C++ ioinit unit tests (which require c++11)

    * Updated mraa required CMake version to 2.8.11 (this is needed for
      the target_xxx_xxx CMake syntax.
    * Added function for adding the c++11 flag give a CMake target.
    * Updated unit tests for range of CMake versions (tested on 2.8.11,
      3.8.2, 3.9.6, and 3.12.0).
    * Added C++ unit test file (more needed here).)

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-29 21:26:50 -07:00
Manivannan Sadhasivam
9056556b7a 96boards: Add Ultra-96 board support
This commit adds Ultra96, one of the Consumer Edition boards of the
96Boards family.

Ultra96 is an Arm-based, Xilinx Zynq UltraScale+ MPSoC development board.
This board runs petalinux distribution on the ARM core and integrates
Xilinx programmable logic (PL) UltraScale architecture in a single fabric.

This board supports standard peripherals defined by 96Boards CE
Specification. Since it ships with >4.8 kernel, only chardev mapping
is supported for accessing GPIO.

More information about this board can be found in 96Boards product
page: https://www.96boards.org/product/ultra96/

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-07-29 23:13:30 +05:30
Manivannan Sadhasivam
71b87904a0 96boards: Cleanup the board support
This commit cleans up the 96boards board support by sorting the boards
in alphabetical manner and also executing clang-format for 96boards.c

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-07-29 23:13:30 +05:30
Noel Eck
9a44283a93 initio.c: Clean up memory from a failed init
Delete allocated space if the string init fails.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-23 22:00:27 -07:00
Noel Eck
b3c1c5ac3c initio.c: Re-applied clang-format for source
Ran clang-format to conform to mraa's coding guide.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-23 21:51:58 -07:00
Noel Eck
e772aec69d initio: Handle no-conversion case in mraa_atoi_x
If strtol fails to process any characters, return a failure.

Added protocol chunk string to each parse_xxx method for completeness
when printing to syslog.

Added more tests - passing and failing cases.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-23 21:40:45 -07:00
Noel Eck
6fe510a27f Peripheralman: Remove IIO from ioinit for android
Since peripheral manager does not build in the IIO source, ifdef's were
added around the initio functionality for IIO.

IMO this is an ugly fix, but I don't see a better way since the
PERIPHERALMAN architecture is qualified throughout the CMake and source
with ifdef's.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-23 21:40:45 -07:00
Noel Eck
4487c98b6f gtest: Organized Gtest unit tests
This commit limits which tests run on which ARCH to allow all tests to
pass on CI.

    * Qualify the FTDI tests with (FTDI4222 AND USBPLAT)
    * Qualify the IO init tests with (DETECTED_ARCH == "MOCK")
    * Renamed all unit tests to start with 'test_unit_' to facilitate
      grouping with tab completion (or any other type of sorting)
    * Updated docker targets with new unit test target name

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-23 21:40:45 -07:00
Mihai Stefanescu
ae391fe9fe String based IO initialization for MRAA
Signed-off-by: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-23 21:40:12 -07:00
netlhx
4b2279704b boards: add rock960 support
Signed-off-by: Hongxin Liu <761896148@qq.com>
2018-07-23 16:33:44 +05:30
Noel Eck
b90c0efcb8 gtest: Added headers to unit tests
Added missing headers for the common and platform extender unit test
source files.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-17 09:48:45 -07:00
Noel Eck
c563e4fb4d gpio.c: Handle subplatform interrupts
For all subplaform pins, save the subplatform index as dev->pin and the
actual platform index as dev->phy_pin.

Example:
    pin 515 (subplatform pin 3)
    dev->pin = 515
    dev->phy_pin = 515 - 512 = 3

In this way, methods which get a mraa_gpio_context have a means
to tell whether the pin is on a subplatform or not.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-07-01 20:51:02 -07:00
Noel Eck
fc4b2a554d Platform_extender: FT4222 library refactor
Updates to make the FT4222 platform extender more usable.

Previous implementation opened libft4222.so and loaded symbols as
needed.  This implementation removes dynamic loading of libft4222 in
favor of creating a new shared libary which links against libft4222.so.
The dynamic loading is now done in mraa.c.  One C method is exposed in
libmraa-platform-ft4222.so for finding/initializing an FT4222:

mraa_platform_t mraa_usb_platform_extender(mraa_board_t* board);

Mraa.c attempts to open this platform library and calls the
mraa_usb_platform_extender method.  If an ftdi4222 is connected, the
user gets added IO from the extender.  If no FT4222 device is connected,
continue as normal.

    * Create a new platform library for the FT4222
    * Expose only 1 C method from the library -
      mraa_usb_platform_extender
    * libmraa-platform-ft4222.so contains CXX code (as well as previous
      C code).  All *allocs have been removed in favor of global
      C++ stl containers.
    * Previously, the FT4222 would only initialize correctly if 2 ftdi
      devices existed.  Now, initialize FT4222 devices based on the
      device id.
    * Many fixes for various problems with the FT4222
    * Added unit test for platform extender (minimal functionality w/o hw)
    * Updated to FindFtd4222.cmake module to handle standard arguments
    * Removed CMAKE_C_FLAGS addition of -DFTDID2XX and -DFTDI4222 since
      these are NOT used anywhere in source.
    * Building the FTDI4222 shim requires libft4222.h which requires
      ftd2xx.h.  Updated CMakeLists.txt to require both when building
      the shim.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-06-26 12:57:13 -07:00
Mihai Tudor Panu
47728b4c1d gpio: adjust adv function hooks to fix subplatforms
The chardev feature changed the flow for most GPIO functions but did not take into account existing function hooks correctly.
This fixes the checks and restores subplatform GPIO access.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-06-25 09:48:12 -07:00
Noel Eck
a2f01bee5f mraa.c: Added pointer to pointer back to find_uart
Went a bit too far with the previous commit.  Added pointer to pointer
back to mraa_find_uart_bus_pci.

Tested leaks against valgrind and verified dev_path gets set with gdb.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-06-14 21:21:37 -07:00
Noel Eck
17342cbbbb mraa.c: Fixed memleak of device_path for IEI_TANK
Unfortunately the device_path char* is dynamically allocated
and #defined and const char *'ed depending on how each platform provided the
uart device paths which makes cleaning it up more complicated.

Added a check for the IEI_TANK.

Removed the char** (in favor of a char*) for mraa_find_uart_bus_pci.)

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-06-14 15:18:29 -07:00
Mihai Tudor Panu
4c4845b101 types.hpp: add missing mediatek boards to platform enum
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-06-11 22:52:37 -07:00
Mihai Tudor Panu
b06172b05a aiotdevkit: add readme and link to it
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-06-11 22:47:39 -07:00
Mihai Tudor Panu
8a22f18152 aiotdevkit: fix pinmap and add uart names
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-06-06 16:28:29 -07:00
Mihai Tudor Panu
9c5f940dad aiotdevkit: add support for IEI Tank platforms
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-05-31 21:21:53 -07:00
Noel Eck
7d58d4c6d0 ftdi_4222: Memleak fixes
Fixes for assortment of memory leaks.  Updated i2c_read/write_internal
methods to get the controller status ONLY when a read/write fails.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-05-30 13:53:45 -07:00
Noel Eck
0712b9ea63 ftdi_4222: Cleanup warning messages from compile
* Fixed broken switch statement - missing 'case' in front of labels
    * Added default case to switch statement
    * Removed unused variable
    * Removed unused static functions
    * Attempted to fix cases where functions are returning/not returning
      data incorrectly.
    * Attempted to fix i2c read which was returning an
    * uninitialized/unused variable.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-05-30 11:30:49 -07:00
Noel Eck
ed79502efc ftdi_4222: Fix mode check in FTDI4222
If numDevs is not == 2, the previous code would fail.  If numDevs > 2
(example 1 ft2xx device connected and 1 ft4222 device in mode 3) then
the code would not initialize the FT4222 and give an error that the mode
must be 0 or 3.

Updated source to find the first index of a ft4222 device.  Initialize
it as I2C.  If another device of the same id exists, then initialize it
as GPIO.

Added more syslog messages for debugging.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-05-30 11:02:04 -07:00
Manivannan Sadhasivam
46b3a3ef88 arm: 96boards: Move pin capabilities property inside is_gpio condition
Declare the GPIO pins capabilities under is_gpio condition instead of
under sysfs_pin.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-05-03 14:17:55 -04:00
Manivannan Sadhasivam
3fa1237255 arm: 96boards: Add support for Hikey960
Add support for Hikey960 board from HiSilicon based on their Kirin960 SoC.

Peripherals supported:

1. GPIO
2. UART
3. I2C

For GPIO only Chardev interface has been added since this board only supports
>=4.15 kernel and using legacy sysfs interface is highly discouraged.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-05-03 14:17:38 -04:00
Manivannan Sadhasivam
5faa2b93ca 96boards: db820c: Fix chardev mapping
Fix chardev mapping for GPIO-C and GPIO-F.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-05-02 17:09:13 -04:00
Manivannan Sadhasivam
b04e728957 gpio: chardev: fix leaking of gpiochip file descriptors
The following APIs are only used for getting the line information from
kernel by opening the gpiochip independently and they fails to close
the file descriptor when done:

1. mraa_get_line_info_by_chip_number()
2. mraa_get_line_info_by_chip_name()
3. mraa_get_line_info_by_chip_label()

This will create issue if these API consumers like mraa_gpio_read_dir(),
mraa_gpio_mode(), mraa_gpio_chardev_dir() gets called in a loop. The
system will run out of file descriptor after some time.

Fix this issue by closing the opened file descriptors before freeing
the cinfo struct.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-05-02 11:38:12 -04:00
Mihai Tudor Panu
b59fc8f076 docs: updated readme and build instructions for node.js and ubuntu
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-19 13:35:06 -04:00
Mihai Tudor Panu
bdd00e10ed minnowboard: add chardev support
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-19 13:35:06 -04:00
Brendan Le Foll
72f1ffca31 cmake: force c99 to be set in the compiler
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-19 12:00:02 -04:00
Manivannan Sadhasivam
6258bd5fdd 96boards: chardev: Move chardev enablement inside platform check
Move the chardev enablement inside the platform check.
Some boards might not have the chardev mapping yet.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-19 11:42:24 -04:00
IvanFarkas
284d882b9d Added Qualcomm DragonBoard 820c support.
GPIO ports from DragonBoard 820c Hardware Manual (p16) at
https://github.com/sdrobertw/dragonboard820c/blob/master/hardware-docs/files/db820c-user-guide.docx

Add Chardev support for DragonBoard 820c

Signed-off-by: Ivan Farkas <Ivan.Farkas@TeleCuris.com>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-10 16:49:38 -04:00
Manivannan Sadhasivam
7ea32cf1ec arm: 96boards: Add Chardev support for relevant boards
As of now both Dragonboard410c and Hikey boards run latest LTS kernel.
Hence, adding chardev support for those.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Ivan Farkas <Ivan.Farkas@TeleCuris.com>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-10 16:49:18 -04:00
Manivannan Sadhasivam
b48baf01bc gpio: chardev: Fix flag for checking kernel owned & open source gpio line
The flag used for checking the kernel owned gpio line is GPIOLINE_FLAG_KERNEL.
Hence use that instead of GPIOLINE_FLAG_IS_OUT.

Flag used for checking the open source gpio line is GPIOLINE_FLAG_OPEN_SOURCE.
Hence use that instead of GPIOHANDLE_REQUEST_OPEN_SOURCE, which should be
only used when requesting lines.

Reported-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-06 15:47:06 -04:00
Manivannan Sadhasivam
be9cd0138a arm: 96boards: Run clang-format on source code
Run clan-format on the source code for better code visibility.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-06 15:20:13 -04:00
Manivannan Sadhasivam
dee7b80f06 arm: 96boards: Add Chardev support for relevant boards
As of now both Dragonboard410c and Hikey boards run latest LTS kernel.
Hence, adding chardev support for those.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
2018-04-06 15:19:25 -04:00
Abhishek Malik
cfda9c99d7 UART: Fixing UART issues on UP2
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2018-03-14 16:21:42 -07:00
Mihai Tudor Panu
acff725d93 gpio: minor change to resource cleanup code
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-03-22 17:52:55 -07:00
mihais
ac58754756 gpio: resource cleanup fix for chardev changes
Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-03-22 17:45:34 -07:00
Mihai Tudor Panu
bbcdb1e087 up2: adding platform examples for built-in user leds
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-03-22 15:29:01 -07:00
Mihai Tudor Panu
d9c54e1d31 up2: added chardev map to platform
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-03-14 16:10:03 -07:00
Mihai Tudor Panu
cf2e69a8ea chardev: boards need to specify chardev support explicitly before runtime check is performed
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-03-14 14:39:42 -07:00
Noel Eck
7021096fd7 common.hpp: Handle const char* nullptrs
Fixes for possible NULL pointer dereferencing by C++ header methods.
Updated string methods to return an empty string.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-14 10:54:10 -07:00
Noel Eck
fa40262d89 api: Fixes for missing mraa methods.
This commit includes a set of small fixes flushed out from the google
unit tests.

    * Fixed missing implementations of mraa_get_*_count methods.
    * Fix for NULL string
    * Fix for MOCK platform C++ define.
    * Switched (void) -> () function definitions for consistency.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-13 16:24:04 -07:00
Noel Eck
467cf5132d gtest: Added Google Test
Added Google Test for unit testing.  Currently NOT required by
MRAA CMake.

    * Added a test fixture for mraa common C header methods.
    * Added a test fixture for mraa common C++ header methods.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-13 16:16:49 -07:00
Noel Eck
76c8b9a76e travis-ci: Added minimal travis job
Added an additional job to the CI matrix which does a minimal mraa build
(only C) which can run and pass/fail quickly.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-03-13 12:10:34 -07:00
Mihai Tudor Panu
4be5d915af spi.c: fix warning on syslog string format
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-03-12 16:23:47 -07:00
Brendan Le Foll
ea6d771c2b gpio.h: Add gpio_event doc
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
mihais
2b98fc7869 gpio: chardev interface / multiple gpio support for sysfs
Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
Brendan Le Foll
fbc2ad6045 chardev: split up helper functions in gpio_chardev
Remove some _multiple functions and replace with generic function that
does both. Some general cleanup and will move more interrnal mraa
functions to use the _mraa prefix

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
Brendan Le Foll
32ab283c2b firmata_mraa.c: Fix warnings in firmata code due to incorrect code
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
Mihai Stefanescu
9f7caf1561 Joule: Add gpiod mapping for Joule
Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
Brendan Le Foll
12c1904fba gpio.h: Add stripped kernel header
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
Mihai Stefanescu
1665e09928 gpio: Add gpio chardev interface
Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:42:02 +01:00
Brendan Le Foll
aa7006cce9 travis: Remove IPK & RPM builds
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:40:00 +01:00
Brendan Le Foll
9bc3ffe815 raspberry_pi.c: Removing spi_frequency_replace as that has become default behaviour
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:34:40 +01:00
Brendan Le Foll
7840710d1b spi.c: Stop trusting SPI_IOC_RD_MAX_SPEED_HZ from the kernel and trust our users
SPI_IOC_RD_MAX_SPEED_HZ is often incorrect and too low (RPI, UP2, galileo g1 at
least). Likely this is because driver writers are too concious of possible
issues or because they don't have the final hardware. Because of this we now
will only LOG_NOTICE on exceeding SPI_IOC_RD_MAX_SPEED_HZ and try keep going
anyways. This effectively will put the burden of not exceeding
SPI_IOC_RD_MAX_SPEED_HZ on our users.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 13:34:40 +01:00
Brendan Le Foll
ae2371c804 cmake: Remove all cpack options including IPK generation
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-03-05 11:45:39 +01:00
Alex Tereschenko
2deaa73ebf static code analysis: correct SonarCloud URL
According to SonarCloud's email notification,
they're dropping sonarqube.com in favor of sonarcloud.io.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-03-02 20:27:15 +01:00
Mihai Tudor Panu
fbb7d92320 mraa: Update to v1.9.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-02-15 15:08:49 -08:00
Alex Tereschenko
2d210621cc mraa.c: make mraa_gpio_lookup() return proper pin index
Pinmap field value is an OS pin number, not mraa pin index,
so make the function return the proper one.

Fixes #817.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-02-07 17:28:58 +01:00
Brendan Le Foll
568c077061 building.md: Add note for static builds and bindings
Closes #864

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-02-07 09:42:34 +01:00
Mihai Tudor Panu
616ffc0b94 cmake: fix indentation on some messages for consistency
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-02-06 20:48:32 -05:00
Mihai Tudor Panu
60b77d5da9 FindNodejs: extend search path to detect ubuntu provided nodejs
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-02-06 20:29:37 -05:00
Noel Eck
cb03cab04a FindNodejs: Updated to find node<version>
Updates to the FindNodejs.cmake module to find newer installs of nodejs
across other distros.  For example openSUSE: /usr/include/node6/node.h

    * Added PATH_SUFFIX to find_path for node.h.
    * Standardized usage of message() (added STATUS)
    * Call find_package_handle_standard_args with version
    * Reformatted to look uniform.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-02-06 10:05:39 -08:00
Khem Raj
c9566bdc6f examples: include endian.h for be16toh and le16toh declarations
this gets exposed on musl, on glibc endian.h gets pulled in indirectly

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-02-06 13:34:28 +01:00
Manivannan Sadhasivam
eda9d03547 examples: Cleanup Python examples
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-02-06 13:31:19 +01:00
Alex Tereschenko
c7faa20c14 readme: add Sonar quality gate badge
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-02-06 13:27:37 +01:00
Alex Tereschenko
2c9d9aaf80 intel_edison_fab_c.c: use snprintf(), not sprintf(), to avoid overflows
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-02-03 17:05:25 +01:00
Alex Tereschenko
fd937e69ef src/led.c: make sure we don't try to close a NULL dir
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-02-03 17:05:25 +01:00
Alex Tereschenko
6e13268301 examples: fix static code analysis findings
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-02-03 17:05:25 +01:00
Alex Tereschenko
9b08a97d46 docs: add static code analysis documentation
Fixes #782.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2018-01-28 15:34:50 +01:00
Manivannan Sadhasivam
25b951dd6a examples: Fix samples.mapping
Fix samples.mapping.txt with the cleaned-up C++ examples

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-25 11:24:23 +01:00
Manivannan Sadhasivam
9f44dc45d8 api: mraa: gpio: Fix doxygen warning
This commit fixes the below doxygen warning:

"warning: unexpected token in comment block while parsing the argument of command param"

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-25 11:23:36 +01:00
Manivannan Sadhasivam
d7490d87f2 api: mraa: Add cleaned-up C++ examples to doxygen doc
Add the cleaned-up C++ examples to doxygen doc by modifying the @snippet
tag.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-25 11:23:36 +01:00
Manivannan Sadhasivam
83a67b96fd examples: Cleanup C++ examples
Modify the C++ examples to be of same coding standard like C. As a
part of this cleanup, a new LED example is also added.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-25 11:23:36 +01:00
Manivannan Sadhasivam
eaaebae69d examples: c++: Add mraa include path to CMakeLists.txt
C++ specific examples depends on headers in api/mraa, so include
them in CMakeLists.txt

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-18 14:12:08 +01:00
Manivannan Sadhasivam
e562c774cf examples: cleanup examples directory
Following changes are done as a part of cleanup:

1. Moved the platform specific `C` examples from top level examples/
directory to platform/ subdirectory and renamed helloedison.c to
gpio_edison.c

2. C specific examples are moved to a new c/ subdirectory. As a part
of this process, examples are modified to follow same standards
and few new examples are also added.

3. Include the newly added C examples to relevant API documentation

4. Ran clang-format for all source files in c/, c++/, platform/
subdirectories

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-18 14:12:08 +01:00
Mihai Tudor Panu
3fb65de4b8 mraa.rst: adding Led class API links to Python docs too
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-01-16 15:04:54 -08:00
Mihai Tudor Panu
d538bbc91f index.md: add Led class documentation links to API index page
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2018-01-08 12:10:22 -08:00
Nicola Lunghi
64fe50ffa8 aio: fix wrong max_analog_value and improve floating point value precision
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-04 13:59:22 +01:00
Nicola Lunghi
54c9c1aff1 aio: improve resolution. fix error with max_analog_value rounding.
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-04 13:59:22 +01:00
Nicola Lunghi
44bebc4f87 analogin example: add sleep between read
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-04 13:59:22 +01:00
Nicola Lunghi
1176fcf671 UP: fix error with adc pin numbering.
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2018-01-04 13:59:22 +01:00
Manivannan Sadhasivam
02963b791a tools: remove INSTALLGPIOTOOL flag
This commit removes INSTALLGPIOTOOL flag as it is not
required anymore

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-11-02 10:00:35 +01:00
Manivannan Sadhasivam
ec26f92fe6 tools: add new tools directory
This is the start of the series of commits focussed on
cleaning up the exmaples/ directory.

This commit moves mraa-gpio, mraa-i2c, mraa-uart files
out of examples directory into new tools directory. Moved
files are the good cadidates to be treated as tools
instead of examples.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-11-02 10:00:35 +01:00
Nicolas Oliver
c24a8f8b20 travis: build examples in additional jobs
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-10-19 13:55:09 -07:00
Manivannan Sadhasivam
e1382ad845 led: Add on board LED support
This patch adds support for using on board LED through sysfs.
Commonly available LED parameters are supported.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-19 14:01:14 +02:00
Nicolas Oliver
e7b51f3b66 docs: improve android things docs
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-10-11 14:54:57 -07:00
Nicolas Oliver
b5efa0e591 travis: use images from inteliotdevkit
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-10-11 14:07:59 -07:00
Mihai Tudor Panu
c45ba13ec0 building.md: fixing a few typos
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-10-10 14:42:57 -07:00
Nicolas Oliver
a7a3b39e30 docs: fix reference to linkit_7688
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-10-06 17:05:58 -07:00
Serge Vakulenko
6770be911b Add support for MIPS-based boards Omega2 and Linkit Smart 7688
Signed-off-by: Serge Vakulenko <vak@besm6.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-05 10:54:57 +02:00
Nicolas Oliver
668776fbfd docs: remove empty lines in tools checking logs
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-04 13:18:39 +02:00
Nicolas Oliver
c6dbe76116 FindYuidoc.cmake: modify log format of yuidoc version
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-04 13:18:39 +02:00
Nicolas Oliver
e9d1b1ef28 docs: add additional validation for doc tools version
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-04 13:18:39 +02:00
Nicolas Oliver
c6d49f6255 src/javascript/CMakeLists.txt: codestyle update for yuidoc task
Signed-off-by: Nicolas Oliver dario.n.oliver@intel.com
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-04 13:18:39 +02:00
Nicolas Oliver
3f3f657887 docs: require specific version of doc tools
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-04 13:18:39 +02:00
Sergey Kiselev
99287f40a1 rpi: Add support for Raspberry Pi Zero W
This patch adds support and autodetection for Raspberry Pi Zero W.
It also adds more revisions for Raspbery Pi Zero from here:
http://elinux.org/RPi_HardwareHistory

Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-10-04 11:56:33 +02:00
Mihai Tudor Panu
721c5533eb readme: small update to installing on Ubuntu section
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-09-25 10:31:55 -07:00
Brendan Le Foll
1a4ba6a7d3 docs: Update various references and texts
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-21 13:38:06 +02:00
Brendan Le Foll
eb7238d9af mraa: Update to v1.8.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-15 11:30:54 +02:00
Mihai Tudor Panu
5b2ecd18ae up2: minor doc improvements and changed pin name to avoid init error msg
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-14 13:10:37 +02:00
Mihai Tudor Panu
cc55ee6314 grovepi: grovepi subplatform support via i2c
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-14 13:10:37 +02:00
Nicola Lunghi
c6b1b18a9d src/x86/up.c: Added support for uart cts/rts
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:55:36 +02:00
Nicola Lunghi
64a0db6a50 up: various fixes in pin naming on up1 and up2
fixes naming in up and up2 platform
- changed the name of the i2c function
- add a warning in the log if a name is not found

Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:55:07 +02:00
Javier Arteaga
04a40ed63f src/x86/up2.c: Add UP^2 EVT3 support
This commit adds a MRAA platform for the UP Squared board, EVT3 revision.
It handles the relevant FPGA configuration updates when using MRAA to
change pin modes or toggle GPIO directions.

Signed-off-by: Javier Arteaga <javier@emutex.com>
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:54:39 +02:00
Nicola Lunghi
6fad8d9888 src/x86/up.c: get i2c numbering from pci information instead of hardcoding it
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:54:39 +02:00
Nicola Lunghi
2e2cd37cfa src/x86/up.c: add platform version information
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:54:34 +02:00
Nicola Lunghi
d78ad91635 src/x86/up.c: Require kernel FPGA control
abort the loading of mraa if the up kernel module is not loaded

Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:48:02 +02:00
Nicola Lunghi
45127e04b9 Add support for UART hardware flow control
This allows assigning platform pins to the CTS/RTS lines.
If provided, these will be muxed as UART when flow control is enabled.

Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:48:02 +02:00
nick
6185f0ac92 rpi: Return 0 if mmap is already done
Signed-off-by: Nick Crast <nicholas.crast@anaren.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:40:57 +02:00
nick
8356c2f03d rpi: Adding PWM support
The Pi doesn't have userspace level PWM support, but you can mmap the
raw registers and configure it that way, which is what this patch is
doing. Tested with Raspberry Pi 3 B. I am able to set the duty cycle,
change the frequency, and set the pulse width. Signals verified with
logic analyzer. Note that the only accessible pwm is on GPIO18, which is
also used by the audio subsystem.

Signed-off-by: Nick Crast <nicholas.crast@anaren.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-12 11:40:38 +02:00
Manivannan Sadhasivam
615e0cd83a src: arm: Add mmap support for db410c
This commit adds mmap support for 96Boards Dragonboard410c

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-06 11:18:33 +02:00
Ferry Toth
6a1ed23246 intel_edison_fab: enable support for vanilla kernels >= 4 for serial
This disables changing pinmux as this is envisioned to be done through acpi
provided by u-boot

Signed-off-by: Ferry Toth <ftoth@exalondelft.nl>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-06 11:18:33 +02:00
Brendan Le Foll
c2787441b4 java: Fix path to mraajni.c
Fix error in e2f964a280

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-06 11:18:33 +02:00
Brendan Le Foll
e2f964a280 swig: use swig_add_modules if cmake > 3.7
swig_add_module has been deprecated

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-09-06 11:11:10 +02:00
Noel Eck
65e30bf7d3 iio: Allow mraa_iio_trigger_buffer to handle void* args
Previously, mraa_iio_trigger_buffer took a void* args but did not use
this.  Included implementation to allow user to pass a void* to this
method and have the corresponding pointer returned in the interrupt
handler.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-08-30 14:14:41 -07:00
Noel Eck
1217c5c034 examples: Remove heap allocation from C++ examples
Small cleanup of MRAA C++ examples.  Switched from heap allocation to
stack allocation when possible.  This simplifies the samples since it
removes the need for explicit memory management.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-08-23 14:49:12 -07:00
Sanrio Alvares
d50b646c35 peripheralman: fix uart data available api
Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-08-22 16:12:51 +02:00
Alex Tereschenko
badf25f289 phyboard.c: fix whitespace error
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-08-19 19:48:44 +02:00
Alex Tereschenko
ba72c5b089 arm: fix compiler warnings
There were unused variables, incorrect pointer operations
and plan broken string comparison.

Now there's only one - for unused uart3_enabled in beaglebone.c,
but we want to keep it for declaration consistency.

Also fixes #757.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-08-19 19:48:44 +02:00
Nicolas Oliver
c4e23e1a41 sonar: remove sonar-scan from allow_failures
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-08-18 11:17:39 -07:00
Nicolas Oliver
e0a1862ce3 Travis CI and Documentation Generation improvements
* Use docker images from docker hub instead of building them on Travis
* Fix doxygen warnings for C/C++ Documentation
* Fix examples inclusion in documentation
* Modify Travis build matrix to include stages and additional jobs
* Update doxygen2jsdoc submodule
* Add doxyport submodule
* Generate documentation for each language in Travis
* Add sonar.java.binaries to sonar-scan.sh

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-08-10 10:47:11 -03:00
spitfire88
14bf91af44 peripheralman: fix uart and add supported replace functions
Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-28 14:34:05 +02:00
Tapani Utriainen
f71b4be059 beaglebone.c: use the ret variable in i2c_init_pre also when successful
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-28 14:33:16 +02:00
Tapani Utriainen
0b1ccf526f beaglebone.c: check devpath only once in i2c_init_pre
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-28 14:33:16 +02:00
Tapani Utriainen
46e5aab56e beaglebone.c: let i2c_init_pre return an error if muxing fails
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-28 14:33:16 +02:00
Tapani Utriainen
8f57b21a26 beaglebone.c: use snprintf instead of sprintf in i2c_init_pre
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-28 14:33:16 +02:00
Abhishek Malik
808d314043 firmata_mraa.c: Handling PWM period
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-22 07:33:09 +02:00
Nicolas Oliver
95068c4259 docs: Add documentation for building mraa with docker
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-21 08:46:45 +02:00
Nicolas Oliver
189b959012 sonar: modify sonar-scan.sh script
Prevent execution on non configured env & add sonar target to allowed failures
in travis

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-21 08:46:45 +02:00
Nicolas Oliver
4bedd68c4e travis: improve docker images generation for building
Make a build heriarchy to reduce images size.
Add Android Thing Build.

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-21 08:46:45 +02:00
Sanrio Alvares
3d77c86634 peripheralman: implement gpio interrupt
Add gpio interrupt support for peripheral manager based on the
existing implementation in gpio.c.
Rewrite steps by using a global reference to lookup java isr
routine using JNI methods and add exception check after every call.
Free local reference class since it's not garbage collected and will
lead to a memory leak.

Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-21 08:09:37 +02:00
Sanrio Alvares
5bbea8010e peripheralman: fix return values
Be consistent with the return values from MRAA and propagate the
errors received from PIO in case of failure. PIO returns 0 on success
and negative errno on failure. Handle APIs that must return length of
read/written data if PIO returns success.

Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-21 08:08:56 +02:00
Martino Facchin
86e7ece2f6 pwm.c: Fix crash if pin == phy_pin_count
Signed-off-by: Martino Facchin <m.facchin@arduino.cc>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-20 11:27:30 +02:00
Noel Eck
08c7c0215e changelog.md: Small fix to typo in changelog
Changed Documentnatino - > Documentation

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-13 09:43:38 -07:00
Mihai Tudor Panu
4f3eae90e8 sonar-scan: disable code scans for mraa clones as they require setup
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-07-12 20:28:59 -07:00
Nicola Ponte
7d6164c136 gpio: Add support for push-pull/open-drain output mode
This attribute is not part of gpio standard attributes
so it's necessary to implement a custom version of this function

Signed-off-by: Nicola Ponte <nicola.ponte@u-blox.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-04 10:12:03 +02:00
Alex Tereschenko
be9fcf2b2d .gitignore: add Sonar and VSCode dirs
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-07-03 20:23:10 +02:00
Alex Tereschenko
fc00fa20d2 static code analysis: introduce automated scans via SonarCloud
This adds Travis and Docker configurations for automated scans,
both for master branch and internal PRs.

External PRs won't be checked due to security concerns
(and Travis limitation related to that) - GH and SonarCloud tokens
are not propagated to those.

An organization and project must be created in SonarCloud for reporting,
as well as a technical GH user with mraa repo commit permission, to set
PR statuses in the "checks" section.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-07-03 20:23:10 +02:00
Alex Tereschenko
caf75a68c0 jsonplatform.c: properly reallocate memory for platform name
Fixes #761.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-07-01 18:06:33 +02:00
Manivannan Sadhasivam
bd3d9d8cab gpio : Add support for input pull up/down modes
Make use of 'active_low' interface in sysfs for configuring input pin
in pull up / pull down mode. C++ binding also has been added.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-28 12:14:50 +02:00
Alex Tereschenko
3f932ac952 x86.c: sanitize data read from sysfs during board detection
Fixes #771.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-24 12:26:46 +02:00
Alex Tereschenko
d544e3c2f6 jsonplatform.c: fix potential segfault at pin label processing
Also update docs to reflect the max label length.

Fixes #738.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-21 14:12:34 +02:00
Alex Tereschenko
30bbb88685 mraa.c/x86.c: use exact match in strncmp() to avoid surprises
Closes #736.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-21 14:12:30 +02:00
Alex Tereschenko
e0052acfa7 mock tests cmake cfg: use PYTHON_DEFAULT_INTERP instead of _EXECUTABLE
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-19 20:48:29 +02:00
Alex Tereschenko
3731f88c4f python3 cmake cfg: correct typo in defines
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-19 20:48:29 +02:00
Brendan Le Foll
869f76c5c5 python: only add python dir if we have the prerequisites
This means we can depend on the directory existing to check if the
prerequisites are met in the tests/ section

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-19 20:48:29 +02:00
Brendan Le Foll
e1778c811d tests: add USEPYTHON3TESTS to explicitly use python3 for tests
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-19 20:48:29 +02:00
Brendan Le Foll
09f8b3ac7b tests: Remove checks for mraa.py python module
As commented by @alext-mkrs - When cmake runs through these lines, the
make naturally hasn't run yet, so there are no such files, so it doesn't
set the PYTHON_DEFAULT_INTERP variable and that causes it not to add
tests to the list later on

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-19 20:46:18 +02:00
Alex Tereschenko
32196d10e9 joule: align SPI bus numbering with reality
Also update docs to make the numbering and pins used crystal clear.

Closes #758.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-06-15 20:49:18 +02:00
Nicolas Oliver
000746c20d build config: fix parameter configuration for docker-compose
We were incorrectly using clang all the time, overriding gcc.
This also brings newer version of docker-compose.

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-06-10 18:15:09 +02:00
Brendan Le Foll
4109b8b454 aio: Update documentation to mention 0 indexed
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-06 15:56:14 +02:00
Alex Tereschenko
c36e4add5a examples: make main loops finite to ensure proper cleanup
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-06 15:52:48 +02:00
Alex Tereschenko
32340f6819 examples: misc static code analysis fixes
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-06 15:52:48 +02:00
Nick Crast
bb3584fcdb mraa_internal_types.h, aio.c, beaglebone.c:
Beaglebone AIO pins seem to be a little different than most boards, so
this is my attempt to work with that without impacting other boards. I
added a new flag in mraa_board_t to indicate whether or not the aio pins
are sequential. One the beaglebone, they are not. To go along with this,
I added a new device mraa_aio_dev_t, that will map each aio to a
physical pin.

In the main aio logic, if aio_non_seq is true for the board, the manual
mapping is used, otherwise the old mathematical mapping is used.

Signed-off-by: Nick Crast  <nrcrast@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-06 15:51:30 +02:00
Nick Crast
ff03b2de1d beaglebone.c Beaglebone should now work with newer kernels
Made the pin declarations a little nicer to look at. Found a bug with
the I2C. The higher layers were passing the bus ID itself, not the index
of the device in the i2c_bus array.

Signed-off-by: Nick Crast <nrcrast@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-06-06 15:47:50 +02:00
Nicolas Oliver
79da382832 travis: migrate travis plans to run in a Docker container
Add Dockerfile to create build environment for mraa
Add docker-compose.yaml file to easily execute build tasks
Add .dockerignore file
Modify .travis.yaml file to use docker and docker-compose for building
Modify package.json.cmake to run a simple load test for node.js

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-31 17:17:39 +02:00
Brendan Le Foll
131ff46a0d tests/CMakeLists.txt: Fix trying to run tests even if no python interpreter is available
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-31 17:17:39 +02:00
Brendan Le Foll
f927bffb16 tests/mock: make all mock tests executable
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-31 17:17:39 +02:00
Brendan Le Foll
8133de0cc0 mraa-uart.c: Remove impossible condition with a fprintf
Thanks to @pylbert for the spot

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-31 12:12:18 +02:00
Brendan Le Foll
ecb53c8501 raspberry_pi.c: Remove max spi freq by adding replace func
Closes #255

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-31 12:01:04 +02:00
Brendan Le Foll
1d37d3b162 tests/CMakeLists.txt: Clean up cmake tests to work with python 2&3
Adds additional checks and PYTHON_DEFAULT_INTERP var that is used to
find the correct python binary as well as checks to see if the
_python2-mraa or _python3-mraa targets have been built by checking
mraa.py. This does assume that this is all that is needed as checking
for TARGET() is not enough as the target is always 'valid'. We prefer
python2 and will only run the java tests if we can find python2

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-30 19:31:34 +02:00
Alex Tereschenko
722b83b95c intel_edison_fab_c.c: fix unused variables
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-29 18:47:45 +02:00
Alex Tereschenko
822160b7de uart.c: fix potential use of uninitialized variable
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-29 18:47:45 +02:00
Alex Tereschenko
98e755d147 pwm.c: remove surplus variable assignment
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-29 18:47:45 +02:00
Alex Tereschenko
2980e211db doxy2swig.py: remove/explain 'do-nothing' blocks
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-29 18:47:45 +02:00
Alex Tereschenko
69f7d09103 mraa.c: remove surplus variables, correct memory allocations
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-29 18:47:45 +02:00
Tapani Utriainen
56d5666ae9 mraa-uart: add a tool for testing, using and debugging UARTs using MRAA
This patch introduces examples/mraa-uart that can be used as a general tool
for UART communication and UART settings.

The syntax mimics the one used for mraa-gpio.

This is an initial version, beware of insects.

Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-28 08:12:18 +02:00
Tapani Utriainen
a6f2464bb1 uart: add a function to query current UART settings
This patch adds a function to query UART settings in an unintrusive way.
It can be used using a uart index or a devpath and it strives to just
read out the settings without affecting the state of the UART.

Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-28 08:11:21 +02:00
Tapani Utriainen
d6edf76680 mraa: add accessor functions to return counts of spi, pwm, gpio and adcs
Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-28 08:11:21 +02:00
Tapani Utriainen
b7e8d96945 mraa: add a function that returns the number of uarts available
Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-28 08:11:21 +02:00
Tapani Utriainen
04c5593cef uart.c: add function to return baudrate as an integer from a speed_t
Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-28 08:11:21 +02:00
Tapani Utriainen
818ae995c2 uart.c: fix return value for invalid baudrates in uint2speed
This patch probably changes no functionality.

Before this patch the return value 0 was used for invalid baudrates in
uint2speed, but this is not a proper speed_t constant.
Instead the constant B0 is returned now, since on x86 and arm linux
architectures B0 is defined as 0.

Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-28 08:11:21 +02:00
Alex Tereschenko
47c21e0b6c jsonplatform.c: fix automated and manual code analysis findings
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-18 20:42:32 +02:00
Alex Tereschenko
816be65ba0 gpio.c,aio.c,iio.c: misc fixes of static code analysis findings
SonarQube is awesome!

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-18 20:41:51 +02:00
Alex Tereschenko
b73fdff00d examples: be more defensive and replace strcmp() with strncmp()
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-17 19:45:05 +02:00
Alex Tereschenko
398b851144 mraa.c: be more defensive and replace strcmp() with strncmp()
Closes #731.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-17 19:34:53 +02:00
Tapani Utriainen
5ef3f3ea29 mraa.c: add a by-name lookup function also for UARTs
Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-16 17:14:30 +02:00
Tapani Utriainen
9479843cde mraa.c: make lookup functions more robust with null pointer checks
Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-16 17:14:30 +02:00
Tapani Utriainen
dc1255ad75 mraa.c: fix style of lookup functions
This patch has no changes in function. It fixes three style issues
to be more readable and in line to the rest of the codebase:
- return types are declared on a separate line
- reversal of Yoda conditionals
- initialize for loop variable inside loop declaration
- Fix styling of pwm lookup doxygen

Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-16 17:14:30 +02:00
Alex Tereschenko
9545a2e320 stability: replace strcpy with strncpy to avoid potential overflows
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-15 21:04:18 +02:00
Alex Tereschenko
0654183b9a stability: replace sprintf with snprintf to avoid potential overflows
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-15 21:04:18 +02:00
Alex Tereschenko
918e2b18e2 spi.c: fix potential null pointer dereference
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-15 21:02:50 +02:00
Tapani Utriainen
e7b0a3e809 uart: add a null pointer check before dereferencing plat->adv_func
Signed-off-by: Tapani Utriainen <tapani@technexion.com>
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-15 21:00:34 +02:00
Brendan Le Foll
8ddbcde84e mraa: Update to v.1.7.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-12 05:16:20 -07:00
Brendan Le Foll
a0332b14b5 Revert "x86.c: add NUC5i7RYB to the list of known NUC5 platforms"
This reverts commit 2f51627d18.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-12 01:23:58 -07:00
Nicola Lunghi
def0a6aed1 up.c: Fixed pin name size on up board
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-12 01:23:47 -07:00
Robert Wolff
9d65d6e0f0 master/README.md: Add 96Boards option/link to ARM supported boards.
Added 96Boards option to list of ARM supported boards
with relative link.

Signed-off-by: Robert Wolff <robert.wolff@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-09 08:41:41 +02:00
Mark van der Pol
4b08887c54 minnow_max.md: Added the Minnow Turbot, replaced broken links
MinnowMax is obsoleted, replaced with the Minnow Turbot - updated the web links
to point to the legacy board pages, and the new board where appropriate.  Pin
26 - Added a pin function for the I2S MCLK

There is more work to do to capture and document all the changes.

Signed-off-by: |\/|ark van der Pol <markx.van.der.pol@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-09 08:41:02 +02:00
Jon Trulson
e0a0dac47b uart: add tcsendbreak support
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-08 21:15:33 +02:00
Alex Tereschenko
6d5b2c0642 .travis.yml: remove Node.js 0.10 and 0.12 - no longer supported
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-06 14:44:48 +02:00
Kas Perch
075a7b1225 JS examples: refactor for clarity and consistent style
Signed-off-by: Kassandra Perch <the@nodebotani.st>
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2017-05-06 14:38:54 +02:00
Mihai Tudor Panu
43d9f6c400 readme.md: minor formatting and content changes
Clarified the need for explicit call to addSubplatform when libmraa is installed from NPM, fixed heading, added link to Firmata subplatforms.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-05 16:52:44 -07:00
Noel Eck
1379c1fe33 types.hpp: Added Platform type for PIO
MRAA C++ getPlatformType casts the return from mraa_get_platform_type()
to a Platform enum (which did not exist in C++ for AT).  Added enum type
to types.hpp which corresponds to the C enum type.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-04 11:10:08 -07:00
Sanrio Alvares
80335b18b6 peripheralman: i2c_read_bytes_data returns length of read bytes
Return length of read bytes rather than 0 on success.
MRAA calls I2C_RDWR ioctl which returns number of bytes read.
PIO is yet to implement that API so currently does I2C_SMBUS
ioctl instead, which returns 0 in case of success.

Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
2017-05-04 02:29:34 -07:00
Robert Wolff
be2bd63223 docs/96Boards.md: Created and populate 96boards.md
First submission for 96Boards markdown in docs folder. Currently
hosts information and resources for three Consumer Edition
96Boards including DragonBoard 410c, HiKey, and Bubblegum-96.
Plans to expand on this doc as more boards are enabled. Will also
highlight any notes as things come up.

Signed-off-by: Robert Wolff <robert.wolff@linaro.org>
2017-05-04 17:10:49 +02:00
Sanrio Alvares
35e17ee25a periphmraa: fix pwm calls to PIO
Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-30 16:39:22 -07:00
Sanrio Alvares
ef2fddc1e1 periphmraa: fix pwm init sequence
Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-28 10:54:58 -07:00
Sanrio Alvares
ce0edf0f62 periphmraa: set pin capabilities
Peripheral Manager provides mutual exclusion between pins
multiple functionalities. This feature in MRAA is redundant for
this platform.

Once the API to retrieve pin functionality from PIO is available
use it to update each pins capabilities.

Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-26 14:43:26 -07:00
Noel Eck
038a7c542a building.md: Small updates to format for AT
Added a bit of formatting to the AT peripheral manager instructions.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 16:24:18 -07:00
Noel Eck
aeb293a163 Peripheralman: Update peripheralman API docs
* Update documentation for C methods
    * Update documentation for CXX methods
    * Update build instructions for building on AT Peripheral Manager Client

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 16:04:33 -07:00
Noel Eck
87fda62759 peripheralman.c: Allocate pwm context for spi
Updated the mraa_pman_pwm_init_replace method to allocate heap space for the
mraa_pwm_context (returned by this method.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 14:42:55 -07:00
Noel Eck
3e19a58710 pio: Remove pio headers from MRAA
The Native PIO API provides both the libraries and headers for use with
the Android Things Peripheralanager client.  This commit removes these
from the MRAA repo in favor of the FindAndroidThings.cmake provided by
the Native PIO API.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 14:42:55 -07:00
Noel Eck
380d2cf638 CMakeLists.txt: Find AT-specific jni.h
Updated the java CMakeLists file to set the JAVA_INCLUDE_PATH for
Android Things.  The JAVA SWIG wrapper will require the jni.h from the
Android NDK.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 14:42:55 -07:00
Noel Eck
1d200840f4 src/CMakeLists.txt: Use AndroidThings find_package
Use the cmake module provided by AndroidThings for setting libs/hdrs
instead of the hard-coded path to the AndroidThings library.  This
requires adding a path to CMAKE_MODULE_PATH which contains
FindAndroidThings.cmake.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 14:42:55 -07:00
Vineela Tummalapalli
34b4d4a97b Periphmraa: Bypass version check if version is 0.0
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Vineela Tummalapalli
913eaf2440 periphmraa: Create IndexLookup functions for GPIO, I2C, SPI, PWM
These lookups provide the MRAA index with the Pin/Bus name as input

Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Sanrio Alvares
7bc069a8fd periphmraa: Fix compilation errors in PWM
config PERIPHERALMAN fails to compile with PWM. Fix it.

Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 14:42:55 -07:00
Sanrio Alvares
beaba463f7 peripheralman.c: Added PWM
Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Stefan Andritoiu
567a92fde5 periphmraa: Added explicit casts for (implicit) casts that were causing errors in periphmraa build, in the wrapper code
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Stefan Andritoiu
4270e7a743 periphmraa: Corrected typo in documentation
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Vineela Tummalapalli
a2ee056c7d peripheralman.c: Updating GPIO, SPI, I2C bus structures for all the available buses
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Sanrio Alvares
e607beedda periphmraa: Rename B* -> A*
Fixes compilation issues introduced earlier

Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Sanrio Alvares
c4555bc4e5 peripheralman: Update APIs in accordance with Android Things
Signed-off-by: Sanrio Alvares <sanrio.alvares@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Vineela Tummalapalli
1cec6705d1 peripheralman.c: Updating the mraa_i2c_bus_t structure for all the available i2c busses
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Vineela Tummalapalli
9a306fc1f5 peripheralman.c: Fix Gpio pin map value to be valid
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Brendan Le Foll
8a1c58bc7f peripheralman: Remove stray source files from pmraa
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Brendan Le Foll
76850eb0f4 peripheralman.c: Added UART
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Brendan Le Foll
0ec90a3138 peripheralman.c: Added SPI & I2C
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Brendan Le Foll
60ca81a3e1 android-things: Possibly working gpio
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:55 -07:00
Brendan Le Foll
533517a864 mraa.c: Fix elif without statement
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:54 -07:00
Brendan Le Foll
69fcd861a7 android-things: Peripheralmanager target build
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:54 -07:00
Brendan Le Foll
4c7616fe91 android-things: Prep for peripheralmanager support
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-24 14:42:54 -07:00
Mihai Tudor Panu
d7fb6c5af9 travis.yml: use TRAVIS_BUILD_DIR for node-gyp path
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-20 12:27:30 -07:00
Mihai Tudor Panu
9cb0440955 imraa: match version number in imraa.c with imraa.conf
Fixes version inconsistencies for imraa service.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-19 15:31:11 -07:00
Mihai Tudor Panu
2f51627d18 x86.c: add NUC5i7RYB to the list of known NUC5 platforms
While the NUC5i7RYB doesn't provide any built-in IO, this change will at least allow it to be used with a subplatform from IDEs that filter out unknown devices (e.g. Intel XDK).

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-19 15:31:07 -07:00
Arun Ravindran
05d4a917e5 joule: Update the documentation on SPI
The existing documentation shows the MISO and MOSI
pins wrongly. As per the hardware document available
at http://www.intel.com/content/dam/support/us/en/documents/
joule-products/intel-joule-dev-kit-hardware-guide.pdf
pin2 should be MISO and pin 4, MOSI.

Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-19 18:53:16 +02:00
Brendan Le Foll
0d6700fe50 mraa: Update to v1.6.1
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-06 23:55:12 +02:00
Mihai Tudor Panu
791fe0c05a de-nano-soc: renamed platform to avoid ambiguity
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-06 23:53:44 +02:00
g-vidal
ecc64da418 rpi3: Adding detection of raspberrypi3
Signed-off-by: g-vidal <gerard.vidal@ens-lyon.fr>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-06 20:42:22 +02:00
Brendan Le Foll
6d004ca80d mraa.c: mraa_deinit make plat pointer NULL after freeing it
This fixes #698 where an application will crash after calling mraa_deinit and
later closing calling deinit again because of the gcc destructor argument
introduced with cac8f7a

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-06 20:40:18 +02:00
Brendan Le Foll
f911e0620e mraa: Update to v1.6.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:17:53 +02:00
Brendan Le Foll
bf548a3377 Android.mk: Remove defunct Android.mk file
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:06:49 +02:00
Noel Eck
cac8f7a47a common.h: Added destructor attribute for deinit
Currently, mraa_init is called when loading libmraa.  This commit
adds similar functionality to call mraa_deinit when unloading
libmraa.  This is a nice-to-have since it makes identifying other
memory leaks easier.

Signed-off-by: Noel Eck <noel.eck@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:03:19 +02:00
Noel Eck
65f7d2a250 mraa.c: Fix for various small memory leaks
In the process of using the mraa mock platform to identify memory leaks
in UPM libraries.  This commit fixes some non-critical places where
memory was getting lost in mraa.

Signed-off-by: Noel Eck <noel.eck@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:03:19 +02:00
Noel Eck
b937c521f6 Doxyfile.in: Use relative paths in generated docs
Updated Doxyfile to strip the full path to the base MRAA directory
from generated documentation.  This removes the build path from
MRAA documentation.

Old html:

aio_8h.html:<title>mraa: /iotdk/jenkins/workspace/upm-doc-stable/api/mraa/aio.h File Reference</title>

New html:

aio_8h.html:<title>mraa: api/mraa/aio.h File Reference</title>

Signed-off-by: Noel Eck <noel.eck@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:02:43 +02:00
Mihai Tudor Panu
48fe5cebbb de10-nano: minor readme update and added to types.hpp
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:00:56 +02:00
Stefan Andritoiu
d2bbfe376d java: bypass version check for packages that don't have version specified
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 20:00:18 +02:00
Nicola Lunghi
a3f5db1d84 up.c: Removed dead code in up.c
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 19:59:53 +02:00
Lunghi@Emutex
2a1590fdf1 platform_checks.py: Disable check on non edison platforms
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-04-02 19:55:21 +02:00
Arun Ravindran
5e34a5cd3b intel_joule: Update doc with correct PIN behavior
GPIO and I2C functions of some PINs are not possible
with default BIOS configuration. Current documentation
wrongly shows that the PINs can work as both GPIO and I2C.

This patch fixes this issue and also updated pin conf for
I2C 1 and 2 to disable GPIO functionality.

Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-20 16:44:18 +00:00
Andrew Koroluk
6f4b333a31 docs(readme): add note about not supporting Node.js 7
Signed-off-by: Andrew Koroluk <koroluka@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-20 08:37:57 +00:00
Arun Ravindran
dd19634889 joule: Fixing descripencies in gpio numbers
The earlier patches did not fix the following issues.

1) gpio number used for ISH I2C 0 and I2C 1 were not correct
2) gpio number used in ISH I2C 1 and I2C 2 were not correct
3) ISH UART 0 gpio numbers were wrong

This patch fixes this issue and also update the doc.

Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-20 08:37:24 +00:00
Alex Tereschenko
21e0ff7c02 pwm.c: properly close duty file when disabling PWM
Fixes #669.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-16 11:15:35 +01:00
Simo Kuusela
b24e90db0c mraa.c: Fix strsep crash
Variable 'dup' doesn't get freed correctly as the pointer to it changes
after 'strsep' function is used. Also 'token' variable doesn't need to
be freed as freeing the original 'dup' already frees the same memory.

Signed-off-by: Simo Kuusela <simo.kuusela@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-16 11:11:06 +01:00
Arun Ravindran
1c4b1fc329 joule: Fix issue with ISH UART name
MRAA is using gpio 484, 483, 485 and 486 as ISH UART1.
But J13 expansion connector doesn't expose ISH UART1,
instead it exposes ISH UART0 as per dev kit hardware guide.

This patch fixes this descrpency and renames the UART and
also enables the GPIO usage.

Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-13 22:11:40 +01:00
Jon Trulson
f6f124a35f uart_ow: prevent possible infinite loop in _ow_read_byte()
With a broken device, or a broken interface circuit, it is possible
for _ow_read_byte() to spin forever.  This patch arranges for it to
timeout after 5 seconds if it cannot read a valid byte from the UART.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-13 21:55:40 +01:00
Arun Ravindran
c7a4a6db34 intel_joule_expansion.c: Fix issue with gpio-339 mapping
The mapping for gpio-339 went away with commit

gpio-339 is available as LED102 or ISH_IO2

Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-13 21:54:27 +01:00
root
0004dfeefb de10-nano: added initial support for Terasic DE10-Nano-SoC kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-09 17:27:17 +01:00
Arun Ravindran
0470aebee6 joule: Fix issues with gpio mapping
The GPIOs are not mapped correctly in MRAA for tuchuk board.

This patch corrects the GPIO maps and the PIN assignments.

Note:
1) There are nothing called I2S(x)SDO and I2S(x)SDI available over breakout
   pins, the usage is commented now.
2) There is nothing called SPP0FS3, is now commented, what we have is SPP1FS3.
3) I2C1SDA available twise 15 and 71. PIN 71 as per gpio used should be renamed as ISHI2C0SDA
4) I2C1SCL available twise 17 and 73. PIN 73 as per gpio used should be renamed as ISHI2C0SCL
5) UART1TX available twise 22 and 74. PIN 74 as per gpio used is ISHUART1TXD
   and is not available in breakout.
6) UART1RX available twise 24 and 76. PIN 76 as per gpio used is ISHUART1RXD
   and is not available in breakout.
7) I2C2SDA available twise 19 and 75. PIN 75 as per gpio used is ISHI2C1SDA
   and is not available in breakout pins
8) I2C2SCL available twise 21 and 77. PIN 75 as per gpio used is ISHI2C1SCL
   and is not available in breakout pins
9) PIN 78 UART1RT as per GPIO used is ISHUART1RT and is not available in breakout pins
10) PIN 80 UART1CT as per GPIO is ISHUART1CT and is not available in breakout pins

BIOS used is 193

Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-09 17:25:07 +01:00
Cédric Bosdonnat
23fd11c4f7 README.md: Add install instructions for openSUSE
Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 18:17:05 +01:00
Cédric Bosdonnat
875289ab94 rpi: take care of gpiochip base
The gpio pins numbers aren't just matching the physical pin numbers...
on some distros like raspbian, with a kernel explicitly setting the
base to 0, it works, but for kernels using the first free slot it
doesn't (see gpiochip_find_base() in kernel's gpiolib.c).

To get the proper gpio pin value, we thus need to find the base for
the corresponding gpiochip. For the raspberry pi, we search for the
chip with a label containing 'bcm2835'.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:32:10 -08:00
Cédric Bosdonnat
c69b6312fa raspberrypi: add 3 model B support
Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:32:10 -08:00
Cédric Bosdonnat
b20fe9163a rpi: use /proc/device-tree/compatible
While some distributions have a modified /proc/cpuinfo including
the board revision for raspberry pi, most distributions don't
have this.

In order to guess the raspberry pi version in such cases, use
the /proc/device-tree/compatible content as a fallback solution.
The values expected from this file have been taken from
upstream kernel documentation:

Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:32:10 -08:00
Cédric Bosdonnat
b453f6633b arm: prefer /proc/device-tree
As per Documentation/ABI/testing/sysfs-firmware-ofw, perfer
/proc/device-tree over /sys/firmware/devicetree/base as this
is the stable one.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:32:10 -08:00
Cédric Bosdonnat
06359e39cd examples: add return in spi_max7219.c
Some compilers are raising an error if no value is returned in main.
Add a return 0 in spi_max7219.c main to quiet them.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:32:10 -08:00
Cédric Bosdonnat
68c6a8df49 rpi: fix PLATFORM_RASPBERRY_PI_ZERO value
Change PLATFORM_RASPBERRY_PI_ZERO into an integer to avoid
build error when comparing it to integer platform_detected.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:32:10 -08:00
Brendan Le Foll
03fb882ce2 types.h: Remove deprecated attribute as there are too many problems
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-03-02 08:08:40 -08:00
Brendan Le Foll
ff2eba732e types.h: Add C99 guards around duplicat & deprecated enm value
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-27 18:17:30 +01:00
Brendan Le Foll
694e6eab23 joule.md: Fix i2c bus number in documentation
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-27 18:07:51 +01:00
Brendan Le Foll
4264aa5a3b blink_onboard.c: Blink LED101 on Joule
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-27 18:07:51 +01:00
Wai Lun
0092e13f57 Joule: Update references to the Intel Joule
GT/GrosseTete -> Joule. This commit deprecates the MRAA_INTEL_GT_TUCHUCK
mraa_platform_t value and links the grossetete.md page to joule.md.

Signed-off-by: Wai Lun Poon <wai.lun.poon@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-27 18:06:40 +01:00
Fan Jiang
2c529689ed 96boards.c: Fixed wrong i2c port numbers and array length in bubblegum 96 board
Signed-off-by: Fan Jiang <i@fanjiang.me>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-22 08:55:50 +00:00
Brendan Le Foll
fc03ea4816 docs/building.md: add note about forcing a static build of mraa
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-21 17:27:04 +00:00
Nicola Lunghi
caabca37be iio.hpp: Added an empty destructor to get rid of a warning
Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-21 12:13:17 +00:00
Nicola Lunghi Emutex
2ea68105f0 uart.c: Simple compiler error fixes
Signed-off-by: Nicola Lunghi Emutex <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-06 21:34:13 +00:00
Nicola Lunghi
6fabccf131 x86: Normalized function names in up & byt platform
Signed-off-by: Nicola Lunghi Emutex <nicola.lunghi@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-02-06 21:32:54 +00:00
Norbert Wesp
19d69b71da phyboard.c: set each length of snprintf() to defined MAX_SIZE
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-01-31 21:26:21 +00:00
Machiel Bruinink
e606d1d615 i2c.c: added close of file handle on mraa_i2c_stop
Signed-off-by: Machiel Bruinink <m.bruinink@robotcaresystems.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-01-31 21:25:57 +00:00
Norbert Wesp
4472ff1629 phyboard-wega: Added platform support for phyBOARD-Wega
Like the beaglebone, the phyBOARD-Wega also got an am335x.
So I merged the four mmap-functions for gpio_context and some
identical defines in a separate header and c-file.
The new platform support-files are based on beaglebone-files.

The documentation of phyBOARD-Wega is still in process,
but for now there are enough informations.
At this time it is possible to use GPIO-Pins and Uart0
(tested via python with mraa). The code for using SPI, I2C and
PWM is also still in process and not tested yet.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-01-26 22:11:46 +01:00
Mihai Tudor Panu
72261d61bd joule: enable ISH_GPIOs and GPIO_22 exposed on J12 header
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-01-24 19:43:19 +01:00
Jon Trulson
e38630097e UartOW.cpp example: Use .data() string accessor instead of .c_str().
.c_str() works accidentally, but is technically incorrect as these
"strings" can have embedded 0 bytes in them.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-01-19 08:04:45 +00:00
Jon Trulson
c3332f5542 uart_ow.hpp: Correct a logic bug, and 2 questionable uses of c_str()
The command() function had a logic error that caused a command to be
broadcast to all devices on the DS OW bus when a proper ID was
specified.  This should only be done when NO ID is specified.

This fixes UPM issue #502.

In addition, there were two cases where the C++ string accessor method
.c_str() was used when .data() should be used instead.  This worked
anyway (accidentally), but is improper since the strings can have
embedded 0 bytes.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-01-19 08:04:45 +00:00
Abhishek Malik
3bd590c18c Firmata: I2C read bytes data array size mismatch fix
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-12-29 18:51:35 +00:00
Abhishek Malik
17b147ba82 Firmata: Reducing wait time
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-12-29 18:49:24 +00:00
Abhishek Malik
4b22a923cf Firmata: Increasing iterations to allow more precise readings and allow more time for response
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-12-29 18:49:24 +00:00
Alex Tereschenko
af051d820a intel_edison_fab_c.c: further fix for PWM disable problem
This adds logic to save PWM duty when disabling the pin (which sets
the duty to 0), and restore it when re-enabling the pin.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-12-29 18:48:53 +00:00
belugon
2558866d4a intel_edison_fab_c.c: Fix edison disabled pwm stuck at high
Edison pwm can stuck at high if pin is disabled during ON pwm peroid.
Workaround is to force zero duty time before disabling the pin.

Signed-off-by: Billy Bai <belugon@outlook.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-12-29 18:48:41 +00:00
Brendan Le Foll
c1017bb6ea intel_gt_tuchuck.c: Clear uart pin cap since bios doesn't allow muxing
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-30 11:37:47 +01:00
Brendan Le Foll
1c180e393c uart.c: Allocate mem for dev->path to fix getDevicePath in raw mode
When mraa_init_uart_raw is called it places the path arg in dev->path. This
works in non raw mode because the path is statically in the device
configuration but in raw mode this is a dynamic address meaning that we need to
copy it. Fix this by simply copying the device path rather than relying on the
user keeping that string path in memory.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-30 11:33:40 +01:00
Fan Jiang
250590e1ed 96boards.c: Added Bubblegum 96 board
- Proper board detection
- Styling refactored using clang-format

Signed-off-by: Fan Jiang <i@fanjiang.me>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-30 11:13:38 +01:00
Brendan Le Foll
68e9399c4c cmake: use TARGETS instead of FILES for js module install
This strips the local RPATH when doing a `make install` rather than running
from the build/ dir

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-23 17:59:04 +00:00
Brendan Le Foll
ad6eb53f81 jsonplatform.c: Remove for loop initial delcarations
This is C99 only and doesn't really provide any value

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-21 10:33:29 +00:00
Dan O'Donovan
d2f1b068b7 update UP board hardware details and enable ADC
Some details regarding the UP board are not in-sync with the
final production version of the board.  This update adds an
ADC, removes a UART, and some corrections in the docs for UP.

Signed-off-by: Dan O'Donovan <dan@emutex.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-21 10:24:05 +00:00
Henry Bruce
a0332a13b0 examples: Python MCP3004 ADC example (use with MinnowMax Calamari lure)
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-21 10:23:21 +00:00
Henry Bruce
a63ad7e10d json: Initial config file for Intel Aero platform (i2c and spi only)
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-21 10:23:21 +00:00
Henry Bruce
9de294b389 json: Improve i2c and spi configuration.
Bus number no longer has to be the same as its id and all busses are
disabled until a configuration entry is found.

Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-21 10:23:21 +00:00
Henry Bruce
61d20c7266 json: Removed tabs and tidied up Turbot JSON formatting
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-21 10:23:21 +00:00
Thomas Ingleby
d043faf687 imraa: correct imraa.service
Should work in more environments now.

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2016-11-08 16:24:51 +01:00
Brendan Le Foll
6f9b470d8d mraa: Update to v1.5.1
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 13:39:32 +00:00
Brendan Le Foll
92188ab950 mraa.c: Fix another memleak in mraa_find_i2c_bus_pci
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 13:36:53 +00:00
Brendan Le Foll
3d790a8278 mraa.c: fix memleak in find_i2c_bus_pci
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 13:27:38 +00:00
Brendan Le Foll
dbcba5cbeb imraa.c: remove ARGP_KEY_ARG checking that makes no sense
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 13:04:44 +00:00
Brendan Le Foll
ef8102deb1 imraa_io.c: Avoid gpio handle going out of scope if uid == NULL
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 12:55:34 +00:00
Brendan Le Foll
7b7b11415b imraa.c: We have 0 args as minimum so remove error check for < 0 against unsinged int
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 12:48:47 +00:00
Brendan Le Foll
5a3f73731c mraa: Update to v1.5.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 12:32:49 +00:00
Brendan Le Foll
e466d1f890 imraa.service: Adjust flag to match new imraa argp options
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-04 10:29:26 +00:00
Brendan Le Foll
ae127b19a5 binding.gyp.cmake: Use node or nodejs depending on what the binary is called
This should fix npm builds on some recent ubuntu and debian images

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-03 15:24:47 +00:00
Brendan Le Foll
fe76260837 npm.md: Update docs to include json removal
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-03 15:24:12 +00:00
Brendan Le Foll
bf4d14ef02 imraa: change list_serialport function to get_101_serialport
This makes things alot less confusing!

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-03 09:40:23 +00:00
Brendan Le Foll
d602196bd6 mraa.c: add LOG_NOTICE to checkout what i2c bus is added from pci
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-02 17:22:38 +00:00
Brendan Le Foll
e387946208 jsonplatform.c: Disable i2c bus in case of bus count being high but busses are undefined
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-02 17:20:31 +00:00
Brendan Le Foll
fa35855bb6 mraa.c: Use mraa_atoi instead of atoi in lockfile adding
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-02 15:30:56 +00:00
Brendan Le Foll
4a33aca8fd intel_gt_tuchuck.c: Use new mraa_find_i2c_bus_pci to find i2c busses
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-02 15:30:56 +00:00
Brendan Le Foll
9d365ce0d6 mraa.c: Find i2c bus by pci id
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-02 15:30:56 +00:00
Brendan Le Foll
23e871c5bb mraa_internal.h: Add internal definition for mraa_atoi
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-11-02 15:30:56 +00:00
Thomas Ingleby
3bb17bb7b9 travis: use mirror of swig-3.0.10.tar.gz
closes #595

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2016-10-31 14:31:18 +01:00
Fathi Boudra
8218e42d41 doc: fix spelling errors
Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-30 10:58:36 +00:00
Brendan Le Foll
3971d27f8a imraa: split imraa up into imraa_io and imraa_lock
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
c69d1884c9 imraa.io.conf: Imraa IO configuration
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
cada819c39 intel_edison_fab_c.c: don't undo muxing if we don't own the pin
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
0b5130335d mraa.c: add error if adding a MRAA_GENERIC_FIRMATA subplat and not supported
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
b4cf93f1f8 gpio.c: Remove use of sprintf in favour of snprintf
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
c7ff9a5173 imraa: Add argp support, split arduino functionality
This commit gets us closer to what was intended for imraa, support of setting
sysfs user permissions

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
c993cf10b4 firmata_curie_imu.c: Fix warning due to signed nature of function input buffer
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
623fef670e firmata: Add pthread spin locks around uart operations
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 14:24:50 +01:00
Brendan Le Foll
bb5ec8bd10 firmata: Remove all 6.2.x warnings
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 12:56:20 +01:00
Brendan Le Foll
a3c717553c cmake: enable INSTALLTOOLS by default
This means mraa-i2c and mraa-gpio are installed in <prefix>/bin by default

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-26 11:55:19 +01:00
Mihai Tudor Panu
6ce1b1c4ce python: remove temporary RPATH from _mraa.so when installing
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:15:29 +01:00
Alex Tereschenko
9f03afbcbc mock: implement UART functionality
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:04:04 +01:00
Alex Tereschenko
8a9efd1bcc uart.c: add replace functions used by mock
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:04:04 +01:00
Alex Tereschenko
1b3a9371a1 uart.c: rework mraa_uart_init_raw to use common cleanup block
This will align it with spi.c and make it easier to introduce
a replace function.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:04:04 +01:00
Alex Tereschenko
ccc4185eff uart.hpp: fix typo in setNonBlocking() function name
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:04:04 +01:00
Alex Tereschenko
6fda865af7 uart.hpp: fix typo in write() description
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:04:04 +01:00
Brendan Le Foll
dd33a32744 README.md: Fix typo in README.md
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:03:23 +01:00
Joseph Butler
7d1ee0c6fe README.MD: Fix ubuntu instructions to update repo
Signed-off-by: Joseph Butler <joseph.butler@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-25 12:02:17 +01:00
Brendan Le Foll
19791be2f5 CONTRIBUTING.md: Add author rules and suggestion on filing issues for feature review
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-24 11:36:22 +01:00
Brendan Le Foll
49ef1623b2 python: Move docs to depend on BUILDPYTHON2 to not build with py3
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 15:21:06 +01:00
Brendan Le Foll
37deb5003b mraa: Update to v1.4.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 14:44:36 +01:00
Brendan Le Foll
980dfce80e mraa.c: return MRAA_SUCCESS when trying to call mraa_add_subplatform twice
If we already have a subplatform present with the same type, return success
when trying to add it again. We don't check that the tty is the same because
that is hidden inside the t_firmata* structure but we should do at some point

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 13:58:40 +01:00
Brendan Le Foll
08e270818a firmata_mraa.c: Clean up for loops with useless statements
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 08:49:36 +01:00
Brendan Le Foll
6bac8594a5 mraa.c: Remove unused variables in mraa_add_from_lockfile
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 08:49:12 +01:00
Brendan Le Foll
11bbd05533 mraa.c: Add MRAA_SUCCESS return to mraa_remove_subplatform
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 08:48:47 +01:00
Brendan Le Foll
1d4b19dc4b mraa.c: Move firmata syslog message to useful location
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 08:48:23 +01:00
Brendan Le Foll
02a7fbf191 imraa.c: Remove unused variables
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 08:47:26 +01:00
Brendan Le Foll
ae15b10997 types.h: Remove tabs that crept in
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-10-11 08:38:09 +01:00
SaschaWeisenberger
be22844922 src/x86/x86.c: add support for Siemens SIMATIC IOT2000
The Siemens device "SIMATIC IOT2000" is identical to the Intel Galileo
Gen 2 regarding the gpios. So if the board name is "SIMATIC IOT2000"
treat the board as if it is Galileo Gen 2.

Signed-off-by: Sascha Weisenberger sascha.weisenberger@siemens.com
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-27 13:08:44 +01:00
Thomas Ingleby
92fdb8aa01 README: Update PPA instructions
Fixes #581

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2016-09-21 23:50:28 +03:00
Stefan Andritoiu
def454e33c java: Renamed pom.xml file to the standard naming convention
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-14 15:17:58 +01:00
Brendan Le Foll
122cab1f1e cmake: Add lots of fancy warnings to CC/CXX and make cmake check they exist
Thanks to Dan Liew for cmake work in fpbench that this is copied from

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-13 11:45:49 +01:00
Brendan Le Foll
6c85b61daa mraa: Fix compiler warnings unused vars and useless statements
Should have 0 functionality effect, just cleans up a few things. Fixes #577

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-13 11:20:41 +01:00
Alex Tereschenko
139d42d084 FindNodejs.cmake: added search paths for Ubuntu 16.04
Closes #566.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-12 12:24:24 +01:00
Stefan Andritoiu
8e38c762f0 java: Added automatic pom.xml file creation in CMake
This is to add mraa package in a Maven repo

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-12 12:23:18 +01:00
Jon Trulson
590f733ff9 uart_ow: convert static const int MRAA_UART_OW_ROMCODE_SIZE to #define
This is needed so that this value can be used in all places in C (and
C++) code.  Unlike C++ you can't always use a static const int
variable to declare an array size for example.  Trying to do so will
yield compiler errors.

In addition, during the declaration of the uart_ow_context, replace a
hardcoded '8' with this macro.  Originally, the '8' was hardcoded for
this very reason.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-12 12:21:46 +01:00
Brendan Le Foll
045ceb084f grossetete.md: Add documentation for uart
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-07 13:51:58 +01:00
Brendan Le Foll
ff3b3004da intel_gt_tuchuck.c: Add SPI to joule pinmap file
This commit fixes documentation for SPI bus to match latest changes in pinmap
file

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-07 13:51:32 +01:00
Brendan Le Foll
5cb2bd220e spi.hpp: Add documentation to raw mode constructor
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-07 13:27:07 +01:00
Brendan Le Foll
8ec4fcb333 intel_galileo_rev_g.c: use pincmd to set OUT_HIGH instead of value
The i/o expander looses connection as soon as direction is set so use direction
OUT_HIGH instead of setting value after direction. Closes #573

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-02 12:00:29 +01:00
Brendan Le Foll
bf2a504774 firmata_mraa.c: retry counter should not be decremented past 0
This means the retry counter works appropriately in case of failure. Closes #574

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-09-02 11:49:26 +01:00
Brendan Le Foll
9bc91f4b12 docs/joule: Rename docs to use joule naming
This also adds the 2 LEDs on the 8260 radio to the mapping

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 16:06:31 +01:00
Brendan Le Foll
6180ddaa8e README.md: update mraa instructions
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 16:03:30 +01:00
Brendan Le Foll
8a93351f0e building.md: Update building docs
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 15:53:39 +01:00
Brendan Le Foll
1591b92605 python2/cmake: Remove unused pydocs target
Pydocs has been deprecated in favour of sphinx as it's really very very ugly

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 15:43:23 +01:00
Brendan Le Foll
22b0f63238 cmake: Remove dirty tag on compilation from non git tree
This is removed to make building in buildsystems like ubuntu's or yocto's
easier. Bugs reported from old versions haven't been that annoying so this is
probably be ok

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 15:00:10 +01:00
Brendan Le Foll
2832909856 mraa: Update to v1.3.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 13:03:47 +01:00
Alex Tereschenko
636c9feb4f travis: add builds for mock
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 12:32:20 +01:00
Alex Tereschenko
0292c960b3 mock SPI: remove loop variable declarations
While working fine on my Fedora 22, under Travis (and Ubuntu)
that fails asking to enable C99 standard first, so let's be conservative.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 12:32:20 +01:00
Alex Tereschenko
9ff47aa64a mock SPI: correct error message to actually use data provided
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 12:32:20 +01:00
Houman Brinjcargorabi
a704a956ea raspberry_pi.c: Added support for pi zero
Signed-off-by: Houman Brinjcargorabi <hbrinjcar@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 12:30:56 +01:00
Brendan Le Foll
94b7477212 intel_gt_tuchuck.c: Make sure GPIOs are set to 0 muxes
Use calloc for pinsize and set mux_total to 0 in all gpios

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 12:26:36 +01:00
Brendan Le Foll
1589389c3f intel_gt_tuchuck.c: LED101 reset to GPIO338
A bios change to 395 was never made so this broke LED101

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-30 11:40:32 +01:00
Alex Tereschenko
bdbbfd03dd mraa mock: Add SPI functionality
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 16:00:53 +01:00
Alex Tereschenko
9030ae2eeb spi.c: added replace functions for all basic actions
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 16:00:53 +01:00
Alex Tereschenko
3a638caf01 spi.c: added context validity checks
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 16:00:53 +01:00
Alex Tereschenko
07f6181c91 mock_board_i2c.c: removed surplus includes
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 16:00:53 +01:00
Houman Brinjcargorabi
0630c5f505 jsonplatform.md: Added documentation
Signed-off-by: Houman Brinjcargorabi <hbrinjcar@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 15:59:53 +01:00
Houman Brinjcargorabi
4277a3ee23 mraa.c: Replaced string values with #defines
Signed-off-by: Houman Brinjcargorabi <hbrinjcar@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 15:46:39 +01:00
Jon Trulson
c976e9f982 gpio.h: remove extraneous extern C declaration
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-19 15:45:08 +01:00
418 changed files with 27069 additions and 9994 deletions

7
.gitignore vendored
View File

@@ -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
View File

@@ -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

View File

@@ -1,55 +1,102 @@
language: cpp
sudo: required
dist: trusty
env:
- NODE010=true
- NODE012=true
- NODE4=true
- NODE5=true
- JSONPLAT=true NODE010=true
- JSONPLAT=true NODE012=true
- JSONPLAT=true NODE4=true
- JSONPLAT=true NODE5=true
# node010 npm builds don't work in clang and anyone using npm should want to
# use something newer
- NPM=true NODE4=true
- NPM=true NODE5=true
compiler:
- clang
- gcc
sudo: required
language: cpp
services:
- docker
before_install:
# Via https://github.com/travis-ci/travis-ci/issues/5326
- export PATH="$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")"
install:
- if [ "${NODE4}" ]; then export CC=gcc-4.8 CXX=g++-4.8; fi
before_script:
# Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
- if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
- if [ "${JSONPLAT}" ]; then export JSONPLAT=ON; else export JSONPLAT=OFF; fi
- if [ "${NODE010}" ]; then nvm install 0.10; fi
- if [ "${NODE012}" ]; then nvm install 0.12; fi
- if [ "${NODE4}" ]; then nvm install 4.1; fi
- if [ "${NODE5}" ]; then nvm install 5; fi
- npm install node-gyp && export NODE_GYP="/home/travis/build/intel-iot-devkit/mraa/node_modules/node-gyp/bin/node-gyp.js"
# Handle 0.10 NODE_ROOT_DIR differently than other versions
- wget http://prdownloads.sourceforge.net/swig/swig-3.0.10.tar.gz && tar xf swig-3.0.10.tar.gz && cd swig-3.0.10 && ./configure --prefix=/home/travis/ && make && make install && cd ..
script:
- echo "CC=$CC BUILDJAVA=$BUILDJAVA JSONPLAT=$JSONPLAT NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
- if [ -z ${NPM} ]; then mkdir build && cd build && cmake -DBUILDSWIGJAVA="$BUILDJAVA" -DJSONPLAT=$JSONPLAT -DNODE_ROOT_DIR:PATH="${NVM_BIN}/.." -DCMAKE_INSTALL_PREFIX:PATH=../install -DSWIG_EXECUTABLE=/home/travis/bin/swig -DSWIG_DIR:PATH=/home/travis/share/swig/3.0.10/ .. && make install && make test; else mkdir build && cd build && cmake -DBUILDSWIGJAVA="$BUILDJAVA" -DJSONPLAT=$JSONPLAT -DNODE_ROOT_DIR:PATH="${NVM_BIN}/.." -DCMAKE_INSTALL_PREFIX:PATH=../install -DSWIG_EXECUTABLE=/home/travis/bin/swig -DSWIG_DIR:PATH=/home/travis/share/swig/3.0.10/ .. && make npmpkg && cd .. && ${NODE_GYP} configure && ${NODE_GYP} build; fi
# simple test to see if we can load our node module
- if [ ${NPM} ]; then cd build/Release/obj.target/ && node -e "var m = require('./mraa.node'); m.getVersion()";fi
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- kalakris-cmake
packages:
- g++-4.8
- cmake
- python
- python-dev
- python3
- python3-dev
- git
- libjson0
- libjson0-dev
- 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
include:
- &run-with-clang-minimal
stage: Clang 3.8 - minimal mock platform
env: TARGET=minimal
before_script: docker-compose pull ${TARGET}
script:
- export CC=clang-3.8 CXX=clang++-3.8
- BUILDARCH=MOCK docker-compose run ${TARGET}
- &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=sonar-scan

View File

@@ -1,62 +0,0 @@
# Copyright (C) 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmraa
LOCAL_CFLAGS += -Wno-unused-parameter -DX86PLAT=1
LOCAL_SHARED_LIBRARIES := libcutils libutils libdl libc
LOCAL_SRC_FILES := \
src/mraa.c \
src/gpio/gpio.c \
src/i2c/i2c.c \
src/pwm/pwm.c \
src/spi/spi.c \
src/aio/aio.c \
src/uart/uart.c \
src/x86/x86.c \
src/iio/iio.c \
src/x86/intel_galileo_rev_d.c \
src/x86/intel_galileo_rev_g.c \
src/x86/intel_edison_fab_c.c \
src/x86/intel_de3815.c \
src/x86/intel_nuc5.c \
src/x86/intel_sofia_3gr.c \
src/x86/intel_minnow_byt_compatible.c \
src/x86/intel_cherryhills.c \
src/x86/up.c \
src/x86/intel_gt_tuchuck.c
# glob.c pulled in from NetBSD project (BSD 3-clause License)
LOCAL_SRC_FILES += \
src/glob/glob.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/include/linux \
$(LOCAL_PATH)/include/x86 \
$(LOCAL_PATH)/api \
$(LOCAL_PATH)/api/mraa \
$(LOCAL_PATH)/src/glob
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/api \
$(LOCAL_PATH)/api/mraa
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)

View File

@@ -1,10 +1,89 @@
cmake_minimum_required (VERSION 2.8)
project (mraa C)
cmake_minimum_required (VERSION 2.8.11)
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 ")
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
endif ()
else ()
set (CMAKE_C_STANDARD 99)
endif ()
###############################################################################
# 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 ()
# This function adds the c++11 flag to a c++ target (if supported)
function(use_cxx_11 targetname)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if (COMPILER_SUPPORTS_CXX11)
set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-std=c++11")
else()
message(FATAL_ERROR "Target '${targetname}' requires c++11 which is not supported by this compiler")
endif()
endfunction()
# Set CMAKE_INSTALL_LIBDIR if not defined
include(GNUInstallDirs)
@@ -31,7 +110,7 @@ include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
message (WARNING " - Install git to compile a production libmraa!")
set (VERSION "v1.2.3-dirty")
set (VERSION "v2.1.0")
endif ()
message (STATUS "INFO - libmraa Version ${VERSION}")
@@ -66,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR})
option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDSWIGNODE "Build swig node modules." OFF)
option (BUILDSWIGJAVA "Build Java API." OFF)
option (USBPLAT "Detection USB platform." OFF)
option (FIRMATA "Add Firmata support to mraa." OFF)
@@ -74,12 +153,10 @@ 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 (INSTALLTOOLS "Install all tools" ON)
option (BUILDTESTS "Override the addition of tests" ON)
option (USEPYTHON3TESTS "Force tests to run with python3" ON)
set (BUILDARCH "" CACHE STRING "Override architecture to build for")
@@ -92,8 +169,7 @@ if (NOT BUILDSWIG)
endif()
if (NOT BUILDARCH)
include (TargetArch)
target_architecture (DETECTED_ARCH)
set (DETECTED_ARCH ${CMAKE_SYSTEM_PROCESSOR})
message (STATUS "INFO - Target arch is ${DETECTED_ARCH}")
else ()
set (DETECTED_ARCH ${BUILDARCH})
@@ -103,12 +179,16 @@ endif()
if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
OR DETECTED_ARCH STREQUAL "i386")
set (X86PLAT ON)
elseif (DETECTED_ARCH MATCHES "arm.*")
elseif (DETECTED_ARCH MATCHES "arm.*" OR DETECTED_ARCH MATCHES "aarch64")
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, arm and mock platforms currently supported")
message (FATAL_ERROR "Only x86, arm, mips, PERIPHERALMAN and mock platforms currently supported")
endif()
if (BUILDSWIGPYTHON OR BUILDTESTS)
@@ -117,8 +197,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)
@@ -128,68 +208,10 @@ if (BUILDDOC)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif (DOXYGEN_FOUND)
endif ()
if (IPK)
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
if (DEFINED ENV{OECORE_TARGET_SYSROOT})
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
else ()
# debian uses amd64 to denote x86_64
if (DETECTED_ARCH STREQUAL "x86_64")
set (TARGET_ARCH "amd64")
else ()
set (TARGET_ARCH ${DETECTED_ARCH})
endif ()
endif ()
message (STATUS "INFO - Package arch is ${TARGET_ARCH}")
set(CPACK_GENERATOR "DEB")
set(OPKG_ARCH ${TARGET_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
set(mraa_PACKAGE_ON_TAG ".")
if ("${VERSION_COMMIT}" STREQUAL "")
set(mraa_PACKAGE_ON_TAG "")
endif()
set(CPACK_PACKAGE_VERSION
"${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_NAME "mraa")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${TARGET_ARCH})
set(CPACK_SYSTEM_NAME ${TARGET_ARCH})
set(CPACK_DEBIAN_PACKAGE_PROVIDES "mraa-dev, mraa-dbg, mraa-doc")
set(CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_PROVIDES}, libmraa, libmraa-dev, libmraa-doc")
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
include (CPack)
endif()
if (RPM)
message (STATUS "INFO - Enabled RPM packaging for ${DETECTED_ARCH}")
set(CMAKE_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "libmraa${mraa_VERSION_MAJOR}")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_VERSION
"${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
# Get distro tag (e.g. 'fc20') by parsing output of rpm --showrc
EXECUTE_PROCESS(
COMMAND rpm --showrc
COMMAND grep -w dist
COMMAND sed -e "s/\\t./ /"
COMMAND awk "{printf \"%s\", \$NF}"
OUTPUT_VARIABLE DIST_TAG
)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${DIST_TAG}.${DETECTED_ARCH}")
include(CPack)
endif()
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 ()
add_subdirectory (src)
if (ENABLEEXAMPLES)
@@ -204,3 +226,7 @@ if (BUILDTESTS AND PYTHON_DEFAULT_EXECUTABLE)
enable_testing ()
add_subdirectory (tests)
endif ()
if (INSTALLTOOLS)
add_subdirectory (tools)
endif()

View File

@@ -1,7 +1,7 @@
Contributing to libmraa {#contributing}
Contributing to Eclipse Mraa (libmraa) {#contributing}
======================
libmraa is an opensource project and we are actively looking for people to help
Eclipse Mraa is an opensource project and we are actively looking for people to help
with:
- Writing platform supports for all types of boards running linux
@@ -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,45 +43,34 @@ job. Few exceptions to coding styles:
Use common sense and don't be afraid to challenge something if it doesn't make sense!
Code signing
Author Rules
------------
The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to pass it
on as an open-source patch. The rules are pretty simple: if you can certify
the below:
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.
Developer's Certificate of Origin 1.1
Eclipse Contributor Agreement
------------
By making a contribution to this project, I certify that:
Your contribution cannot be accepted unless you have a signed [ECA - Eclipse Foundation Contributor Agreement](http://www.eclipse.org/legal/ECA.php) in place.
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
Here is the checklist for contributions to be _acceptable_:
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
1. [Create an account at Eclipse](https://dev.eclipse.org/site_login/createaccount.php).
2. Add your GitHub user name in your account settings.
3. [Log into the project's portal](https://projects.eclipse.org/) and sign the ["Eclipse ECA"](https://projects.eclipse.org/user/sign/cla).
4. Ensure that you [_sign-off_](https://wiki.eclipse.org/Development_Resources/Contributing_via_Git#Signing_off_on_a_commit) your Git commits.
5. Ensure that you use the _same_ email address as your Eclipse account in commits.
6. Include the appropriate copyright notice and license at the top of each file.
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
then you just add a line saying
Signed-off-by: Random J Developer <random@developer.example.org>
Using your real name (sorry, no pseudonyms or anonymous contributions.)
Your signing of the ECA will be verified by a webservice called 'ip-validation'
that checks the email address that signed-off on your commits has signed the
ECA. **Note**: This service is case-sensitive, so ensure the email that signed
the ECA and that signed-off on your commits is the same, down to the case.
Where to find us
----------------

View File

@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright © 2014-2016 Intel Corporation
Copyright © 2014-2019 Intel Corporation and others
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -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

View File

@@ -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

120
README.md
View File

@@ -1,10 +1,11 @@
<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
Eclipse Mraa - Low Level Skeleton Library for Communication on GNU/Linux platforms
=============================================================================
Eclipse Mraa (Libmraa) is a C/C++ library with bindings to Java, Python and JavaScript to
interface with the IO on Galileo, Edison & other platforms, with a structured
and sane API where port names/numbering matches the board that you are on. Use
of libmraa does not tie you to specific hardware with board detection done at
@@ -15,7 +16,10 @@ 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.
[![Build Status](https://travis-ci.org/intel-iot-devkit/mraa.svg?branch=master)](https://travis-ci.org/intel-iot-devkit/mraa)
The MRAA project is joining the Eclipse Foundation as an Eclipse IoT project.
You can read more about this [here](https://projects.eclipse.org/proposals/eclipse-mraa).
[![Build Status](https://travis-ci.org/intel-iot-devkit/mraa.svg?branch=master)](https://travis-ci.org/intel-iot-devkit/mraa) [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=mraa-master&metric=alert_status)](https://sonarcloud.io/dashboard?id=mraa-master)
Supported Boards
================
@@ -26,55 +30,119 @@ X86
* [Galileo Gen 2 - Rev H](../master/docs/galileorevh.md)
* [Edison](../master/docs/edison.md)
* [Intel DE3815](../master/docs/intel_de3815.md)
* [Minnowboard Max](../master/docs/minnow_max.md)
* [Minnowboard](../master/docs/minnow_max.md)
* [NUC 5th generation](../master/docs/intel_nuc5.md)
* [UP](../master/docs/up.md)
* [Intel Grosse Tete](../master/docs/grossetete.md)
* [UP Squared](../master/docs/up2.md)
* [Intel Joule](../master/docs/joule.md)
* [IEI Tank](../master/docs/iei-tank.md)
* [ADLINK IPi-SMARC X86](../master/docs/adlink_ipi_x86.md)
* [UP Xtreme](../master/docs/up_xtreme.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)
* [ADLINK IPi-SMARC ARM](../master/docs/adlink_ipi_arm.md)
* [Rock Pi 4](../master/docs/rockpi4.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
========
========================
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!
Installing on Ubuntu
--------------------
``` bash
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
opkg update
opkg install mraa
```
If you would like to get the latest & greatest builds from master HEAD you can
use our -dev repository
Here is a PPA for installing on Ubuntu Xenial or Bionic:
https://launchpad.net/~mraa/+archive/ubuntu/mraa
```bash
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf
opkg update
opkg install mraa
sudo add-apt-repository ppa:mraa/mraa
sudo apt-get update
sudo apt-get install libmraa2 libmraa-dev libmraa-java python-mraa python3-mraa node-mraa mraa-tools
```
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.
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 or SLE
---------------------------
For the latest versions of openSUSE and SLE the project is distributed via
native repositories and can be installed by developers with:
```bash
npm install mraa
sudo zypper install mraa mraa-devel
```
For ARM boards use:
```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
```
A full list of packages and instructions for installing MRAA for various openSUSE releases
can be found [here](https://software.opensuse.org/package/mraa).
Install on Fedora Linux
-----------------------
There is an mraa package in the main Fedora repository so it can be dnf installed
in all recent Fedora releases. The Node.js and Python 3 bindings are packaged as
separate packages.
```bash
sudo dnf install mraa nodejs-mraa python3-mraa
```
Installing for Red Hat Enterprise Linux, CentOS and Other Linux Distributions
---------------------------
The MRAA project does not currently distribute official binaries for RHEL
or CentOS so developers will have to compile the project from sources as
described in the next section.
For testing and development purposes it may be possible to share and install
.deb and .rpm packages across similar Linux builds.
Compiling
=========

View File

@@ -19,6 +19,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -34,6 +36,7 @@ extern "C" {
#include "mraa/i2c.h"
#include "mraa/uart.h"
#include "mraa/uart_ow.h"
#include "mraa/led.h"
#ifdef __cplusplus
}

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -31,3 +33,4 @@
#include "mraa/i2c.hpp"
#include "mraa/spi.hpp"
#include "mraa/uart.hpp"
#include "mraa/led.hpp"

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -30,7 +32,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 +53,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

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -36,7 +38,7 @@ namespace mraa
*
* This file defines the aio interface for libmraa
*
* @snippet AioA0.cpp Interesting
* @snippet aio.cpp Interesting
*/
class Aio
{
@@ -56,9 +58,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)
{

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -27,13 +29,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 +52,17 @@
if (res != MRAA_SUCCESS) \
return res;} while(0)
/**
* Simple deprecated macro
*/
#ifdef __GNUC__
#define DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED
#endif
/** @file
*
@@ -85,7 +104,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.
@@ -106,7 +125,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);
@@ -121,7 +140,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);
@@ -146,7 +165,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);
@@ -201,6 +220,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();
/**
* 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();
/**
* 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();
/**
* 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();
/**
* 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_count();
/**
* Get platform usable I2C bus count, board must be initialised.
*
@@ -220,7 +274,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);
@@ -233,6 +287,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.
*
@@ -251,7 +345,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
*/
@@ -260,7 +354,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
*/
@@ -269,7 +363,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
*/
@@ -278,17 +372,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
*/
@@ -301,7 +395,7 @@ 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
*/
@@ -310,7 +404,7 @@ void* mraa_init_io(const char* desc);
/**
* Instantiate an unknown board using a json file
*
* @param Path to the json file, relative to the folder the program
* @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

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -27,6 +29,8 @@
#include "common.h"
#include "types.hpp"
#include <string>
#include <sstream>
#include <stdexcept>
/**
* @namespace mraa namespace
@@ -97,7 +101,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)
@@ -141,27 +145,31 @@ adcSupportedBits()
}
/**
* Return Platform Name. Returns NULL if no platform inited.
* Return platform name.
*
* @return platform name
* @return platform name or empty string if not initialised
*/
inline std::string
getPlatformName()
{
std::string ret_val(mraa_get_platform_name());
std::string ret_val;
const char * pn = mraa_get_platform_name();
if (pn) ret_val = pn;
return ret_val;
}
/**
* Return platform versioning info. Returns NULL if no info present.
* Return platform versioning info.
*
* @param optional subplatform identifier
* @return platform versioning info
* @param platform_offset optional subplatform identifier
* @return platform versioning info or empty string if no info is present
*/
inline std::string
getPlatformVersion(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
{
std::string ret_val(mraa_get_platform_version(platform_offset));
std::string ret_val;
const char* pv = mraa_get_platform_version(platform_offset);
if (pv) ret_val = pv;
return ret_val;
}
@@ -176,6 +184,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.
*
@@ -205,15 +225,122 @@ getI2cBusId(int i2c_bus)
*
* @param pin number
*
* @return char* of pin name
* @return Pin name or empty string on failure
*/
inline std::string
getPinName(int pin)
{
std::string ret_val(mraa_get_pin_name(pin));
std::string ret_val;
const char* pn = mraa_get_pin_name(pin);
if (pn) ret_val = pn;
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 +368,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 +381,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 +394,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 +407,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 +420,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 +450,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
*/
@@ -330,7 +464,7 @@ initIo(std::string desc)
/**
* Instantiate an unknown board using a json file
*
* @param Path to the json file, relative to the folder the program
* @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

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -52,7 +54,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);

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -33,7 +35,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 +48,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
/**
@@ -63,7 +63,10 @@ typedef enum {
MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
MRAA_GPIO_PULLUP = 1, /**< Resistive High */
MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
MRAA_GPIO_HIZ = 3 /**< High Z State */
MRAA_GPIO_HIZ = 3, /**< High Z State */
MRAA_GPIOD_ACTIVE_LOW = 4,
MRAA_GPIOD_OPEN_DRAIN = 5,
MRAA_GPIOD_OPEN_SOURCE = 6,
} mraa_gpio_mode_t;
/**
@@ -86,6 +89,35 @@ 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;
typedef long long unsigned int mraa_timestamp_t;
/**
* Gpio event object
*/
typedef struct {
int id; /**< id of event */
mraa_timestamp_t timestamp; /**< timestamp */
} mraa_gpio_event;
typedef mraa_gpio_event* mraa_gpio_events_t;
/**
* Initialise gpio_context, based on board number
*
@@ -94,6 +126,24 @@ typedef enum {
*/
mraa_gpio_context mraa_gpio_init(int pin);
/**
* Initialise gpio_context, based on gpio line name
*
* @param name GPIO line name, i.e GPIO-A
* @returns gpio context or NULL
*/
mraa_gpio_context mraa_gpio_init_by_name(char* name);
/**
* Initialise gpio_context, based on board number, for multiple pins (can be one).
*
* @param pins Pin array read from the board
* @param num_pins Number of pins - must be the same as the pins array length provided
* as the first argument.
* @returns gpio context or NULL
*/
mraa_gpio_context mraa_gpio_init_multi(int pins[], int num_pins);
/**
* Initialise gpio context without any mapping to a pin
*
@@ -112,10 +162,10 @@ mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
/**
* Set an interrupt on pin
* Set an interrupt on pin(s).
*
* @param dev The Gpio context
* @param edge The edge mode to set the gpio into
* @param edge The edge mode to set the gpio(s) into
* @param fptr Function pointer to function to be called when interrupt is
* triggered
* @param args Arguments passed to the interrupt handler (fptr)
@@ -123,9 +173,19 @@ mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
*/
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (*fptr)(void*), void* args);
/**
* Get an array of structures describing triggered events.
*
* @param dev The Gpio context
* @return Array of structures containing pairs of pin id's and the associated timestamp.
* An event with negative id value indicates that no event was triggered for the respective pin.
* The array length is that of the number of pins provided in mraa_gpio_init_multi().
*/
mraa_gpio_events_t mraa_gpio_get_events(mraa_gpio_context dev);
/**
* Stop the current interrupt watcher on this Gpio, and set the Gpio edge mode
* to MRAA_GPIO_EDGE_NONE
* to MRAA_GPIO_EDGE_NONE(only for sysfs interface).
*
* @param dev The Gpio context
* @return Result of operation
@@ -133,35 +193,36 @@ mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (
mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
/**
* Set Gpio Output Mode,
* Set Gpio(s) Output Mode,
*
* @param dev The Gpio context
* @param mode The Gpio Output Mode
* @param mode The Gpio(s) Output Mode
* @return Result of operation
*/
mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode);
/**
* Set Gpio direction
* Set Gpio(s) direction
*
* @param dev The Gpio context
* @param dir The direction of the Gpio
* @param dir The direction of the Gpio(s)
* @return Result of operation
*/
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir);
/**
* Read Gpio direction
* Read Gpio(s) direction
*
* @param dev The Gpio context
* @param dir The address where to store the Gpio direction
* @param dir The address where to store the Gpio(s) direction
* @return Result of operation
*/
mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir);
/**
* Close the Gpio context
* - Will free the memory for the context and unexport the Gpio
* - Will free the memory for the context and unexport the Gpio - sysfs interface.
* - Will free up the memory used by context and close related file descriptors - chardev interface.
*
* @param dev The Gpio context
* @return Result of operation
@@ -177,6 +238,16 @@ mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
*/
int mraa_gpio_read(mraa_gpio_context dev);
/**
* Read the Gpio(s) value. The user must provide an integer array with a length equal to the
* number of pins provided to mraa_gpio_init_multi() function.
*
* @param dev The Gpio context
* @param output_values The array provided by the user. Existing values will be overwritten with the newly read ones.
* @return Result of operation
*/
mraa_result_t mraa_gpio_read_multi(mraa_gpio_context dev, int output_values[]);
/**
* Write to the Gpio Value.
*
@@ -186,6 +257,17 @@ int mraa_gpio_read(mraa_gpio_context dev);
*/
mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
/**
* Write to the Gpio(s) Value. The user must provide an integer array with a length equal to the
* number of pins provided to mraa_gpio_init_multi() function.
*
* @param dev The Gpio context
* @param output_values The array provided by the user. It must contain the values intended to be written
* to the gpio pins, in the same order as the init function.
* @return Result of operation
*/
mraa_result_t mraa_gpio_write_multi(mraa_gpio_context dev, int input_values[]);
/**
* Change ownership of the context.
*
@@ -196,13 +278,15 @@ mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
/**
* Enable using memory mapped io instead of sysfs
* Enable using memory mapped io instead of sysfs, chardev based I/O can be
* considered memorymapped
*
* @deprecated
* @param dev The Gpio context
* @param mmap Use mmap instead of sysfs
* @return Result of operation
*/
mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
/**
* Get a pin number of the gpio, invalid will return -1
@@ -220,6 +304,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

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -69,12 +71,28 @@ 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
*
* This file defines the gpio interface for libmraa
*
* @snippet Blink-IO.cpp Interesting
* @snippet gpio.cpp Interesting
*/
class Gpio
{
@@ -111,7 +129,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 +334,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 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)

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -32,7 +34,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

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -38,14 +40,14 @@ namespace mraa
* selecting the correct address
* @htmlinclude i2c.txt
*
* @snippet I2c-compass.cpp Interesting
* @snippet i2c.cpp Interesting
*/
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 +67,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 +78,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.
*/

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -27,22 +29,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 +69,7 @@ typedef struct {
*
* An iio context represents an IIO device
*
* @snippet iio_driver.c Interesting
* @snippet iio.c Interesting
*/
#ifdef __cplusplus
@@ -74,44 +91,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 +265,32 @@ mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
int* channel2,
int* different);
/**
* 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
*

View File

@@ -20,33 +20,46 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <stdexcept>
#include <sstream>
#include "iio.h"
#include "types.hpp"
#include <sstream>
#include <stdexcept>
namespace mraa
{
struct IioEventData
{
/** 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:
virtual void onIioEvent(const IioEventData& eventData) = 0;
public:
/** onIioEvent Handler */
virtual void onIioEvent(const IioEventData& eventData) = 0;
/** Destructor */
virtual ~IioHandler(){}; // add an empty destructor to get rid of warning
};
@@ -55,7 +68,7 @@ public:
*
* This file defines the C++ iio interface for libmraa
*
* @snippet iio_dummy_test.cpp Interesting
* @snippet iio.cpp Interesting
*/
class Iio
{
@@ -100,6 +113,19 @@ class Iio
}
}
/**
* IIO constructor, takes a pointer to a IIO context and initialises the IIO class
*
* @param iio_context void * to an IIO context
*/
Iio(void* iio_context)
{
m_iio = (mraa_iio_context) iio_context;
if (m_iio == NULL) {
throw std::invalid_argument("Invalid IIO context");
}
}
/**
* Iio destructor
*/
@@ -181,7 +207,6 @@ class Iio
oss << "IIO writeInt for attibute " << attributeName << " failed";
throw std::runtime_error(oss.str());
}
}
/**
@@ -201,7 +226,6 @@ class Iio
oss << "IIO writeFloat for attibute " << attributeName << " failed";
throw std::runtime_error(oss.str());
}
}
/**
@@ -221,13 +245,15 @@ class Iio
}
private:
static void private_event_handler(iio_event_data* data, void *args)
static void
private_event_handler(iio_event_data* data, void* args)
{
if (args != NULL) {
IioHandler* handler = (IioHandler*)args;
IioHandler* handler = (IioHandler*) args;
IioEventData eventData;
int chan_type, modifier, type, direction, channel, channel2, different;
mraa_iio_event_extract_event(data, &chan_type, &modifier, &type, &direction, &channel, &channel2, &different);
mraa_iio_event_extract_event(data, &chan_type, &modifier, &type, &direction, &channel,
&channel2, &different);
eventData.channelType = chan_type;
eventData.modifier = modifier;
eventData.type = type;
@@ -241,5 +267,4 @@ class Iio
mraa_iio_context m_iio;
};
}

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
//For kernel 4.1+,
@@ -115,12 +117,11 @@ enum iio_event_direction {
/**
* 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;
};

157
api/mraa/initio.h Normal file
View File

@@ -0,0 +1,157 @@
/*
* Author: Noel Eck <noel.eck@intel.com>
* Copyright (c) 2014-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
/**
* @file
* @brief I/O initializer
*
* initio allows for string initialization of mraa resources.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "aio.h"
#include "gpio.h"
#include "i2c.h"
#if !defined(PERIPHERALMAN)
#include "iio.h"
#endif
#include "pwm.h"
#include "spi.h"
#include "uart.h"
#include "uart_ow.h"
typedef struct _mraa_io_descriptor {
int n_aio;
mraa_aio_context* aios;
int n_gpio;
mraa_gpio_context* gpios;
int n_i2c;
mraa_i2c_context* i2cs;
#if !defined(PERIPHERALMAN)
int n_iio;
mraa_iio_context* iios;
#endif
int n_pwm;
mraa_pwm_context* pwms;
int n_spi;
mraa_spi_context* spis;
int n_uart;
mraa_uart_context* uarts;
int n_uart_ow;
mraa_uart_ow_context* uart_ows;
char* leftover_str;
} mraa_io_descriptor;
/**
* Initialize a structure of MRAA context elements given a description string.
*
* @param strdesc of one or more MRAA IO
* io:io_ndx[:option_0:option_1:option_2:option_n][,io:io_ndx]
*
* AIO
* AIO_KEY:aio pin[:num_bits]
*
* examples:
* a:13 # aio 13
* a:13:10 # aio 13, 10 bits
*
* GPIO
* GPIO_KEY:gpio pin[:dir:value:mode:edge:input:driver]
*
* examples:
* g:13:input # gpio 13, input
* g:13:0:output # gpio 13, value 0, output
*
* I2C
* I2C_KEY:i2c bus[:address:mode]
*
* examples:
* i:1:std # i2c bus 1, STD speed (100 KHz)
* i:1:16 # i2c bus 1, address 16
* i:0x1:0x10 # i2c bus 1, address 16
*
* IIO
* IIO_KEY:iio device
*
* examples:
* ii:1 # iio device 1
* ii:0x1 # iio device 1
*
* PWM
* PWM_KEY:pwm pin
*
* examples:
* p:1 # pwm pin 1
* p:0x1 # pwm pin 1
*
* SPI
* SPI_KEY:spi bus[:mode:frequency]
*
* examples:
* s:1 # spi bus 1
* s:0x1:mode2:400000 # spi bus 1, mode2 (CPOL = 1, CPHA = 0), 400 KHz
*
* UART
* UART_KEY:uart ndx[:baud:mode]
*
* examples:
* u:1 # uart bus 1
* u:0x1:9600:8N1 # uart bus 1, 9600 baud, 8 bit byte, no parity, 1 stop bit
*
* UART_OW
* UART_OW_KEY:uart_ow ndx
*
* examples:
* ow:1 # uart_ow bus 1
* ow:0x1 # uart_ow bus 1
*
*
* @param desc Pointer to structure containing number/pointer collections for initialized IO.
* @return Result of operation
*/
mraa_result_t mraa_io_init(const char* strdesc, mraa_io_descriptor** desc);
/**
* Free and close resources used by mraa_io_descriptor structure.
*
* @param desc mraa_io_descriptor structure
* @return Result of operation
*/
mraa_result_t mraa_io_close(mraa_io_descriptor* desc);
#ifdef __cplusplus
}
#endif

180
api/mraa/initio.hpp Normal file
View File

@@ -0,0 +1,180 @@
/*
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
* Copyright (c) 2018 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include "initio.h"
#include <stdexcept>
#include <string>
#include <vector>
#include "aio.hpp"
#include "gpio.hpp"
#include "i2c.hpp"
#if !defined(PERIPHERALMAN)
#include "iio.hpp"
#endif
#include "pwm.hpp"
#include "spi.hpp"
#include "uart.hpp"
#include "uart_ow.hpp"
namespace mraa
{
class MraaIo
{
private:
mraa_io_descriptor* descs = nullptr;
public:
MraaIo(const std::string& initStr) : descs()
{
if (mraa_io_init(initStr.c_str(), &descs) != MRAA_SUCCESS) {
throw std::runtime_error("mraa_io_init error");
}
aios.reserve(descs->n_aio);
for (int i = 0; i < descs->n_aio; ++i) {
aios.emplace_back(descs->aios[i]);
}
gpios.reserve(descs->n_gpio);
for (int i = 0; i < descs->n_gpio; ++i) {
gpios.emplace_back(descs->gpios[i]);
}
i2cs.reserve(descs->n_i2c);
for (int i = 0; i < descs->n_i2c; ++i) {
i2cs.emplace_back(descs->i2cs[i]);
}
#if !defined(PERIPHERALMAN)
iios.reserve(descs->n_iio);
for (int i = 0; i < descs->n_iio; ++i) {
iios.emplace_back(descs->iios[i]);
}
#endif
pwms.reserve(descs->n_pwm);
for (int i = 0; i < descs->n_pwm; ++i) {
pwms.emplace_back(descs->pwms[i]);
}
spis.reserve(descs->n_spi);
for (int i = 0; i < descs->n_spi; ++i) {
spis.emplace_back(descs->spis[i]);
}
uarts.reserve(descs->n_uart);
for (int i = 0; i < descs->n_uart; ++i) {
uarts.emplace_back(descs->uarts[i]);
}
uart_ows.reserve(descs->n_uart_ow);
for (int i = 0; i < descs->n_uart_ow; ++i) {
uart_ows.emplace_back(descs->uart_ows[i]);
}
if (descs->leftover_str) {
leftoverStr = std::string(descs->leftover_str);
} else {
leftoverStr = std::string("");
}
}
MraaIo() : descs() {}
~MraaIo()
{
if (descs != nullptr) {
if (descs->leftover_str) {
free(descs->leftover_str);
}
if (descs->n_aio) {
free(descs->aios);
}
if (descs->n_gpio) {
free(descs->gpios);
}
if (descs->n_i2c) {
free(descs->i2cs);
}
#if !defined(PERIPHERALMAN)
if (descs->n_iio) {
free(descs->iios);
}
#endif
if (descs->n_pwm) {
free(descs->pwms);
}
if (descs->n_spi) {
free(descs->spis);
}
if (descs->n_uart) {
free(descs->uarts);
}
if (descs->n_uart_ow) {
free(descs->uart_ows);
}
/* Finally free the mraa_io_descriptor structure. */
free(descs);
}
}
public:
std::vector<Aio> aios;
std::vector<Gpio> gpios;
std::vector<I2c> i2cs;
#if !defined(PERIPHERALMAN)
std::vector<Iio> iios;
#endif
std::vector<Pwm> pwms;
std::vector<Spi> spis;
std::vector<Uart> uarts;
std::vector<UartOW> uart_ows;
private:
/* Used exclusively by the UPM library. */
std::string leftoverStr;
public:
/* This is used mainly by sensors that use C structs/functions in C++ code. */
mraa_io_descriptor*
getMraaDescriptors()
{
return descs;
}
std::string
getLeftoverStr()
{
return leftoverStr;
}
};
}

122
api/mraa/led.h Normal file
View File

@@ -0,0 +1,122 @@
/*
* 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.
*
* SPDX-License-Identifier: MIT
*/
#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 index.
*
* @param led ID of the LED
* @returns LED context or NULL
*/
mraa_led_context mraa_led_init(int led);
/**
* 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_raw("user4");`
*
* @param led_dev Name of the LED device
* @returns LED context or NULL
*/
mraa_led_context mraa_led_init_raw(const char* led_dev);
/**
* 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

156
api/mraa/led.hpp Normal file
View File

@@ -0,0 +1,156 @@
/*
* 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.
*
* SPDX-License-Identifier: MIT
*/
#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
*
* @snippet led.cpp Interesting
*/
class Led
{
public:
/**
* Instantiates an LED object
*
* @param led LED index to use
*/
Led(int led)
{
m_led = mraa_led_init(led);
if (m_led == NULL) {
throw std::invalid_argument("Invalid LED name specified");
}
}
/**
* Instantiates an LED object
*
* @param led_dev LED function name to use
*/
Led(std::string led_dev)
{
m_led = mraa_led_init_raw(led_dev.c_str());
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;
};
}

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -33,7 +35,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 +47,7 @@ extern "C" {
#include "common.h"
/** Mraa Pwm Context */
typedef struct _pwm* mraa_pwm_context;
/**

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -36,7 +38,7 @@ namespace mraa
*
* This file defines the PWM interface for libmraa
*
* @snippet Pwm3-cycle.cpp Interesting
* @snippet pwm.cpp Interesting
*/
class Pwm
{
@@ -71,7 +73,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)
{

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -34,7 +36,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

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -51,7 +53,7 @@ typedef enum {
*
* This file defines the SPI interface for libmraa
*
* @snippet Spi-pot.cpp Interesting
* @snippet spi.cpp Interesting
*/
class Spi
{
@@ -70,6 +72,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 +91,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)
{

View File

@@ -19,6 +19,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -46,23 +48,46 @@ typedef enum {
MRAA_BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
MRAA_BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
MRAA_INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */
MRAA_96BOARDS = 9, /**< Linaro 96boards */
MRAA_96BOARDS = 9, /**< Linaro 96boards */
MRAA_INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
MRAA_UP = 12, /**< The UP Board */
MRAA_INTEL_GT_TUCHUCK = 13, /**< The Intel GT Tuchuck Board */
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
MRAA_UP = 12, /**< The UP Board */
MRAA_INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
#if __STDC_VERSION__ >= 199901L
MRAA_INTEL_GT_TUCHUCK = MRAA_INTEL_JOULE_EXPANSION, // deprecated
#endif
MRAA_PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
MRAA_DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
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 */
MRAA_IEI_TANK = 19, /**< IEI Tank System*/
MRAA_ROCKPI4 = 20, /**< Radxa ROCK PI 4 Models A/B/C */
MRAA_ADLINK_IPI = 21, /**< Adlink Industrial PI */
MRAA_ADLINK_LEC_AL = 22, /**< Adlink LEC-AL*/
MRAA_ADLINK_LEC_AL_AI = 23, /**< Adlink LEC-AL*/
MRAA_UPXTREME = 24, /**< The UPXTREME Board */
MRAA_ROCKPIS = 25, /**< Radxa ROCK PI S Board */
MRAA_ROCKPIN10 = 26, /**< Radxa ROCK PI N 10 Board */
MRAA_ROCKPIE = 27, /**< Radxa ROCK PI E V1.2 */
MRAA_ROCKPIE_V11 = 28, /**< Radxa ROCK PI E V1.1 */
MRAA_ROCKPIX = 29, /**< Radxa ROCK PI X V1.4 */
MRAA_RADXA_ZERO = 30, /**< Radxa Zero V1.3 */
MRAA_RADXA_ROCK_3_MODEL_A = 31, /**< Radxa ROCK3A V1.3 */
MRAA_RADXA_CM3_IO = 32, /**< Radxa CM3 V1.3 */
MRAA_RADXA_ROCK_3_MODEL_C = 33, /**< Radxa ROCK 3C */
// 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_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;
/**
@@ -157,6 +182,39 @@ typedef enum {
MRAA_INTEL_EDISON_GP81 = 55
} mraa_intel_edison_t;
/**
* ROCKPI4 GPIO numbering enum
*/
typedef enum {
MRAA_ROCKPI4_GPIO71 = 3,
MRAA_ROCKPI4_GPIO72 = 5,
MRAA_ROCKPI4_GPIO75 = 7,
MRAA_ROCKPI4_GPIO148 = 8,
MRAA_ROCKPI4_GPIO147 = 10,
MRAA_ROCKPI4_GPIO146 = 11,
MRAA_ROCKPI4_GPIO131 = 12,
MRAA_ROCKPI4_GPIO150 = 13,
MRAA_ROCKPI4_GPIO149 = 15,
MRAA_ROCKPI4_GPIO154 = 16,
MRAA_ROCKPI4_GPIO156 = 18,
MRAA_ROCKPI4_GPIO40 = 19,
MRAA_ROCKPI4_GPIO39 = 21,
MRAA_ROCKPI4_GPIO157 = 22,
MRAA_ROCKPI4_GPIO41 = 23,
MRAA_ROCKPI4_GPIO42 = 24,
MRAA_ROCKPI4_GPIO64 = 27,
MRAA_ROCKPI4_GPIO65 = 28,
MRAA_ROCKPI4_GPIO74 = 29,
MRAA_ROCKPI4_GPIO73 = 31,
MRAA_ROCKPI4_GPIO112 = 32,
MRAA_ROCKPI4_GPIO76 = 33,
MRAA_ROCKPI4_GPIO133 = 35,
MRAA_ROCKPI4_GPIO132 = 36,
MRAA_ROCKPI4_GPIO158 = 37,
MRAA_ROCKPI4_GPIO134 = 38,
MRAA_ROCKPI4_GPIO135 = 40
} mraa_rockpi4_t;
/**
* Raspberry PI Wiring compatible numbering enum
*/
@@ -239,12 +297,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

View File

@@ -19,6 +19,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -51,15 +53,25 @@ typedef enum {
INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
INTEL_UP = 12, /**< The UP Board */
INTEL_GT_TUCHUCK = 13, /**< The Intel GT Board */
INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
INTEL_UP2 = 16, /**< The UP^2 Board */
MTK_LINKIT = 17, /**< Mediatek MT7688 based Linkit boards */
MTK_OMEGA2 = 18, /**< MT7688 based Onion Omega2 board */
IEI_TANK = 19, /**< IEI Tank System*/
ROCKPI4 = 20, /**< Radxa ROCK PI 4 Models A/B/C */
INTEL_UPXTREME = 24, /**< The UPXTREME 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 */
MOCK_PLATFORM = 96, /**< Mock platform, which requires no real hardware */
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;
/**
@@ -190,6 +202,39 @@ typedef enum {
RASPBERRY_WIRING_PIN29 = 40
} RaspberryWiring;
/**
* ROCKPI4 GPIO numbering enum
*/
typedef enum {
ROCKPI4_GPIO71 = 3,
ROCKPI4_GPIO72 = 5,
ROCKPI4_GPIO75 = 7,
ROCKPI4_GPIO148 = 8,
ROCKPI4_GPIO147 = 10,
ROCKPI4_GPIO146 = 11,
ROCKPI4_GPIO131 = 12,
ROCKPI4_GPIO150 = 13,
ROCKPI4_GPIO149 = 15,
ROCKPI4_GPIO154 = 16,
ROCKPI4_GPIO156 = 18,
ROCKPI4_GPIO40 = 19,
ROCKPI4_GPIO39 = 21,
ROCKPI4_GPIO157 = 22,
ROCKPI4_GPIO41 = 23,
ROCKPI4_GPIO42 = 24,
ROCKPI4_GPIO64 = 27,
ROCKPI4_GPIO65 = 28,
ROCKPI4_GPIO74 = 29,
ROCKPI4_GPIO73 = 31,
ROCKPI4_GPIO112 = 32,
ROCKPI4_GPIO76 = 33,
ROCKPI4_GPIO133 = 35,
ROCKPI4_GPIO132 = 36,
ROCKPI4_GPIO158 = 37,
ROCKPI4_GPIO134 = 38,
ROCKPI4_GPIO135 = 40
} RockPi4;
/**
* MRAA return codes
*/
@@ -228,7 +273,7 @@ typedef enum {
} Pinmodes;
/**
* Enum reprensenting different i2c speeds/modes
* Enum representing different i2c speeds/modes
*/
typedef enum {
I2C_STD = 0, /**< up to 100Khz */
@@ -236,6 +281,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,

View File

@@ -22,6 +22,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -45,6 +47,7 @@ extern "C" {
#include "common.h"
/** Mraa Uart Context */
typedef struct _uart* mraa_uart_context;
/**
@@ -72,6 +75,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 +151,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
*

View File

@@ -22,6 +22,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -40,7 +42,7 @@ namespace mraa
*
* This file defines the UART interface for libmraa
*
* @snippet Uart-example.cpp Interesting
* @snippet uart.cpp Interesting
*/
class Uart
{
@@ -64,7 +66,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 +81,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 +126,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 +162,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 +199,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 +275,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);
}

View File

@@ -20,6 +20,8 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
@@ -64,19 +66,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
*/

View File

@@ -20,14 +20,16 @@
* 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.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include "uart_ow.h"
#include "types.hpp"
#include <stdexcept>
#include "uart_ow.h"
#include <cstring>
#include <stdexcept>
namespace mraa
{
@@ -37,7 +39,7 @@ namespace mraa
*
* This file defines the UartOW (UART to Dallas 1-wire) interface for libmraa
*
* @snippet UartOW.cpp Interesting
* @snippet uart_ow.cpp Interesting
*/
class UartOW
{
@@ -46,8 +48,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 +64,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)
{
@@ -74,6 +76,21 @@ class UartOW
}
}
/**
* UartOW Constructor, takes a pointer to the UartOW context and initialises
* the UartOW class
*
* @param uart_ow_context void * to a UartOW context
*/
UartOW(void* uart_ow_context)
{
m_uart = (mraa_uart_ow_context) uart_ow_context;
if (m_uart == NULL) {
throw std::invalid_argument("Invalid UART_OW context");
}
}
/**
* Uart destructor
*/
@@ -233,7 +250,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 +258,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 +285,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:

View File

@@ -0,0 +1,14 @@
This directory used to contain an OE-Toolchain file. A far better one is now included
with Devtool/OE-SDK.
https://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake
The following may be interesting for certain Java/Cross-compilation reasons:
```
# for Cmake java
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)
```

View File

@@ -1,25 +0,0 @@
# this toolchain file comes from gnuradio project
set( CMAKE_SYSTEM_NAME Linux )
#set( CMAKE_C_COMPILER $ENV{CC} )
#set( CMAKE_CXX_COMPILER $ENV{CXX} )
string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT})
string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE )
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources
set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib )
set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
set( CMAKE_INSTALL_PREFIX $ENV{OECORE_TARGET_SYSROOT}/usr CACHE STRING "" FORCE)
set( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 )
set( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib )
# for java
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)

View File

@@ -1,222 +0,0 @@
# - The builtin (binary) CPack Deb generator (Unix only)
# CPackDeb may be used to create Deb package using CPack.
# CPackDeb is a CPack generator thus it uses the CPACK_XXX variables
# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration
#
# However CPackRPM has specific features which are controlled by
# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on
# the wiki:
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
# However as a handy reminder here comes the list of specific variables:
#
# CPACK_DEBIAN_PACKAGE_NAME
# Mandatory : YES
# Default : CPACK_PACKAGE_NAME (lower case)
# The debian package summary
# CPACK_DEBIAN_PACKAGE_VERSION
# Mandatory : YES
# Default : CPACK_PACKAGE_VERSION
# The debian package version
# CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# Mandatory : YES
# Default : Output of dpkg --print-architecture or i386
# The debian package architecture
# CPACK_DEBIAN_PACKAGE_DEPENDS
# Mandatory : NO
# Default : -
# May be used to set deb dependencies.
# CPACK_DEBIAN_PACKAGE_MAINTAINER
# Mandatory : YES
# Default : CPACK_PACKAGE_CONTACT
# The debian package maintainer
# CPACK_DEBIAN_PACKAGE_DESCRIPTION
# Mandatory : YES
# Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY
# The debian package description
# CPACK_DEBIAN_PACKAGE_SECTION
# Mandatory : YES
# Default : 'devel'
# The debian package section
# CPACK_DEBIAN_PACKAGE_PRIORITY
# Mandatory : YES
# Default : 'optional'
# The debian package priority
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
# CPack script for creating Debian package
# Author: Mathieu Malaterre
#
# http://wiki.debian.org/HowToPackageForDebian
IF(CMAKE_BINARY_DIR)
MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
ENDIF(CMAKE_BINARY_DIR)
IF(NOT UNIX)
MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
ENDIF(NOT UNIX)
# Let's define the control file found in debian package:
# Binary package:
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
# DEBIAN/control
# debian policy enforce lower case for package name
# Package: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
# Version: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
IF(NOT CPACK_PACKAGE_VERSION)
MESSAGE(FATAL_ERROR "Debian package requires a package version")
ENDIF(NOT CPACK_PACKAGE_VERSION)
SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
# Architecture: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# There is no such thing as i686 architecture on debian, you should use i386 instead
# $ dpkg --print-architecture
FIND_PROGRAM(DPKG_CMD dpkg)
IF(NOT DPKG_CMD)
MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
ENDIF(NOT DPKG_CMD)
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# have a look at GET_PROPERTY(result GLOBAL PROPERTY ENABLED_FEATURES),
# this returns the successful FIND_PACKAGE() calls, maybe this can help
# Depends:
# You should set: DEBIAN_PACKAGE_DEPENDS
# TODO: automate 'objdump -p | grep NEEDED'
IF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
MESSAGE(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
# Maintainer: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
IF(NOT CPACK_PACKAGE_CONTACT)
MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
ENDIF(NOT CPACK_PACKAGE_CONTACT)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
# Description: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
# Section: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
# Priority: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
# Recommends:
# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
# Suggests:
# You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
# Typical examples are:
# - conffiles
# - postinst
# - postrm
# - prerm"
# Usage:
# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
# For debian source packages:
# debian/control
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
# .dsc
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
# Builds-Depends:
#IF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
# SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
# "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
# )
#ENDIF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
# Description: (mandatory)
#if(NOT CPACK_SECTION)
# message(FATAL_ERROR "opkg package requires a package section")
#endif(NOT CPACK_SECTION)
# Package for opkg
FIND_PROGRAM(OPKG_CMD opkg-build)
if( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )
message("CPack: opkg-build not found. Skipping packaging")
else( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )
SET(CPACK_OPKG_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
FILE(MAKE_DIRECTORY ${CPACK_OPKG_ROOTDIR}/CONTROL)
set(CPACK_OPKG_CONTROL_FILE "${CPACK_OPKG_ROOTDIR}/CONTROL/control")
# Write controlfile
FILE(WRITE ${CPACK_OPKG_CONTROL_FILE}
"Package: ${CPACK_PACKAGE_NAME}
Version: ${CPACK_PACKAGE_VERSION}
Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}
Section: ${CPACK_DEBIAN_PACKAGE_SECTION}
Priority: optional
Maintainer: ${CPACK_DEBIAN_PACKAGE_MAINTAINER}
Depends:
Provides: ${CPACK_DEBIAN_PACKAGE_PROVIDES}
Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES}
Conflicts: ${CPACK_DEBIAN_PACKAGE_CONFLICTS}
Source: https://github.com/intel-iot-devkit/mraa
#Essential: no
")
set(OPKG_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
execute_process(
COMMAND "${OPKG_CMD}" "-o" "0" "${CPACK_PACKAGE_FILE_NAME}" "."
RESULT_VARIABLE _result
OUTPUT_VARIABLE _res_output
ERROR_VARIABLE _res_error
WORKING_DIRECTORY ${CPACK_TOPLEVEL_DIRECTORY}
)
if(${_result})
message("Result '${_result}'")
message("Output '${_res_output}'")
message("Error '${_res_error}'")
else(${_result})
message("CPack: Package ${OPKG_FILE_NAME}.ipk generated.")
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
file(RENAME ${CPACK_TOPLEVEL_DIRECTORY}/${OPKG_FILE_NAME}.ipk ${CPACK_BINARY_DIR}/${OPKG_FILE_NAME}.ipk)
endif(${_result})
endif( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )

View File

@@ -14,6 +14,8 @@
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# SPDX-License-Identifier: BSD-3-Clause
if (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
# in cache already
@@ -27,11 +29,11 @@ else (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
/usr/local/include
/opt/local/include
/sw/include
)
)
SET(FTD2XX_LIBNAME ftd2xx)
IF(WIN32)
SET(FTD2XX_LIBNAME ftd2xx.lib)
SET(FTD2XX_LIBNAME ftd2xx.lib)
ENDIF(WIN32)
find_library(LIBFTD2XX_LIBRARY
@@ -42,16 +44,16 @@ else (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
/usr/local/lib
/opt/local/lib
/sw/lib
)
)
if(LIBFTD2XX_INCLUDE_DIR)
set(LIBFTD2XX_INCLUDE_DIRS
set(LIBFTD2XX_INCLUDE_DIRS
${LIBFTD2XX_INCLUDE_DIR}
)
)
endif(LIBFTD2XX_INCLUDE_DIR)
set(LIBFTD2XX_LIBRARIES
${LIBFTD2XX_LIBRARY}
)
)
if (LIBFTD2XX_INCLUDE_DIRS AND LIBFTD2XX_LIBRARIES)
set(LIBFTD2XX_FOUND TRUE)
@@ -59,14 +61,17 @@ else (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
if (LIBFTD2XX_FOUND)
if (NOT libftd2xx_FIND_QUIETLY)
message(STATUS "Found libftd2xx: ${LIBFTD2XX_LIBRARIES}")
message(STATUS "Found libftd2xx: ${LIBFTD2XX_LIBRARIES}")
endif (NOT libftd2xx_FIND_QUIETLY)
else (LIBFTD2XX_FOUND)
if (libftd2xx_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libftd2xx")
message(FATAL_ERROR "Could not find libftd2xx")
endif (libftd2xx_FIND_REQUIRED)
endif (LIBFTD2XX_FOUND)
find_package_handle_standard_args(Ftd2xx
REQUIRED_VARS LIBFTD2XX_INCLUDE_DIRS)
# show the LIBFTD2XX_INCLUDE_DIRS and LIBFTD2XX_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBFTD2XX_INCLUDE_DIRS LIBFTD2XX_LIBRARIES)

View File

@@ -15,6 +15,8 @@
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# SPDX-License-Identifier: BSD-3-Clause
if (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
# in cache already
@@ -28,11 +30,11 @@ else (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
/usr/local/include
/opt/local/include
/sw/include
)
)
SET(FTD4222_LIBNAME ft4222)
IF(WIN32)
SET(FTD4222_LIBNAME LibFT4222.lib)
SET(FTD4222_LIBNAME LibFT4222.lib)
ENDIF(WIN32)
find_library(LIBFT4222_LIBRARY
@@ -43,16 +45,16 @@ else (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
/usr/local/lib
/opt/local/lib
/sw/lib
)
)
if(LIBFT4222_INCLUDE_DIR)
set(LIBFT4222_INCLUDE_DIRS
set(LIBFT4222_INCLUDE_DIRS
${LIBFT4222_INCLUDE_DIR}
)
)
endif(LIBFT4222_INCLUDE_DIR)
set(LIBFT4222_LIBRARIES
${LIBFT4222_LIBRARY}
)
)
if (LIBFT4222_INCLUDE_DIRS AND LIBFT4222_LIBRARIES)
set(LIBFT4222_FOUND TRUE)
@@ -60,14 +62,17 @@ else (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
if (LIBFT4222_FOUND)
if (NOT LIBFT4222_FIND_QUIETLY)
message(STATUS "Found LIBFT4222: ${LIBFT4222_LIBRARIES}")
message(STATUS "Found LIBFT4222: ${LIBFT4222_LIBRARIES}")
endif (NOT LIBFT4222_FIND_QUIETLY)
else (LIBFT4222_FOUND)
if (LIBFT4222_FIND_REQUIRED)
message(FATAL_ERROR "Could not find LIBFT4222")
message(FATAL_ERROR "Could not find LIBFT4222")
endif (LIBFT4222_FIND_REQUIRED)
endif (LIBFT4222_FOUND)
find_package_handle_standard_args(Ftd4222
REQUIRED_VARS LIBFT4222_INCLUDE_DIRS LIBFT4222_LIBRARIES)
# show the LIBFT4222_INCLUDE_DIRS and LIBFT4222_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBFT4222_INCLUDE_DIRS LIBFT4222_LIBRARIES)

View File

@@ -1,3 +1,6 @@
# Copyright (c) 2016 Intel Corporation
# SPDX-License-Identifier: MIT
# JSON-C_FOUND - true if library and headers were found
# JSON-C_INCLUDE_DIRS - include directories
# JSON-C_LIBRARIES - library directories

View File

@@ -1,66 +1,71 @@
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
macro(add_include_dir dir)
# Copyright (c) 2015 Intel Corporation
# SPDX-License-Identifier: MIT
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
macro(add_include_dir dir)
if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include")
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
endif()
endmacro()
find_program (NODEJS_EXECUTABLE NAMES node nodejs
HINTS
$ENV{NODE_DIR}
PATH_SUFFIXES bin
DOC "Node.js interpreter"
)
DOC "Node.js interpreter")
include (FindPackageHandleStandardArgs)
# If compat-libuv package exists, it must be at start of include path
find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH)
if (UV_ROOT_DIR)
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
add_include_dir(${UV_ROOT_DIR})
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
add_include_dir(${UV_ROOT_DIR})
endif()
# Now look for node. Flag an error if not found
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h"
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
find_path (NODE_ROOT_DIR
NAMES node.h src/node.h
PATH_SUFFIXES node node4 node5 node6 node7 node8 nodejs
PATHS /usr/include /usr/local/include)
message(STATUS "INFO - NODE_ROOT_DIR is ${NODE_ROOT_DIR}")
if (NODE_ROOT_DIR)
add_include_dir(${NODE_ROOT_DIR}/include/src)
add_include_dir(${NODE_ROOT_DIR}/include/node)
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
add_include_dir(${NODE_ROOT_DIR})
add_include_dir(${NODE_ROOT_DIR}/deps/uv/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}/include/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/include/node)
add_include_dir(${NODE_ROOT_DIR}/include/src)
add_include_dir(${NODE_ROOT_DIR}/src)
else()
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - node.h not found")
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - node.h not found")
endif()
# Check that v8.h is in NODEJS_INCLUDE_DIRS
find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
if (NOT V8_ROOT_DIR)
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - v8.h not found")
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - v8.h not found")
endif()
# Check that uv.h is in NODEJS_INCLUDE_DIRS
find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS})
if (NOT UV_ROOT_DIR)
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - uv.h not found")
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - uv.h not found")
endif()
find_package_handle_standard_args (Nodejs DEFAULT_MSG
NODEJS_EXECUTABLE
NODEJS_INCLUDE_DIRS
)
if (NODEJS_EXECUTABLE)
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _NODE_VERSION_RESULT)
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _NODE_VERSION_RESULT)
execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)"
OUTPUT_VARIABLE _V8_VERSION
RESULT_VARIABLE _V8_RESULT)
OUTPUT_VARIABLE _V8_VERSION
RESULT_VARIABLE _V8_RESULT)
if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT)
string (REPLACE "v" "" NODE_VERSION_STRING "${_VERSION}")
string (REPLACE "." ";" _VERSION_LIST "${NODE_VERSION_STRING}")
@@ -83,12 +88,15 @@ if (NODEJS_EXECUTABLE)
set (V8_VERSION_MINOR"14")
set (V8_VERSION_PATCH "5")
set (V8_VERSION_STRING "3.28.72")
message ("defaulted to node 0.10.30")
message (STATUS "defaulted to node 0.10.30")
endif ()
string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
message ("INFO - Node version is " ${NODE_VERSION_STRING})
message ("INFO - Node using v8 " ${V8_VERSION_STRING})
mark_as_advanced (NODEJS_EXECUTABLE)
endif ()
mark_as_advanced (NODEJS_EXECUTABLE)
find_package_handle_standard_args (Nodejs
REQUIRED_VARS NODEJS_EXECUTABLE NODEJS_INCLUDE_DIRS
VERSION_VAR NODE_VERSION_STRING)
message(STATUS "Found v8: ${V8_ROOT_DIR}/v8.h (found version \"${V8_VERSION_STRING}\")")
endif ()

View File

@@ -1,3 +1,6 @@
# Copyright (c) 2014 Intel Corporation
# SPDX-License-Identifier: MIT
find_program (SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
@@ -11,4 +14,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)

View File

@@ -1,3 +1,6 @@
# Copyright (c) 2016 Intel Corporation
# SPDX-License-Identifier: MIT
# UDEV_FOUND - true if library and headers were found
# UDEV_INCLUDE_DIRS - include directories
# UDEV_LIBRARIES - library directories

View File

@@ -1,3 +1,6 @@
# Copyright (c) 2015 Intel Corporation
# SPDX-License-Identifier: MIT
find_program (YUIDOC_EXECUTABLE NAMES yuidoc
HINTS $ENV{YUIDOC_DIR}
PATHS usr usr/local
@@ -14,8 +17,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)

View File

@@ -29,6 +29,8 @@
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0
if(__get_git_revision_description)
return()

View File

@@ -12,6 +12,8 @@
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0
set(HEAD_HASH)

View File

@@ -1,504 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,3 +1,6 @@
# From OpenCV Project
# SPDX-License-Identifier: BSD-3-Clause
#
# Find specified Python version
# Arguments:
# preferred_version (value): Version to check for first

View File

@@ -1,145 +0,0 @@
# Based on the Qt 5 processor detection code, so should be very accurate
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
# This file is under the terms of the GNU Lesser General Public License version
# 2.1 as published by the Free Software Foundation and appearing in the file
# LICENSE.LGPL included in the packaging of this file. Please review the
# following information to ensure the GNU Lesser General Public License version
# 2.1 requirements will be met:
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
# Regarding POWER/PowerPC, just as is noted in the Qt source,
# "There are many more known variants/revisions that we do not handle/detect."
set(archdetect_c_code "
#if defined(__aarch64__)
#error cmake_ARCH armv8
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM)
#if defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
#error cmake_ARCH armv7
#elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\
|| defined(__ARM_ARCH_6T2__) \\
|| defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
#error cmake_ARCH armv6
#elif defined(__ARM_ARCH_5TEJ__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
#error cmake_ARCH armv5
#else
#error cmake_ARCH arm
#endif
#elif defined(__i586) || defined(__i586__)
#error cmake_ARCH i586
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#error cmake_ARCH i386
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#error cmake_ARCH ia64
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#error cmake_ARCH ppc64
#else
#error cmake_ARCH ppc
#endif
#endif
#error cmake_ARCH unknown
")
# Set ppc_support to TRUE before including this file or ppc and ppc64
# will be treated as invalid architectures since they are no longer supported by Apple
function(target_architecture output_var)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
# First let's normalize the order of the values
# Note that it's not possible to compile PowerPC applications if you are using
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
# disable it by default
# See this page for more information:
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
set(osx_arch_ppc TRUE)
elseif("${osx_arch}" STREQUAL "i386")
set(osx_arch_i386 TRUE)
elseif("${osx_arch}" STREQUAL "x86_64")
set(osx_arch_x86_64 TRUE)
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
set(osx_arch_ppc64 TRUE)
else()
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
endif()
endforeach()
# Now add all the architectures in our normalized order
if(osx_arch_ppc)
list(APPEND ARCH ppc)
endif()
if(osx_arch_i386)
list(APPEND ARCH i386)
endif()
if(osx_arch_x86_64)
list(APPEND ARCH x86_64)
endif()
if(osx_arch_ppc64)
list(APPEND ARCH ppc64)
endif()
else()
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
enable_language(C)
# Detect the architecture in a rather creative way...
# This compiles a small C program which is a series of ifdefs that selects a
# particular #error preprocessor directive whose message string contains the
# target architecture. The program will always fail to compile (both because
# file is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in this
# way, we can detect the correct target architecture even when cross-compiling,
# since the program itself never needs to be run (only the compiler/preprocessor)
try_run(
run_result_unused
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/arch.c"
COMPILE_OUTPUT_VARIABLE ARCH
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)
# Parse the architecture name from the compiler output
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
# Get rid of the value marker leaving just the architecture name
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due
# to a typo in the code), then set it to unknown
if (NOT ARCH)
set(ARCH unknown)
endif()
endif()
set(${output_var} "${ARCH}" PARENT_SCOPE)
endfunction()

View File

@@ -1,3 +1,4 @@
// Auto-Generated file
#include "version.h"
const char* gVERSION = "@VERSION@";

158
docker-compose.yaml Normal file
View File

@@ -0,0 +1,158 @@
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}
- 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
minimal:
extends: base
environment:
- BUILDSWIG=OFF
- INSTALLTOOLS=OFF
- JSONPLAT=OFF
command: bash -c "./scripts/run-cmake.sh && cd build && make && ctest -R unit --output-on-failure"
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:
- USBPLAT=ON
- FTDI4222=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
python2:
extends: base
image: inteliotdevkit/mraa-python
environment:
- BUILDSWIG=ON
- BUILDSWIGPYTHON=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make _python2-mraa test_unit_all && ctest --output-on-failure"
python3:
extends: python2
environment:
- USEPYTHON3TESTS=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make _python3-mraa test_unit_all && 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 test_unit_all && 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

60
docs/96boards.md Normal file
View File

@@ -0,0 +1,60 @@
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
-------------
- [Bubblegum-96](http://www.96boards.org/product/bubblegum-96/)
- [DragonBoard 410c](http://www.96boards.org/product/dragonboard410c/)
- [DragonBoard 820c](http://www.96boards.org/product/dragonboard820c/)
- [HiKey](http://www.96boards.org/product/hikey/)
- [HiKey960](http://www.96boards.org/product/hikey960/)
- [Rock960](http://www.96boards.org/product/rock960/)
- [Ultra96](https://www.96boards.org/product/ultra96/)
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)

38
docs/adlink_ipi_arm.md Executable file
View File

@@ -0,0 +1,38 @@
ADLINK IPi-SMARC ARM
============
Based on Rockchip PX30 with Quad-core ARM Cortex-A35 CPU
Up to 4GB DDR3L at 1066/1333 MHz, 32 GB eMMC
4x USB 2.0, 1x USB 2.0 OTG port, 2x 10/100M Ethernet Ports, DSI to HDMI converter board, RTC and a 40-pin I/O header
## Pin Mapping
| Linux GPIO (/sys/class/gpio) | Function | MRAA number | MRAA number | Function | Linux GPIO (/sys/class/gpio) |
| :--------------------------: | :-------: | :---------: | :---------: | :-------: | :--------------------------: |
| | 3V3 | 1 | 2 | 5V | |
| | I2C_0 SDA | 3 | 4 | 5V | |
| | I2C_0 SCL | 5 | 6 | GND | |
| 116 | GPIO | 7 | 8 | UART TX | |
| | GND | 9 | 10 | UART RX | |
| 118 | GPIO | 11 | 12 | GPIO | 117 |
| 107 | GPIO | 13 | 14 | GND | |
| 104 | GPIO | 15 | 16 | GPIO | 109 |
| | 3V3 | 17 | 18 | GPIO | 121 |
| | SPI MOSI | 19 | 20 | GND | |
| | SPI MISO | 21 | 22 | GPIO | 122 |
| | SPI SCLK | 23 | 24 | SPI CS0 | |
| | GND | 25 | 26 | N/A | |
| | I2C_1 SDA | 27 | 28 | I2C_1 SCL | |
| 496 | GPIO/PWM | 29 | 30 | GND | |
| 497 | GPIO/PWM | 31 | 32 | GPIO/PWM | 498 |
| 499 | GPIO/PWM | 33 | 34 | GND | |
| 500 | GPIO/PWM | 35 | 36 | GPIO/PWM | 501 |
| 502 | GPIO/PWM | 37 | 38 | GPIO/PWM | 503 |
| | GND | 39 | 40 | GPIO/PWM | 504 |
**Note**: N/A: Funciton is not supported

56
docs/adlink_ipi_x86.md Executable file
View File

@@ -0,0 +1,56 @@
ADLINK IPi-SMARC x86
============
* ADLINK IPi-SMARC x86
Based on Intel(R) Atom® E3900 Series(codename: Apollo Lake) with Movidius chip
up to 8GB RAM, 64GB eMMC
2x USB 2.0, 2x USB 3.0, 1x USB 2.0 OTG port, 1x Gigabit Ethernet port, HDMI display, RTC and a 40-pin I/O header
## Pin Mapping
| Linux GPIO (/sys/class/gpio) | Function | MRAA number | MRAA number | Function | Linux GPIO (/sys/class/gpio) |
| :--------------------------: | :-------: | :---------: | :---------: | :-------: | :--------------------------: |
| | 3V3 | 1 | 2 | 5V | |
| | I2C_0 SDA | 3 | 4 | 5V | |
| | I2C_0 SCL | 5 | 6 | GND | |
| 255 | GPIO | 7 | 8 | UART TX | |
| | GND | 9 | 10 | UART RX | |
| 256 | GPIO | 11 | 12 | GPIO | 257 |
| 258 | GPIO | 13 | 14 | GND | |
| 259 | GPIO | 15 | 16 | GPIO | 260 |
| | 3V3 | 17 | 18 | GPIO | 261 |
| | n/a | 19 | 20 | GND | |
| | n/a | 21 | 22 | GPIO | 262 |
| | n/a | 23 | 24 | n/a | |
| | GND | 25 | 26 | n/a | |
| | I2C_1 SDA | 27 | 28 | I2C_1 SCL | |
| 234 | GPIO/PWM | 29 | 30 | GND | |
| 235 | GPIO/PWM | 31 | 32 | GPIO/PWM | 236 |
| 237 | GPIO/PWM | 33 | 34 | GND | |
| 238 | GPIO/PWM | 35 | 36 | GPIO/PWM | 239 |
| 240 | GPIO/PWM | 37 | 38 | GPIO/PWM | 241 |
| | GND | 39 | 40 | GPIO/PWM | 242 |
**Note:**
* Before installing MRAA on Ubuntu 18.04, please follow up the below instructions to insert the following drivers first and configure I2C devices:
```
$ sudo modprobe i2c_i801
$ sudo modprobe gpio-pca953x
$ echo "pca9535 0x20" > /sys/bus/i2c/devices/i2c-13/new_device
$ echo "sx1509q 0x3e" > /sys/bus/i2c/devices/i2c-1/new_device
```
* Not support SPI interface

View File

@@ -4,28 +4,37 @@ 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+
* [SWIG](http://swig.org) 3.0.5+ (3.0.12 recommended, on Xenial this can be installed via 3rd party PPAs)
* [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
```
Adjust as needed, for instance Python 3 builds will require `python3-dev`.
On Ubuntu Bionic you'll need to downgrade node.js (see [nodesource](https://github.com/nodesource/distributions)
for some handy install scripts) or patch SWIG. This is explained more in the
advanced dependencies list below.
### Documentation dependencies
To build the documentation you'll also need:
* [Doxygen](http://www.stack.nl/~dimitri/doxygen/) 1.8.9.1+
* [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 +61,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 +85,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 +101,66 @@ 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`
Note that for static builds the python bindings will not build as they would
require a static python etc... You can try to link mraa statically to the
python binding module by adding -fPIC with `-DCMAKE_C_FLAGS=-fPIC`. You can
also use the node.js gyp build system to get node.js static bindings.
## Dependencies continued
You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
You'll need at least SWIG version 3.0.2 and we recommend 3.0.12 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.
### JavaScript bindings for node.js 7.0.0+
Building the JavaScript bindings using the latest versions of node.js does
involve additional steps due to our dependency on SWIG. In short, a patch is
needed to compile correctly with node.js 7.0.0 or newer. We found the install
scripts from nodesource to be very handy for switching versions and they
support all versions of Ubuntu.
The patch applies cleanly on SWIG 3.0.12, available by default on Ubuntu Bionic
and through 3rd party PPAs for older distributions. For example, with Xenial or
Zesty you could use [this](https://launchpad.net/~timsc/+archive/ubuntu/swig-3.0.12).
To patch SWIG on Ubuntu (assumes you start in the home folder):
```
wget https://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-devtools/swig/swig/0001-Add-Node-7.x-aka-V8-5.2-support.patch
cd /usr/share/swig3.0
sudo patch -p2 <~/0001-Add-Node-7.x-aka-V8-5.2-support.patch
```
Keep in mind that Ubuntu Bionic ships with node.js version 8. You'll need to
either use the patch or downgrade node.js.
### Build version
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
@@ -129,20 +175,8 @@ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/oe-sdk_cross.cmake ..
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.
~~~~~~~~~~~~~{.sh}
mkdir covbuild/ && cd covbuild
cmake -DBUILDDOC=OFF -DBUILDSWIG=OFF ..
cov-build --dir cov-int make
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,24 +191,147 @@ 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`
## Building for the Android Things Peripheralmanager Client
You can get `cpack` to generate an IPK or RPM package fairly easily if you have
the correct packaging tools
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}
cmake -DIPK=ON -DCMAKE_INSTALL_PREFIX=/usr ..
make package
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 \
..
~~~~~~~~~~~~~
To use RPM simply enable the RPM option. You'll need `rpmbuild` installed on your
build machine.
## Building with Docker
~~~~~~~~~~~~~{.sh}
cmake -DRPM=ON -DCMAKE_INSTALL_PREFIX=/usr ..
~~~~~~~~~~~~~
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"
```

View File

@@ -5,6 +5,82 @@ 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.
**2.1.0**
* New platforms UP Xtreme, IPi SMARC, ROCK PI 4, Raspberry Pi 4, Ultra96
* Added support for chardev GPIO devices on Rock960
* Introduced APIs to initialize GPIOs by name
* Multiple fixes to address static tool scans and user submitted bug reports
* Revised documentation to reflect project transfer to the Eclipse Foundation
* Updated installation instructions for multiple distribution channels
**2.0.0**
* New platforms IEI Tank, Ultra-96, Rock960, Hikey960, Dragonboard 820c
* Added support for chardev GPIO devices with implementation on several boards
* Added string based I/O initialization for simpler integration with other frameworks
* Added GTest support for unit testing
* Extended named LED device APIs allowing them to be listed during board definition
* Removed packaging and CI for obsolete devkits
* Multiple bug fixes and cmake improvements
**1.9.0**
* Added support for RPi Zero W
* Added support for MIPS based Omega2 and Linkit Smart 7688
* New APIs for sysfs onboard LED control using the gpio-leds driver
* Restructured and cleaned-up examples
* Improved documentation generation and CI integration
* Static analysis fixes, added SonarQube badge
* Enhanced Node.js detection on some Linux distros (OpenSUSE)
**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
@@ -19,25 +95,25 @@ they are listed here. Anything pre 0.2.x is ignored.
**1.2.0**
* JSON platform support
* mock I2c functionality
* Intel Grosse Tete PWM fix
* Intel Joule PWM fix
* AIO firmata bug fix
**1.1.2**
* Mock platform support
* mraa-i2c treats i2c buses by default as linux
* grosse tete i2c fixes
* Intel Joule i2c fixes
* travis now uses 14.04 instead of 12.04
**1.1.1**
* IIO 4.6 kernel matrix support
* Intel Grosse Tete radio led support
* Intel Joule radio led support
* mraa_init_io() examples
* MRAAPLATFORMFORCE fixes
* fix python documentation
**1.1.0**
* build python2 & python3 bindings
* Intel Grosse Tete support
* Intel Joule support
* mraa_init_io() generic funtion
* mraa-gpio fixes
* edison PWM 0% improvements

153
docs/de_nano_soc.md Normal file
View 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.
Alteras 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
```

View File

@@ -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

View File

@@ -1,112 +1,6 @@
Grosse Tete {#grossetete}
===========
Grosstete {#grossetete}
=========
The Grosse Tete with the Tuchuck board is supported by Mraa
You probably meant to go here: @ref joule.
Revision Support
----------------
Tuchuck
Interface notes
---------------
**SPI** Currently not working
**UART** Some pins are labelled as UARTs but are not configured in BIOS as UART
so only available UART is on the FTDI header
Pin Mapping
-----------
Tuchuck has two breakouts, breakout #1 is 1-40 whilst breakout2 is 41-80. The
LEDs are numbered from 100-103.
| MRAA Number | Physical Pin | Function |
|-------------|--------------|----------|
| 1 | GPIO | GPIO |
| 2 | SPP1RX | GPIO |
| 3 | PMICRST | NONE |
| 4 | SPP1TX | GPIO |
| 5 | 19.2mhz | GPIO |
| 6 | SPP1FS0 | GPIO |
| 7 | UART0TX | GPIO |
| 8 | SPP1FS2 | GPIO |
| 9 | PWRGD | NONE |
| 10 | SPP1CLK | GPIO |
| 11 | I2C0SDA | I2C |
| 12 | I2S1SDI | GPIO |
| 13 | I2C0SCL | I2C |
| 14 | I2S1SDO | GPIO |
| 15 | I2C1SDA | I2C |
| 16 | I2S1WS | GPIO |
| 17 | I2C1SCL | I2C |
| 18 | I2S1CLK | GPIO |
| 19 | I2C2SDA | I2C |
| 20 | I2S1MCL | GPIO |
| 21 | I2C2SCL | I2CO |
| 22 | UART1TX | UART |
| 23 | I2S4SDO | NONE |
| 24 | UART1RX | UART |
| 25 | I2S4SDI | NONE |
| 26 | PWM0 | GPIO PWM |
| 27 | I2S4BLK | GPIO |
| 28 | PWM1 | GPIO PWM |
| 29 | I2S4WS | NONE |
| 30 | PWM2 | GPIO PWM |
| 31 | I2S3SDO | NONE |
| 32 | PWM3 | GPIO PWM |
| 33 | I2S3SDI | NONE |
| 34 | 1.8V | NONE |
| 35 | I2S4BLK | GPIO |
| 36 | GND | NONE |
| 37 | GND | NONE |
| 38 | GND | NONE |
| 39 | GND | NONE |
| 40 | 3.3V | NONE |
| 41 | GND | NONE |
| 42 | 5V | NONE |
| 43 | GND | NONE |
| 44 | 5V | NONE |
| 45 | GND | NONE |
| 46 | 3.3V | NONE |
| 47 | GND | NONE |
| 48 | 3.3V | NONE |
| 49 | GND | NONE |
| 50 | 1.8V | NONE |
| 51 | GPIO | GPIO |
| 52 | 1.8V | NONE |
| 53 | PANEL | GPIO |
| 54 | GND | NONE |
| 55 | PANEL | GPIO |
| 56 | CAMERA | NONE |
| 57 | PANEL | GPIO |
| 58 | CAMERA | NONE |
| 59 | SPP0FS0 | GPIO |
| 60 | CAMERA | NONE |
| 61 | SPP0FS1 | GPIO |
| 62 | SPI_DAT | SPI |
| 63 | SPP0FS2 | GPIO |
| 64 | SPICLKB | GPIO SPI |
| 65 | SPP0FS3 | GPIO |
| 66 | SPICLKA | GPIO SPI |
| 67 | SPP0TX | GPIO |
| 68 | UART0RX | GPIO UART|
| 69 | SPP0RX | GPIO |
| 70 | UART0RT | GPIO UART|
| 71 | I2C1SDA | GPIO I2C |
| 72 | UART0CT | GPIO UART|
| 73 | I2C1SCL | GPIO I2C |
| 74 | UART1TX | GPIO UART|
| 75 | I2C2SDA | GPIO I2C |
| 76 | UART1RX | GPIO UART|
| 77 | I2C1SCL | GPIO I2C |
| 78 | UART1RT | GPIO UART|
| 79 | RTC_CLK | GPIO |
| 80 | UART1CT | GPIO UART|
| 100 | LED100 | GPIO |
| 101 | LED101 | GPIO |
| 102 | LED102 | GPIO |
| 103 | LED103 | GPIO |
To see a live pin mapping use the command:
$ mraa-gpio list
Note: This page will be deleted in the future, don't link to it!

66
docs/grovepi.md Normal file
View 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.

40
docs/iei-tank.md Normal file
View File

@@ -0,0 +1,40 @@
IEI TANK AIoT Dev. Kit {#iei-tank}
================================
TANK AIoT Dev. Kit features rich I/O and dual PCIe by 16 slots with by 8 signal
for add-on card installation such as PoE (IPCEI-4POE) card or acceleration card
(Mustang-F100-A10 & Mustang-V100-RX8) to enhance function and performance for
various applications.
For the full specifications please visit the product page:
https://www.ieiworld.com/tank-aiot-development-kit
Interface notes
-----------------------
The MRAA platform file was developed using an IEI TANK-870-Q170 and may not
be compatible with other TANK systems. 6 serial ports and 8 digital pins are
available and can be controlled using MRAA on this system.
**UART**
* 4 x RS-232 (2 x RJ-45, 2 x DB-9 w/2.5KV isolation protection)
* 2 x RS-232/422/485 (DB-9)
**GPIO**
* 8-bit digital I/O , 4-bit input / 4-bit output (DB9)
Pin Mapping
--------------------
The GPIO numbering in MRAA is explained in the table below. To use the pins
the *gpio_f7188x* Linux kernel module must be available and loaded.
| MRAA Pin | DB9 Pin | Sysfs GPIO | Function |
|----------|--------------|------------|-----------------|
| 0 | 1 | 4 | DIN0 |
| 1 | 2 | 0 | DOUT0 |
| 2 | 3 | 11 | DIN1 |
| 3 | 4 | 1 | DOUT1 |
| 4 | 5 | 12 | DIN2 |
| 5 | 6 | 2 | DOUT2 |
| 6 | 7 | 13 | DIN3 |
| 7 | 8 | 3 | DOUT3 |
| 8 | 9 | | +5V |

View File

@@ -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).

View File

@@ -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,17 +46,20 @@ Specific platform information for supported platforms is documented here:
- @ref rasppi
- @ref bananapi
- @ref beaglebone
- @ref phyboard-wega
- @ref nuc5
- @ref up
- @ref grossetete
- @ref joule
- @ref ft4222
- @ref iei-tank
- @ref up-xtreme
## 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

View File

@@ -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,22 +46,37 @@ Specific platform information for supported platforms is documented here:
- @ref rasppi
- @ref bananapi
- @ref beaglebone
- @ref phyboard-wega
- @ref nuc5
- @ref up
- @ref grossetete
- @ref up2
- @ref joule
- @ref ft4222
- @ref _96boards
- @ref de10-nano
- @ref firmata
- @ref grovepi
- @ref mock
- @ref linkit_7688
- @ref omega2
- @ref iei-tank
- @ref upXtreme
## 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
More information on compiling is @ref building page.
## STATIC CODE ANALYSIS
See @ref static_code_analysis page.
## CONTRIBUTING
Please see the @ref contributing page, the @ref internals page may also be of

View File

@@ -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
View 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
View 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
View 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)
![Pinout](http://www.cnx-software.com/wp-content/uploads/2015/12/Link_Smart_7688_Pinout.png)
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) |

View File

@@ -1,30 +1,34 @@
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
------------------
mraa has only been tested with 64 bit firmware version 0.73 or later.
MRAA has only been tested with 64 bit firmware version 0.73 or later.
SPI
---
For SPI support you need to load the low_speed_spidev kernel module and that
will create the /dev/spidev0.0 device node. Mraa only knows about this one SPI
will create the /dev/spidev0.0 device node. MRAA only knows about this one SPI
bus and no other.
Interface notes
---------------
The low speed I/O connector supported as per table below. This assumes default
BIOS settings, as they are not dynamcially detected If any changes are mode
(Device Manager -> System Setup -> South Cluster -> LPSS & CSS) them mraa calls
(Device Manager -> System Setup -> South Cluster -> LPSS & CSS) them MRAA calls
will not behave as expected.
The platform is chardev capable on newer kernels.
Documentation shows i2c on bus #5, ACPI shows it on bus #6, but driver uses
bus #7.
@@ -55,4 +59,17 @@ 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
** On 3.18+ kernels, sysfs GPIO numbers are computed using:
`new_value = old_value | 0x100`
User LED
---------------
The MinnowBoard Turbot has one user programmable built-in LED. This is exposed
as a GPIO from MRAA.
| MRAA Number | Physical Pin | Function | Sysfs GPIO | Notes |
|-------------|---------------|------------|------------|----------------------|
| 27 | N/A | D2_LED | 104 | Active low |

View File

@@ -19,8 +19,15 @@ Right now we simulate a single generic board with:
which can be read or written in bytes or words (big-endian). Technically those
registers are just an array of `uint8_t`, so you can treat them as 10 single-byte
registers or 5 single-word ones or a mix thereof.
* Single SPI bus with one Chip Select. All write functions are supported, received
data items (words or bytes) are calculated from the sent ones using
`sent_byte (or word) XOR constant` formula.
See [SPI mock header](../include/mock/mock_board_spi.h#L38-L39) for constant values.
* Single UART port. All functions are supported, but many are simple stubs. Write
always succeeds, read returns 'Z' symbol as many times as `read()` requested.
We plan to develop it further and all [contributions](../CONTRIBUTING.md) are more than welcome.
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
@@ -30,12 +37,18 @@ See the table below for pin layout and features
| 1 | ADC0 | AIO pin, returns random value on read |
| 2 | I2C0SDA | SDA pin for I2C0 bus |
| 3 | I2C0SCL | SCL pin for I2C0 bus |
| 4 | SPI0CS | CS pin for SPI0 bus |
| 5 | SPI0MOSI | MOSI pin for SPI0 bus |
| 6 | SPI0MISO | MISO pin for SPI0 bus |
| 7 | SPI0SCLK | SCLK pin for SPI0 bus |
| 8 | UART0RX | RX pin for UART0 port |
| 9 | UART0TX | TX pin for UART0 port |
Building
--------
Generally all the building steps are the same as listed
in the [main building guide](./building.md), you just need to set some specific
in the main @ref building guide, you just need to set some specific
CMake options.
### Linux

View File

@@ -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
View 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)
![Pinout](https://raw.githubusercontent.com/OnionIoT/Onion-Docs/master/Omega2/Documentation/Hardware-Overview/img/Omega-2-Pinout-Diagram.png)
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
View 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!

62
docs/rockpi4.md Normal file
View File

@@ -0,0 +1,62 @@
Rock Pi 4 A/B Single Board Computer {#_rockpi}
=============================
ROCK Pi 4 is a Rockchip RK3399 based SBC(Single Board Computer) by Radxa. It can run android or some Linux distributions. ROCK Pi 4 features a six core ARM processor, 64bit dual channel 3200Mb/s LPDDR4, up to 4K@60 HDMI, MIPI DSI, MIPI CSI, 3.5mm jack with mic, 802.11 ac WIFI, Bluetooth 5.0, USB Port, GbE LAN, 40-pin color expansion header, RTC. Also, ROCK Pi 4 supports USB PD and QC powering.
ROCK Pi 4 comes in three models, Model A and Model B has 1GB, 2GB or 4GB ram options, Model C has 4GB ram only. For detailed difference of three models, please check Specifications.
Board Support
-------------
- [ROCK Pi 4](https://wiki.radxa.com/Rockpi4)
Interface notes
---------------
- **UART**: ttyS0 not usable, use ttyS2 and ttyS4
- UART2 is enabled as U-boot and Linux serial console by default. Check Rockpi4/dev/serial-console to use. Check Rockpi4/hardware/devtree_overlays to disable serial console on UART2.
- UART2 & UART4 support a wide range of baud rate. It includes but not is not limited to the following baud rates. For instance, 115200bps. 500000bps, 1500000bps and so on.
- Function marked with color orange is the default function of this pin.
- Except Pins for power supply, all pins are laid out directly to Soc RK3399.
- For pin 3, 5, 27, 28, 29 and 31, each pin is connected to the 3.0V supply through a 4.7K pull-up resistor.
- Pin 19, 21, 23, 24 are laid out directly to the pins of SPI device on board.
- Pin 7 is laid out directly to the pin of MIPI CSI on board.
- For I2C-2 and I2C-7
- We have do the test using the i2c device e2prom. We need to open the i2c device file, and then do the read or write operation.
Pin Mapping
-----------
PROCK Pi 4 has a 40-pin expansion header. Each pin is distinguished by color.
|Additional Function | Primary Function| PIN | PIN | Primary Function | Additional Function |
|--------------------|------------------|:------|------:|--------------------|---------------------|
| | +3.3V | 1 | 2 | +5.0V | |
| | I2C7_SDA | 3 | 4 | +5.0V | |
| | I2C7_SCL | 5 | 6 | GND | |
| | SPI2_CLK | 7 | 8 | UART2_TXD | |
| | GND | 9 | 10 | UART2_RXD | |
| | PWM0 | 11 | 12 | I2S1_SCLK | |
| | PWM1 | 13 | 14 | GND | |
| | SPDIF_TX | 15 | 16 | GPIO4_D2 | |
| | +3.3V | 17 | 18 | GPIO4_D4 | |
| UART4_TXD | SPI1_TXD | 19 | 20 | GND | |
| UART4_RXD | SPI1_RXD | 21 | 22 | GPIO4_D5 | |
| | SPI1_CLK | 23 | 24 | SPI1_CSn | |
| | GND | 25 | 26 | ADC_IN0 | |
| | I2C2_SDA | 27 | 28 | I2C2_CLK | |
| I2C6_SCL | SPI2_TXD | 29 | 30 | GND | |
| I2C6_SDA | SPI2_RXD | 31 | 32 | SPDIF_TX | UART3_CTSn |
| | SPI2_CSn | 33 | 34 | GND | |
| | I2S1_LRCK_TX| 35 | 36 | I2S1_LRCK_RX | |
| | GPIO4_D6 | 37 | 38 | I2S1_SDI | |
| | GND | 39 | 40 | I2S1_SDO | |
Resources
---------
The following links will take you to additional Rock Pi 4 resources
- [Armbian for Rock Pi 4](https://www.armbian.com/rock-pi-4/)
- [Forums](https://forum.radxa.com/c/rockpi4)
- [Github Repo](https://github.com/radxa)

View File

@@ -0,0 +1,93 @@
Static code analysis {#static_code_analysis}
====================
We use [SonarQube](https://www.sonarqube.org/) for static code analysis scans.
These are automated via Travis, same as our usual builds.
Automated scans
---------------
We don't use the Travis' plugin for Sonar due to the fact we use Docker
and not the bare Travis, and these two are not compatible.
We have a dedicated `docker-compose` target for scans, `sonar-scan`. Necessary
values are passed to Sonar scanner as command-line parameters.
For the whole config to work, the following one-time configuration steps are necessary:
* Create organization and project in SonarQube - done already,
https://sonarcloud.io/organizations/mraa-github (key: mraa-github)
and https://sonarcloud.io/dashboard?id=mraa-master (key: mraa-master);
* Create technical account on GitHub with push permissions for mraa repo.
It is used for reporting pull request statuses in the "checks" area.
We have `intel-iot-devkit-helperbot` for this, shared with UPM.
* Add several environment variables in Travis:
* `GITHUB_TOKEN` (secure) - GH OAuth token for the technical user,
with `public_repo` privileges only;
* `SONAR_TOKEN` (secure) - this one comes from the SonarQube org properties;
* `SONAR_ORG`, `SONAR_PROJ_KEY` (may be public) - project and org keys (names)
from SonarQube org, see above;
These scans are executed each time there's an internal pull request (from a branch
local to main mraa repo) or a `master` branch push.
Upon the former the so called "preview" scan is executed, which doesn't
upload anything to SonarQube organization and only reports the result within the PR.
Upon `master` branch push a normal scan is executed and results are uploaded to
SonarQube.
When there's a so called "external" pull request (originating somewhere else
than mraa's main repo, e.g. from a fork), no scan is done for
security reasons, as code within such PR would have access to tokens listed above.
In view of such setup, it's beneficial to create internal pull requests as much
as possible, because you'll catch problems right away - in the preview scan,
before PR is merged.
Manual scans
------------
It's a good practice to run the scan manually before actually submitting a PR.
There may also be a need to run the scan manually out-of-cycle, so here's how.
Just use the command line from [the scanner script](../master/scripts/sonar-scan.sh).
See `sonar_cmd_base` variable specifically and just replace various tokens
listed there with proper ones. Please also don't forget that you need to run the
build wrapper first, so that the scanner knows what to scan.
The set of commands for the main mraa repo and SonarQube project would look like
the below. Note that it will upload results to the SonarQube by default,
if you don't want that, setup a throwaway "project" in SonarQube, or create a
separate "organization" dedicated to your mraa repo fork:
```bash
$> export PATH=~/bin/sonar/sonar-scanner-3.0.3.778-linux/bin/:~/bin/sonar/build-wrapper-linux-x86/:$PATH
$> build-wrapper-linux-x86-64 --out-dir bw-output make clean all
$> sonar-scanner \
-Dsonar.projectKey=mraa-master \
-Dsonar.projectBaseDir=/PATH/TO/YOUR/MRAA/REPO/CLONE \
-Dsonar.sources=/PATH/TO/YOUR/MRAA/REPO/CLONE \
-Dsonar.inclusions='api/**/*,CMakeLists.txt,examples/**/*,imraa/**/*,include/**/*,src/*,src/**/*,tests/**/*' \
-Dsonar.cfamily.build-wrapper-output=/PATH/TO/YOUR/MRAA/REPO/CLONE/YOUR_BUILD_DIR/bw-output \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=mraa-github \
-Dsonar.login=YOUR_SONAR_LOGIN_TOKEN_HERE
```
Notice that we first set the `PATH` to point to our downloaded copy of Sonar tools.
You can find more information on setting these up in SonarQube's nice
[Getting Started tutorial](https://about.sonarcloud.io/get-started/).
Using Coverity
--------------
In the past we've used Coverity to do static code analysis scans. Below is the
documentation on that setup - for archiving purposes.
This is the procedure to submit a build to Coverity. You'll need to install
`coverity-submit` for your OS.
```bash
mkdir covbuild/ && cd covbuild
cmake -DBUILDDOC=OFF -DBUILDSWIG=OFF ..
cov-build --dir cov-int make
tar caf mraa.tar.bz2 cov-int
```

View File

@@ -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
View File

@@ -0,0 +1,88 @@
UP Squared Board {#up2}
================================
UP Squared is based on the Intel&reg; Celeron&trade; N3350 or the Intel&reg; Pentium&trade; N4200, formerly ApolloLake&trade;.
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://wiki.up-community.org/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 | |

85
docs/up_xtreme.md Normal file
View File

@@ -0,0 +1,85 @@
UP Xtreme Board {#up_xtreme}
================================
UP Xtreme is based on the Intel&reg; Core&trade; i3/i5/i7 Whiskey Lake SoCs.
For the full specification please refer to the main specification page here:
https://up-board.org/wp-content/uploads/up-xtreme/Datasheet-UP-xtreme.pdf
Interface notes
-----------------------
The UP Xtreme present one Raspberry Pi compatible HAT connector and a 100 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
- 2 chip-selects
- To enable SPI device nodes the ACPI tables need to be overwritten as explained [here](https://wiki.up-community.org/Pinout_UP2#SPI_Ports)
**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/up_xtreme.c for details.
| MRAA no. | Function | Rpi GPIO | Sysfs GPIO | mraa device |
|----------|--------------|------------|------------|-----------------|
| 1 | 3V3 VCC | | | |
| 2 | 5V VCC | | | |
| 3 | I2C_SDA | 2 | 368 | I2C0 |
| 4 | 5V VCC | | | |
| 5 | I2C_SCL | 3 | 369 | I2C0 |
| 6 | GND | | | |
| 7 | GPIO(4) | 4 | 296 | |
| 8 | UART_TX | 14 | 469 | UART0 |
| 9 | GND | | | |
| 10 | UART_RX | 15 | 468 | UART0 |
| 11 | UART_RTS | 17 | 470 | UART0 |
| 12 | I2S_CLK | 18 | 360 | |
| 13 | GPIO(27) | 27 | 268 | |
| 14 | GND | | | |
| 15 | GPIO(22) | 22 | 270 | |
| 16 | GPIO(23) | 23 | 264 | |
| 17 | 3V3 VCC | | | |
| 18 | GPIO(24) | 24 | 265 | |
| 19 | SPI0_MOSI | 10 | 308 | SPI0 |
| 20 | GND | | | |
| 21 | SPI0_MISO | 9 | 307 | SPI0 |
| 22 | GPIO(25) | 25 | 266 | |
| 23 | SPI0_SCL | 11 | 306 | SPI0 |
| 24 | SPI0_CS0 | 8 | 305 | SPI0 |
| 25 | GND | | | |
| 26 | SPI0_CS1 | 7 | 311 | SPI0 |
| 27 | ID_SD | 0 | 366 | I2C1 |
| 28 | ID_SC | 1 | 367 | I2C1 |
| 29 | GPIO(5) | 5 | 317 | |
| 30 | GND | | | |
| 31 | GPIO(6) | 6 | 318 | |
| 32 | GPIO(12) | 12 | 298 | |
| 33 | GPIO(13) | 13 | 299 | |
| 34 | GND | | | |
| 35 | I2S_FRM | 19 | 261 | |
| 36 | UART_CTS | 16 | 471 | UART0 |
| 37 | GPIO(26) | 26 | 267 | |
| 38 | I2S_DIN | 20 | 363 | |
| 39 | GND | | | |
| 40 | I2S_DOUT | 21 | 362 | |

1
doxyport Submodule

Submodule doxyport added at db3e1a6eb8

View File

@@ -1,61 +1,14 @@
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 ( (DEFINED ENV{JAVA_HOME_NATIVE}) OR (DEFINED ENV{JAVA_HOME}) )
#add_subdirectory (java)
else ()
#message ( WARNING "You haven't configured the Java environment variables yet!")
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)
if (NOT ANDROID_TOOLCHAIN)
add_subdirectory (c++)
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()

View File

@@ -1,52 +0,0 @@
/*
* Author: Nandkishor Sonar
* 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 <unistd.h>
//! [Interesting]
#include "mraa/aio.h"
int
main()
{
mraa_aio_context adc_a0;
uint16_t adc_value = 0;
float adc_value_float = 0.0;
adc_a0 = mraa_aio_init(0);
if (adc_a0 == NULL) {
return 1;
}
for (;;) {
adc_value = mraa_aio_read(adc_a0);
adc_value_float = mraa_aio_read_float(adc_a0);
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
}
mraa_aio_close(adc_a0);
return MRAA_SUCCESS;
}
//! [Interesting]

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -1,49 +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.
*/
//! [Interesting]
#include "mraa.hpp"
int
main()
{
uint16_t adc_value;
float adc_value_float;
mraa::Aio* a0;
a0 = new mraa::Aio(0);
if (a0 == NULL) {
return MRAA_ERROR_UNSPECIFIED;
}
for (;;) {
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);
}
return MRAA_SUCCESS;
}
//! [Interesting]

View File

@@ -1,77 +0,0 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Thomas Ingleby <thomas.c.ingleby@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 <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "mraa.hpp"
#define DEFAULT_IOPIN 8
static int iopin;
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing IO%d nicely\n", iopin);
running = -1;
}
}
int
main(int argc, char** argv)
{
if (argc < 2) {
printf("Provide an int arg if you want to flash on something other than %d\n", DEFAULT_IOPIN);
iopin = DEFAULT_IOPIN;
} else {
iopin = strtol(argv[1], NULL, 10);
}
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);
if (response != mraa::SUCCESS) {
mraa::printError(response);
return 1;
}
while (running == 0) {
response = gpio->write(1);
sleep(1);
response = gpio->write(0);
sleep(1);
}
delete gpio;
return response;
//! [Interesting]
}

View File

@@ -1,26 +1,29 @@
enable_language(CXX)
add_executable (AioA0 AioA0.cpp)
add_executable (blink-io-cpp Blink-IO.cpp)
add_executable (Pwm3-cycle Pwm3-cycle.cpp)
add_executable (I2c-compass I2c-compass.cpp)
add_executable (Spi-pot Spi-pot.cpp)
add_executable (Uart Uart-example.cpp)
add_executable (Isr-pin6 Isr-pin6.cpp)
add_executable (Iio-dummy Iio-dummy.cpp)
add_executable (aio_cpp aio.cpp)
add_executable (gpio_advanced_cpp gpio_advanced.cpp)
add_executable (gpio_cpp gpio.cpp)
add_executable (pwm_cpp pwm.cpp)
add_executable (i2c_cpp i2c.cpp)
add_executable (spi_cpp spi.cpp)
add_executable (uart_cpp uart.cpp)
add_executable (iio_cpp iio.cpp)
add_executable (led_cpp led.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++)
target_link_libraries (Pwm3-cycle mraa stdc++)
target_link_libraries (I2c-compass mraa stdc++ m)
target_link_libraries (Spi-pot mraa stdc++)
target_link_libraries (Uart mraa stdc++)
target_link_libraries (Isr-pin6 mraa stdc++)
target_link_libraries (Iio-dummy mraa stdc++)
target_link_libraries (aio_cpp mraa stdc++)
target_link_libraries (gpio_advanced_cpp mraa stdc++)
target_link_libraries (gpio_cpp mraa stdc++)
target_link_libraries (pwm_cpp mraa stdc++)
target_link_libraries (i2c_cpp mraa stdc++ m)
target_link_libraries (spi_cpp mraa stdc++)
target_link_libraries (uart_cpp mraa stdc++)
target_link_libraries (iio_cpp mraa stdc++)
target_link_libraries (led_cpp mraa stdc++)
if (ONEWIRE)
add_executable (UartOW UartOW.cpp)
target_link_libraries (UartOW mraa stdc++)
add_executable (uart_ow_cpp uart_ow.cpp)
target_link_libraries (uart_ow_cpp mraa stdc++)
endif ()

View File

@@ -1,157 +0,0 @@
/*
* Author: Henry Bruce
* 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 <iostream>
#include <math.h>
#include <float.h>
#include "mraa/iio.hpp"
#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); \
}
// 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); \
}
// 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); \
}
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)
{
std::string result;
if (expect_success)
result = success ? "PASS" : "FAIL";
else
result = success ? "FAIL" : "PASS";
if (attr_name.empty())
fprintf(stdout, "%s: %s\n", test_name.c_str(), result.c_str());
else
fprintf(stdout, "%s(%s): %s\n", test_name.c_str(), attr_name.c_str(), result.c_str());
}
// Generate iio_dummy driver event by writing a string to a specific sysfs node
bool generate_event()
{
FILE *fp = fopen("/sys/bus/iio/devices/iio_evgen/poke_ev0", "w");
if (fp == NULL)
return false;
fprintf(fp, "1\n");
fclose(fp);
return true;
}
// 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)
eventCount++;
}
};
int
main()
{
IioTestHandler testHandler;
std::string deviceName;
try {
mraa::Iio* iio_device0 = new mraa::Iio(0);
std::cout << "IIO device 0 found by id." << std::endl;
deviceName = iio_device0->getDeviceName();
delete iio_device0;
} catch (std::exception& e) {
std::cerr << "IIO device 0 not found." << std::endl;
return EXIT_FAILURE;
}
try {
mraa::Iio* iio_device1 = new mraa::Iio(1);
delete iio_device1;
} catch (std::exception& e) {
std::cerr << "IIO device 1 not found. This is expected behavior." << std::endl;
}
try {
iio_device = new mraa::Iio(deviceName);
std::cout << "IIO device 0 found by name." << std::endl;
} catch (std::exception& e) {
std::cerr << "IIO device 0 not found." << std::endl;
return EXIT_FAILURE;
}
std::cout << "Using IIO device0. Name is " << iio_device->getDeviceName() << std::endl;
IIO_RUN(writeFloat, "in_accel_x_raw", 100, EXPECT_FAILURE);
IIO_RUN(writeFloat, "in_voltage0_scale", 100, EXPECT_FAILURE);
IIO_RUN(writeInt, "out_voltage0_raw", 100, EXPECT_SUCCESS);
IIO_TEST(readInt, "in_accel_x_raw", 34, EXPECT_SUCCESS);
IIO_TEST(readFloat, "in_voltage0_scale", 0.001333, EXPECT_SUCCESS);
IIO_RUN(writeInt, "events/in_voltage0_thresh_rising_en", 1, EXPECT_SUCCESS);
IIO_TRY(registerEventHandler(&testHandler));
eventCount = 0;
generate_event();
usleep(500000);
log_result("eventReceived", "", (eventCount == 1), true);
delete iio_device;
return EXIT_SUCCESS;
}

View File

@@ -1,57 +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.hpp"
static volatile int counter = 0;
static volatile int oldcounter = 0;
void
interrupt(void* args)
{
++counter;
}
int
main()
{
mraa::Gpio* x = new mraa::Gpio(6);
x->dir(mraa::DIR_IN);
x->isr(mraa::EDGE_BOTH, &interrupt, NULL);
for (;;) {
if (counter != oldcounter) {
fprintf(stdout, "timeout counter == %d\n", counter);
oldcounter = counter;
}
// got to relieve our poor CPU!
sleep(1);
}
return EXIT_SUCCESS;
}

View File

@@ -1,68 +0,0 @@
/*
* Author: Thomas Ingleby <thomas.c.ingleby@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 <unistd.h>
#include <signal.h>
#include "mraa.hpp"
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing PWM nicely\n");
running = -1;
}
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
mraa::Pwm* pwm;
pwm = new mraa::Pwm(3);
if (pwm == NULL) {
return MRAA_ERROR_UNSPECIFIED;
}
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
pwm->enable(true);
float value = 0.0f;
while (running == 0) {
value = value + 0.01f;
pwm->write(value);
usleep(50000);
if (value >= 1.0f) {
value = 0.0f;
}
}
delete pwm;
//! [Interesting]
return MRAA_SUCCESS;
}

View File

@@ -1,80 +0,0 @@
/*
* Author: Thomas Ingleby <thomas.c.ingleby@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 <unistd.h>
#include <signal.h>
#include <stdint.h>
#include "mraa.hpp"
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing spi nicely\n");
running = -1;
}
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
mraa::Spi* spi;
spi = new mraa::Spi(0);
uint8_t data[] = { 0x00, 100 };
uint8_t rxBuf[2];
uint8_t* recv;
while (running == 0) {
int i;
for (i = 90; i < 130; i++) {
data[1] = i;
recv = spi->write(data, 2);
printf("Writing -%i", i);
if (recv) {
printf("RECIVED-%i-%i\n", recv[0], recv[1]);
free(recv);
}
usleep(100000);
}
for (i = 130; i > 90; i--) {
data[1] = i;
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;
}

View File

@@ -1,70 +0,0 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <exception>
#include "mraa.hpp"
int
main()
{
//! [Interesting]
// If you have a valid platform configuration use numbers to represent uart
// device. If not use raw mode where std::string is taken as a constructor
// parameter
mraa::Uart* dev;
try {
dev = new mraa::Uart(0);
} catch (std::exception& e) {
std::cout << e.what() << ", likely invalid platform config" << std::endl;
}
try {
dev = new mraa::Uart("/dev/ttyACM0");
} catch (std::exception& e) {
std::cout << "Error while setting up raw UART, do you have a uart?" << std::endl;
std::terminate();
}
if (dev->setBaudRate(115200) != mraa::SUCCESS) {
std::cout << "Error setting parity on UART" << std::endl;
}
if (dev->setMode(8, mraa::UART_PARITY_NONE, 1) != mraa::SUCCESS) {
std::cout << "Error setting parity on UART" << std::endl;
}
if (dev->setFlowcontrol(false, false) != mraa::SUCCESS) {
std::cout << "Error setting flow control UART" << std::endl;
}
dev->writeStr("Hello monkeys");
//! [Interesting]
delete dev;
return mraa::SUCCESS;
}

View File

@@ -1,82 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "stdio.h"
#include "iostream"
//! [Interesting]
#include "uart_ow.hpp"
using namespace std;
int
main(int argc, char** argv)
{
mraa::UartOW* uart = new mraa::UartOW(0);
// Reset the ow bus and see if anything is present
mraa::Result rv;
if ((rv = uart->reset()) == mraa::SUCCESS) {
cout << "Reset succeeded, device(s) detected!" << endl;
} else {
cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl;
return 1;
}
cout << "Looking for devices..." << endl;
;
uint8_t count = 0;
// start the search from scratch
string id = uart->search(true);
if (id.empty()) {
cout << "No devices detected." << endl;
return 1;
}
while (!id.empty()) {
// hack so we don't need to cast each element of the romcode
// for printf purposes
uint8_t* ptr = (uint8_t*) id.c_str();
// The first byte (0) is the device type (family) code.
// The last byte (7) is the rom code CRC value. The
// intervening bytes are the unique 48 bit device ID.
printf("Device %02d Type 0x%02x ID %02x%02x%02x%02x%02x%02x CRC 0x%02x\n", count, ptr[0],
ptr[6], ptr[5], ptr[4], ptr[3], ptr[2], ptr[1], ptr[7]);
count++;
// continue the search with start argument set to false
id = uart->search(false);
}
cout << "Exiting..." << endl;
delete uart;
return 0;
}
//! [Interesting]

56
examples/c++/aio.cpp Normal file
View File

@@ -0,0 +1,56 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributors: Alex Tereschenko <alex.mkrs@gmail.com>
* Contributors: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
* Copyright (c) 2014 Intel Corporation.
*
* SPDX-License-Identifier: MIT
*
* Example usage: Reads ADC A0 value continuously. Press Ctrl+C to exit.
*/
/* standard headers */
#include <iostream>
#include <signal.h>
#include <stdlib.h>
/* mraa headers */
#include "mraa/aio.hpp"
#include "mraa/common.hpp"
/* AIO port */
#define AIO_PORT 0
volatile sig_atomic_t flag = 1;
void
sig_handler(int signum)
{
if (signum == SIGINT) {
std::cout << "Exiting..." << std::endl;
flag = 0;
}
}
int
main(void)
{
uint16_t value;
float float_value;
signal(SIGINT, sig_handler);
//! [Interesting]
/* initialize AIO */
mraa::Aio aio(AIO_PORT);
while (flag) {
value = aio.read();
float_value = aio.readFloat();
std::cout << "ADC A0 read %X - %d" << value << value << std::endl;
std::cout << "ADC A0 read float - %.5f" << float_value << std::endl;
}
//! [Interesting]
return EXIT_SUCCESS;
}

97
examples/c++/gpio.cpp Normal file
View File

@@ -0,0 +1,97 @@
/*
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
* Copyright (c) 2018 Linaro Ltd.
*
* SPDX-License-Identifier: MIT
*
* Example usage: Toggles GPIO's 23 and 24 recursively. Press Ctrl+C to exit
*
*/
/* standard headers */
#include <iostream>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
/* mraa headers */
#include "mraa/common.hpp"
#include "mraa/gpio.hpp"
/* 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) {
std::cout << "Exiting..." << std::endl;
flag = 0;
}
}
int
main(void)
{
mraa::Result status;
/* install signal handler */
signal(SIGINT, sig_handler);
//! [Interesting]
/* initialize GPIO pin */
mraa::Gpio gpio_1(GPIO_PIN_1);
/* initialize GPIO pin */
mraa::Gpio gpio_2(GPIO_PIN_2);
/* set GPIO to output */
status = gpio_1.dir(mraa::DIR_OUT);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
/* set gpio 24 to output */
status = gpio_2.dir(mraa::DIR_OUT);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
/* toggle both GPIO's */
while (flag) {
status = gpio_1.write(1);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
status = gpio_2.write(0);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
sleep(1);
status = gpio_1.write(0);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
status = gpio_2.write(1);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
sleep(1);
}
//! [Interesting]
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,56 @@
/*
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
* Copyright (c) 2018 Linaro Ltd.
*
* SPDX-License-Identifier: MIT
*
* Example usage: Configures GPIO pin for interrupt and waits 30 seconds for the isr to trigger
*
*/
/* standard headers */
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
/* mraa headers */
#include "mraa/common.hpp"
#include "mraa/gpio.hpp"
#define GPIO_PIN 6
void
int_handler(void* args)
{
std::cout << "ISR triggered" << std::endl;
}
int
main(void)
{
mraa::Result status;
//! [Interesting]
/* initialize GPIO */
mraa::Gpio gpio(GPIO_PIN);
/* set GPIO to input */
status = gpio.dir(mraa::DIR_IN);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
/* configure ISR for GPIO */
status = gpio.isr(mraa::EDGE_BOTH, &int_handler, NULL);
if (status != mraa::SUCCESS) {
printError(status);
return EXIT_FAILURE;
}
/* wait 30 seconds isr trigger */
sleep(30);
//! [Interesting]
return EXIT_SUCCESS;
}

Some files were not shown because too many files have changed in this diff Show More