Compare commits

...

255 Commits

Author SHA1 Message Date
Mihai Stefanescu
ecf04cb151 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>
2017-08-27 19:18:15 +02:00
Brendan Le Foll
e7133989e5 gpio.h: Add stripped kernel header
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-08-27 19:18:15 +02:00
Mihai Stefanescu
c5f61d4a8d 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>
2017-08-27 19:18:15 +02: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
209 changed files with 12334 additions and 2946 deletions

6
.gitignore vendored
View File

@@ -20,3 +20,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,99 @@
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
allow_failures:
- env: TARGET=ipk
include:
- &run-with-clang
stage: Clang 3.8
env: TARGET=python2
before_script: docker-compose pull ${TARGET}
script:
- export CC=clang-3.8 CXX=clang++-3.8
- docker-compose run ${TARGET}
- BUILDARCH=MOCK docker-compose run ${TARGET}
- if [[ ${TARGET} != *"node"* ]]; then JSONPLAT=ON docker-compose run ${TARGET}; fi
- <<: *run-with-clang
env: TARGET=python3
- <<: *run-with-clang
env: TARGET=node4
- <<: *run-with-clang
env: TARGET=node5
- <<: *run-with-clang
env: TARGET=node6
- <<: *run-with-clang
env: TARGET=java
- &run-with-gcc-5
stage: Gcc 5
env: TARGET=python2
before_script: docker-compose pull ${TARGET}
script:
- export CC=gcc-5 CXX=g++-5
- docker-compose run ${TARGET}
- BUILDARCH=MOCK docker-compose run ${TARGET}
- if [[ ${TARGET} != *"node"* ]]; then JSONPLAT=ON docker-compose run ${TARGET}; fi
- <<: *run-with-gcc-5
env: TARGET=python3
- <<: *run-with-gcc-5
env: TARGET=node4
- <<: *run-with-gcc-5
env: TARGET=node5
- <<: *run-with-gcc-5
env: TARGET=node6
- <<: *run-with-gcc-5
env: TARGET=java
- &run-with-gcc-6
stage: Gcc 6
env: TARGET=python2
before_script: docker-compose pull ${TARGET}
script:
- export CC=gcc-6 CXX=g++-6
- docker-compose run ${TARGET}
- BUILDARCH=MOCK docker-compose run ${TARGET}
- if [[ ${TARGET} != *"node"* ]]; then JSONPLAT=ON docker-compose run ${TARGET}; fi
- <<: *run-with-gcc-6
env: TARGET=python3
- <<: *run-with-gcc-6
env: TARGET=node4
- <<: *run-with-gcc-6
env: TARGET=node5
- <<: *run-with-gcc-6
env: TARGET=node6
- <<: *run-with-gcc-6
env: TARGET=java
- &run-additional-jobs
stage: Additional Jobs
env: TARGET=doc
before_script: docker-compose pull ${TARGET}
script:
- export CC=clang-3.8 CXX=clang++-3.8
- docker-compose run ${TARGET}
- <<: *run-additional-jobs
env: TARGET=android
- <<: *run-additional-jobs
env: TARGET=usbplat
- <<: *run-additional-jobs
env: TARGET=firmata
- <<: *run-additional-jobs
env: TARGET=imraa
- <<: *run-additional-jobs
env: TARGET=ftdi4442
- <<: *run-additional-jobs
env: TARGET=ipk
- <<: *run-additional-jobs
env: TARGET=rpm
- <<: *run-additional-jobs
env: TARGET=sonar-scan

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,70 @@
cmake_minimum_required (VERSION 2.8)
project (mraa C)
project (mraa C CXX)
FIND_PACKAGE (Threads REQUIRED)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer ")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall ")
###############################################################################
# Detect supported warning flags
# Modified from work By Dan Liew (fpbench - MIT)
# https://github.com/delcypher/fp-bench/blob/master/CMakeLists.txt
###############################################################################
# Warnings for both the C and C++ compiler
set (MRAA_BOTH_WARNING_FLAGS
-Wall
-Werror=main
-Wformat
-Wmain
-Wuninitialized
-Winit-self
)
# Warning flags for the C compiler only
set (MRAA_C_WARNING_FLAGS
-Werror=implicit
-Werror=missing-parameter-type
)
# Warning flags for the C++ compiler only
set (MRAA_CXX_WARNING_FLAGS
-Wnon-virtual-dtor
-Woverloaded-virtual
-Wreorder
)
include (CheckCCompilerFlag)
include (CheckCXXCompilerFlag)
function (MRAA_SANITIZE_FLAG_NAME OUTPUT_VAR FLAG)
string (REPLACE "-" "_" SANITIZED_FLAG_NAME "${FLAG}")
string (REPLACE "/" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
string (REPLACE "=" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
string (REPLACE " " "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
set (${OUTPUT_VAR} "${SANITIZED_FLAG_NAME}" PARENT_SCOPE)
endfunction ()
# Globally set C compiler warning flags that are supported and emit
# a warning about unsupported flags
foreach (flag ${MRAA_BOTH_WARNING_FLAGS} ${MRAA_C_WARNING_FLAGS})
MRAA_SANITIZE_FLAG_NAME(SANITIZED_FLAG_NAME "${flag}")
CHECK_C_COMPILER_FLAG("${flag}" HAS_C_${SANITIZED_FLAG_NAME})
if (HAS_C_${SANITIZED_FLAG_NAME})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
else ()
message (WARNING "C compiler does not support flag \"${flag}\"")
endif ()
endforeach ()
# Globally set C++ compiler warning flags that are supported and emit
# a warning about unsupported flags
foreach (flag ${MRAA_BOTH_WARNING_FLAGS} ${MRAA_CXX_WARNING_FLAGS})
MRAA_SANITIZE_FLAG_NAME (SANITIZED_FLAG_NAME "${flag}")
CHECK_CXX_COMPILER_FLAG ("${flag}" HAS_CXX_${SANITIZED_FLAG_NAME})
if (HAS_CXX_${SANITIZED_FLAG_NAME})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
else ()
message (WARNING "C++ compiler does not support flag \"${flag}\"")
endif ()
endforeach ()
# Set CMAKE_INSTALL_LIBDIR if not defined
include(GNUInstallDirs)
@@ -31,7 +91,7 @@ include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
message (WARNING " - Install git to compile a production libmraa!")
set (VERSION "v1.2.3-dirty")
set (VERSION "v1.7.0")
endif ()
message (STATUS "INFO - libmraa Version ${VERSION}")
@@ -78,8 +138,9 @@ option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
option (ENABLEEXAMPLES "Disable building of examples" ON)
option (INSTALLGPIOTOOL "Install gpio tool" OFF)
option (INSTALLTOOLS "Install all tools" OFF)
option (INSTALLTOOLS "Install all tools" ON)
option (BUILDTESTS "Override the addition of tests" ON)
option (USEPYTHON3TESTS "Force tests to run with python3" OFF)
set (BUILDARCH "" CACHE STRING "Override architecture to build for")
@@ -107,8 +168,10 @@ elseif (DETECTED_ARCH MATCHES "arm.*")
set (ARMPLAT ON)
elseif (DETECTED_ARCH STREQUAL "MOCK")
set (MOCKPLAT ON)
elseif (DETECTED_ARCH STREQUAL "PERIPHERALMAN")
set (PERIPHERALMAN ON)
else ()
message (FATAL_ERROR "Only x86, arm and mock platforms currently supported")
message (FATAL_ERROR "Only x86, arm, PERIPHERALMAN and mock platforms currently supported")
endif()
if (BUILDSWIGPYTHON OR BUILDTESTS)

View File

@@ -10,7 +10,8 @@ with:
The recommended method to contribute is to fork on github, and then send pull
requests to the main project. You can open issues if you find any bugs/have
questions.
questions. If you want to work on a large feature then we suggest you file an
issue first so we can avoid dissapointments come merging time!
If you'd rather not use github you are more than welcome to send git formatted
patches to our mailing list mraa@lists.01.org which you can register for access
@@ -42,6 +43,16 @@ job. Few exceptions to coding styles:
Use common sense and don't be afraid to challenge something if it doesn't make sense!
Author Rules
------------
If you create a file, then add yourself as the Author at the top. If you did a
large contribution to it (or if you want to ;-)), then fee free to add yourself
to the contributors list in that file. You can also add your own copyright
statement to the file but cannot add a license of your own. If you're borrowing
code that comes from a project with another license, make sure to explicitly
note this in your PR.
Code signing
------------

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

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

View File

@@ -1,8 +1,9 @@
<p align="center">
<img src="http://iotdk.intel.com/misc/logos/mraa.png" height="150px" width="auto" algt="Mraa Logo"/>
</p>
libmraa - Low Level Skeleton Library for Communication on GNU/Linux platforms
==============
=============================================================================
Libmraa is a C/C++ library with bindings to Java, Python and JavaScript to
interface with the IO on Galileo, Edison & other platforms, with a structured
@@ -26,34 +27,100 @@ X86
* [Galileo Gen 2 - Rev H](../master/docs/galileorevh.md)
* [Edison](../master/docs/edison.md)
* [Intel DE3815](../master/docs/intel_de3815.md)
* [Minnowboard Max](../master/docs/minnow_max.md)
* [Minnowboard](../master/docs/minnow_max.md)
* [NUC 5th generation](../master/docs/intel_nuc5.md)
* [UP](../master/docs/up.md)
* [Intel Grosse Tete](../master/docs/grossetete.md)
* [Intel Joule](../master/docs/joule.md)
ARM
---
* [Raspberry Pi](../master/docs/raspberry_pi.md)
* [Bannana Pi](../master/docs/banana_pi.md)
* [Banana Pi](../master/docs/banana_pi.md)
* [Beaglebone Black](../master/docs/beaglebone.md)
* [phyBOARD-Wega](../master/docs/phyboard-wega.md)
* [96Boards](../master/docs/96boards.md)
FPGA
----
* [DE10-Nano](../master/docs/de_nano_soc.md)
USB
---
* [FT4222](../master/docs/ftdi_ft4222.md)
* [Firmata](../master/docs/firmata.md)
Mock
----
* [Generic simulated board](../master/docs/mock.md)
JSON platform
----
* [Platform loading](../master/docs/jsonplatform.md)
Installing on your board
========
========================
Installing on Ubuntu
--------------------
Here is a PPA for installing on ubuntu:
https://launchpad.net/~mraa/+archive/ubuntu/mraa
```bash
sudo add-apt-repository ppa:mraa/mraa
sudo apt-get update
sudo apt-get install libmraa1 libmraa-dev mraa-tools python-mraa python3-mraa
```
Node.js package is available separately.
Install on Arch Linux
---------------------
There is an AUR package for mraa here: https://aur.archlinux.org/packages/mraa
Install on openSUSE
-------------------
```bash
REPO="openSUSE_Tumbleweed"
if test "$(arch)" == "aarch64"; then
REPO="openSUSE_Factory_ARM"
fi
sudo zypper ar http://download.opensuse.org/repositories/hardware/$REPO/hardware.repo
sudo zypper in mraa
```
Installing for Node.js only
---------------------------
> Note: Node.js 7.0.0+ is not supported. You'll have to downgrade to 6.x.x.
You can also install just the node.js mraa module by using npm. You will need a
C++ compiler and the node development headers, however it's not required to
have SWIG installed.
```bash
npm install mraa
```
Note that installing mraa in this way builds mraa without json-c so you cannot
use mraa_init_json_platform(). Also building this way means the mraa.node
includes a static version of libmraa rather than relying on a dynamic library
in /usr/lib.
Subplatforms (i.e. Firmata) have to be added manually with this kind of install
from your application, as shown in [this example](examples/javascript/firmata.js).
Installing on Intel 32bit Yocto based opkg image
------------------------------------------------
See the section below on compiling or use our repository to install on a glibc
based yocto poky image that supports opkg. Adding this repository is as simple
as and you'll have the latest stable tagged build of mraa installed!
``` bash
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
echo "src mraa-upm http://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
opkg update
opkg install mraa
```
@@ -62,19 +129,11 @@ If you would like to get the latest & greatest builds from master HEAD you can
use our -dev repository
```bash
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf
echo "src mraa-upm http://iotdk.intel.com/repos/3.5/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf
opkg update
opkg install mraa
```
You can also install just the node.js mraa module by using npm. You will need a
C++ compiler and the node development headers, however it's not required to
have SWIG installed.
```bash
npm install mraa
```
Compiling
=========

View File

@@ -51,7 +51,9 @@ extern "C" {
typedef struct _aio* mraa_aio_context;
/**
* Initialise an Analog input device, connected to the specified pin
* Initialise an Analog input device, connected to the specified pin. Aio pins
* are always 0 indexed reguardless of their position. Check your board mapping
* for details. An arduino style layout will have A0 as pin14 but AIO0.
*
* @param pin Channel number to read ADC inputs
* @returns aio context or NULL

View File

@@ -56,9 +56,11 @@ class Aio
}
/**
* Aio Constructor, takes a pointer to the AIO context and initialises
* the AIO class
* the AIO class. Aio pins are always 0 indexed reguardless of their
* position. Check your board mapping for details. An arduino style layout
* will have A0 as pin14 but AIO0.
*
* @param void * to an AIO context
* @param aio_context void * to an AIO context
*/
Aio(void* aio_context)
{

View File

@@ -27,13 +27,19 @@
#include <stdint.h>
#include "types.h"
/** Max size off Mraa Platform name */
#define MRAA_PLATFORM_NAME_MAX_SIZE 64
/** Size off Mraa pin name */
#define MRAA_PIN_NAME_SIZE 12
/** Bit Shift for Mraa sub platform */
#define MRAA_SUB_PLATFORM_BIT_SHIFT 9
/** Mask for Mraa sub platform */
#define MRAA_SUB_PLATFORM_MASK (1<<MRAA_SUB_PLATFORM_BIT_SHIFT)
/** Mraa main platform offset */
#define MRAA_MAIN_PLATFORM_OFFSET 0
/** Mraa sub platform offset */
#define MRAA_SUB_PLATFORM_OFFSET 1
/** Executes function func and returns its result in case of error
@@ -85,7 +91,7 @@ mraa_result_t mraa_init() __attribute__((constructor));
* people who like super clean code. If dynamically loading & unloading
* libmraa you need to call this before unloading the library.
*/
void mraa_deinit();
void mraa_deinit() __attribute__((destructor));
/**
* Checks if a pin is able to use the passed in mode.
@@ -106,7 +112,7 @@ unsigned int mraa_adc_raw_bits();
/**
* Check the specified board's bit size when reading the value
*
* @param specified platform offset; 0 for main platform, 1 foor sub platform
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
* @return raw bits being read from kernel module. zero if no ADC
*/
unsigned int mraa_get_platform_adc_raw_bits(uint8_t platform_offset);
@@ -121,7 +127,7 @@ unsigned int mraa_adc_supported_bits();
/**
* Return value that the raw value should be shifted to. Zero if no ADC
*
* @param specified platform offset; 0 for main platform, 1 foor sub platform
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
* @return return actual bit size the adc value should be understood as.
*/
unsigned int mraa_get_platform_adc_supported_bits(int platform_offset);
@@ -146,7 +152,7 @@ const char* mraa_get_platform_name();
* platform and can be NULL. platform_offset has to be given. Do not modify
* this pointer
*
* @param specified platform offset; 0 for main platform, 1 for sub platform
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
* @return platform's versioning string
*/
const char* mraa_get_platform_version(int platform_offset);
@@ -201,6 +207,41 @@ int mraa_get_platform_combined_type();
*/
unsigned int mraa_get_pin_count();
/**
* Get the number of usable UARTs, board must be initialised.
*
* @return number of usable UARTs on the platform, returns -1 on failure.
*/
int mraa_get_uart_count(void);
/**
* Get the number of usable SPI buses, board must be initialised.
*
* @return number of usable SPI buses on the platform, returns -1 on failure.
*/
int mraa_get_spi_bus_count(void);
/**
* Get the number of usable PWM pins, board must be initialised.
*
* @return number of PWMs on the current platform, -1 on failure.
*/
int mraa_get_pwm_count(void);
/**
* Get the number of usable GPIOs, board must be initialised.
*
* @return number of usable external GPIO pins on the board, -1 on failure.
*/
int mraa_get_gpio_count(void);
/**
* Get the number of usable analog pins, board must be initialised.
*
* @return number of usable ADC inputs on the platform and -1 on failure.
*/
int mraa_get_aio_bus_count(void);
/**
* Get platform usable I2C bus count, board must be initialised.
*
@@ -220,7 +261,7 @@ int mraa_get_i2c_bus_id(int i2c_bus);
/**
* Get specified platform pincount, board must be initialised.
*
* @param specified platform offset; 0 for main platform, 1 foor sub platform
* @param platform_offset specified platform offset; 0 for main platform, 1 for sub platform
* @return uint of physical pin count on the in-use platform
*/
unsigned int mraa_get_platform_pin_count(uint8_t platform_offset);
@@ -233,6 +274,46 @@ unsigned int mraa_get_platform_pin_count(uint8_t platform_offset);
*/
char* mraa_get_pin_name(int pin);
/**
* Get GPIO index by pin name, board must be initialised.
*
* @param pin_name: GPIO pin name. Eg: IO0
* @return int of MRAA index for GPIO or -1 if not found.
*/
int mraa_gpio_lookup(const char* pin_name);
/**
* Get I2C bus index by bus name, board must be initialised.
*
* @param i2c_name: I2C bus name. Eg: I2C6
* @return int of MRAA index for I2C bus or -1 if not found.
*/
int mraa_i2c_lookup(const char* i2c_name);
/**
* Get SPI bus index by bus name, board must be initialised.
*
* @param spi_name: Name of SPI bus. Eg: SPI2
* @return int of MRAA index for SPI bus or -1 if not found.
*/
int mraa_spi_lookup(const char* spi_name);
/**
* Get PWM index by PWM name, board must be initialised.
*
* @param pwm_name: Name of PWM. Eg:PWM0
* @return int of MRAA index for PWM or -1 if not found.
*/
int mraa_pwm_lookup(const char* pwm_name);
/**
* Get UART index by name, board must be initialised.
*
* @param uart_name: Name of UART. Eg:UART1
* @return int of MRAA index for UART, or -1 if not found.
*/
int mraa_uart_lookup(const char* uart_name);
/**
* Get default i2c bus, board must be initialised.
*
@@ -251,7 +332,7 @@ mraa_boolean_t mraa_has_sub_platform();
/**
* Check if pin or bus id includes sub platform mask.
*
* @param int pin or bus number
* @param pin_or_bus_id pin or bus number
*
* @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
*/
@@ -260,7 +341,7 @@ mraa_boolean_t mraa_is_sub_platform_id(int pin_or_bus_id);
/**
* Convert pin or bus index to corresponding sub platform id.
*
* @param int pin or bus index
* @param pin_or_bus_index pin or bus index
*
* @return int sub platform pin or bus number
*/
@@ -269,7 +350,7 @@ int mraa_get_sub_platform_id(int pin_or_bus_index);
/**
* Convert pin or bus sub platform id to index.
*
* @param int sub platform pin or bus id
* @param pin_or_bus_id sub platform pin or bus id
*
* @return int pin or bus index
*/
@@ -278,8 +359,8 @@ 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 uart_dev uart device subplatform is on
*
* @return mraa_result_t indicating success
*/
@@ -288,7 +369,7 @@ mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char*
/**
* Remove a mraa subplatform
*
* @param subplatform type
* @param subplatformtype subplatform type
*
* @return mraa_result indicating success
*/
@@ -301,7 +382,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 +391,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

@@ -27,6 +27,8 @@
#include "common.h"
#include "types.hpp"
#include <string>
#include <sstream>
#include <stdexcept>
/**
* @namespace mraa namespace
@@ -97,7 +99,7 @@ getPlatformType()
/**
* Print a textual representation of the mraa::Result
*
* @param Result the Result to print
* @param result the Result to print
*/
inline void
printError(Result result)
@@ -155,7 +157,7 @@ getPlatformName()
/**
* Return platform versioning info. Returns NULL if no info present.
*
* @param optional subplatform identifier
* @param platform_offset optional subplatform identifier
* @return platform versioning info
*/
inline std::string
@@ -176,6 +178,18 @@ getPinCount()
return mraa_get_pin_count();
}
/**
* Get platform usable UART count, board must be initialised.
*
* @return number of usable UARTs on the current platform. Function will
* return -1 on failure
*/
inline int
getUartCount()
{
return mraa_get_uart_count();
}
/**
* Get platform usable I2C bus count, board must be initialised.
*
@@ -214,6 +228,111 @@ getPinName(int pin)
return ret_val;
}
/**
* Get GPIO index by pin name, board must be initialised.
*
* @param pin_name: GPIO pin name. Eg: IO0
* @throws std::invalid_argument if name is not found
* @return int of MRAA index for GPIO
*/
inline int
getGpioLookup(std::string pin_name)
{
int index = mraa_gpio_lookup(pin_name.c_str());
if (index < 0){
std::ostringstream oss;
oss << "Gpio name " << pin_name << " is not valid";
throw std::invalid_argument(oss.str());
}
return index;
}
/**
* Get I2C bus index by bus name, board must be initialised.
*
* @param i2c_name: I2C bus name. Eg: I2C6
* @throws std::invalid_argument if name is not found
* @return int of MRAA index for I2C bus
*/
inline int
getI2cLookup(std::string i2c_name)
{
int index = mraa_i2c_lookup(i2c_name.c_str());
if (index < 0){
std::ostringstream oss;
oss << "i2c name " << i2c_name << " is not valid";
throw std::invalid_argument(oss.str());
}
return index;
}
/**
* Get SPI bus index by bus name, board must be initialised.
*
* @param spi_name: Name of SPI bus. Eg: SPI2
* @throws std::invalid_argument if name is not found
* @return int of MRAA index for SPI bus
*/
inline int
getSpiLookup(std::string spi_name)
{
int index = mraa_spi_lookup(spi_name.c_str());
if (index < 0){
std::ostringstream oss;
oss << "Spi name " << spi_name << " is not valid";
throw std::invalid_argument(oss.str());
}
return index;
}
/**
* Get PWM index by PWM name, board must be initialised.
*
* @param pwm_name: Name of PWM. Eg:PWM0
* @throws std::invalid_argument if name is not found
* @return int of MRAA index for PWM
*/
inline int
getPwmLookup(std::string pwm_name)
{
int index = mraa_pwm_lookup(pwm_name.c_str());
if (index < 0){
std::ostringstream oss;
oss << "PWM name " << pwm_name << " is not valid";
throw std::invalid_argument(oss.str());
}
return index;
}
/**
* Get UART index by UART name, board must be initialised.
*
* @param uart_name: Name of the UART. Eg: UART2
* @throws std::invalid_argument if name is not found
* @return MRAA index for the UART
*/
inline int
getUartLookup(std::string uart_name)
{
int index = mraa_uart_lookup(uart_name.c_str());
if (index < 0) {
std::ostringstream oss;
oss << "UART name " << uart_name << " is not valid";
throw std::invalid_argument(oss.str());
}
return index;
}
/**
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
* syslog log levels, see syslog(3) for more information on the levels.
@@ -241,7 +360,7 @@ hasSubPlatform()
/**
* Check if pin or bus id includes sub platform mask.
*
* @param int pin or bus number
* @param pin_or_bus_id pin or bus number
*
* @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
*/
@@ -254,7 +373,7 @@ isSubPlatformId(int pin_or_bus_id)
/**
* Convert pin or bus index to corresponding sub platform id.
*
* @param int pin or bus index
* @param pin_or_bus_index pin or bus index
*
* @return int sub platform pin or bus number
*/
@@ -267,7 +386,7 @@ getSubPlatformId(int pin_or_bus_index)
/**
* Convert pin or bus sub platform id to index.
*
* @param int sub platform pin or bus id
* @param pin_or_bus_id sub platform pin or bus id
*
* @return int pin or bus index
*/
@@ -280,7 +399,7 @@ getSubPlatformIndex(int pin_or_bus_id)
/**
* Get default i2c bus, board must be initialised.
*
* @param optional subplatform identifier
* @param platform_offset optional subplatform identifier
* @return default i2c bus for paltform
*/
inline int
@@ -303,6 +422,13 @@ addSubplatform(Platform subplatformtype, std::string uart_dev)
return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, uart_dev.c_str());
}
/**
* Remove mraa subplatform
*
* @param subplatformtype the type of subplatform to remove
* (e.g. MRAA_GENERIC_FIRMATA)
* @return Result of operation
*/
inline Result
removeSubplatform(Platform subplatformtype)
{
@@ -316,7 +442,7 @@ removeSubplatform(Platform subplatformtype)
* [io]-[raw]-[id]-[pin]
* [io]-[raw]-[path]
*
* @param IO description
* @param desc description
*
* @return class T initialised using pointer to IO or NULL
*/
@@ -330,7 +456,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

@@ -52,7 +52,7 @@ typedef struct _firmata* mraa_firmata_context;
* Initialise firmata context on a feature. This feature is what will be
* listened on if you request a response callback
*
* @param firmata feature
* @param feature firmata feature
* @return firmata context or NULL
*/
mraa_firmata_context mraa_firmata_init(int feature);

View File

@@ -46,9 +46,7 @@ extern "C" {
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include <jni.h>
extern "C" {
void mraa_java_isr_callback(void *args);
}
void mraa_java_isr_callback(void *args);
#endif
/**
@@ -63,7 +61,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 +87,23 @@ typedef enum {
MRAA_GPIO_EDGE_FALLING = 3 /**< Interrupt on falling only */
} mraa_gpio_edge_t;
/**
* Gpio input modes
*/
typedef enum {
MRAA_GPIO_ACTIVE_HIGH = 0, /**< Resistive High */
MRAA_GPIO_ACTIVE_LOW = 1, /**< Resistive Low */
} mraa_gpio_input_mode_t;
/**
* Gpio output driver modes
*/
typedef enum {
MRAA_GPIO_OPEN_DRAIN = 0, /**< Open Drain Configuration */
MRAA_GPIO_PUSH_PULL = 1, /**< Push Pull Configuration */
} mraa_gpio_out_driver_mode_t;
/**
* Initialise gpio_context, based on board number
*
@@ -94,6 +112,8 @@ typedef enum {
*/
mraa_gpio_context mraa_gpio_init(int pin);
mraa_gpio_context mraa_gpio_init_multiple(int pins[], int num_pins);
/**
* Initialise gpio context without any mapping to a pin
*
@@ -111,6 +131,8 @@ 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);
mraa_result_t mraa_gpio_edge_mode_multiple(mraa_gpio_context dev, mraa_gpio_edge_t mode);
/**
* Set an interrupt on pin
*
@@ -123,6 +145,8 @@ 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);
mraa_result_t mraa_gpio_isr_multiple(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (*fptr)(void*), void* args);
/**
* Stop the current interrupt watcher on this Gpio, and set the Gpio edge mode
* to MRAA_GPIO_EDGE_NONE
@@ -150,6 +174,8 @@ mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode);
*/
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir);
mraa_result_t mraa_gpio_dir_multiple(mraa_gpio_context dev, mraa_gpio_dir_t dir);
/**
* Read Gpio direction
*
@@ -168,6 +194,8 @@ mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir);
*/
mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
mraa_result_t mraa_gpio_close_multiple(mraa_gpio_context dev);
/**
* Read the Gpio value. This can be 0 or 1. A resonse of -1 means that there
* was a fatal error.
@@ -177,6 +205,11 @@ mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
*/
int mraa_gpio_read(mraa_gpio_context dev);
/* Values array is provided by user. Must be the same size as the array passed in init.
* It will be overwritten with the read results.
*/
mraa_result_t mraa_gpio_read_multiple(mraa_gpio_context dev, int output_values[]);
/**
* Write to the Gpio Value.
*
@@ -186,6 +219,8 @@ int mraa_gpio_read(mraa_gpio_context dev);
*/
mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
mraa_result_t mraa_gpio_write_multiple(mraa_gpio_context dev, int input_values[]);
/**
* Change ownership of the context.
*
@@ -220,6 +255,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

@@ -69,6 +69,22 @@ typedef enum {
EDGE_FALLING = 3 /**< Interrupt on falling only */
} Edge;
/**
* Gpio Input modes
*/
typedef enum {
MODE_IN_ACTIVE_HIGH = 0, /**< Resistive High */
MODE_IN_ACTIVE_LOW = 1, /**< Resistive Low */
} InputMode;
/**
* Gpio output driver modes
*/
typedef enum {
MODE_OUT_OPEN_DRAIN = 0, /**< Open Drain Configuration */
MODE_OUT_PUSH_PULL = 1, /**< Push Pull Configuration */
} OutputMode;
/**
* @brief API to General Purpose IO
*
@@ -111,7 +127,7 @@ class Gpio
* Gpio Constructor, takes a pointer to the GPIO context and initialises
* the GPIO class
*
* @param void * to GPIO context
* @param gpio_context void * to GPIO context
*/
Gpio(void* gpio_context)
{
@@ -316,6 +332,30 @@ class Gpio
return mraa_gpio_get_pin(m_gpio);
}
/**
* Change Gpio input mode
*
* @param mode The mode to change the gpio input
* @return Result of operation
*/
Result
inputMode(InputMode mode)
{
return (Result )mraa_gpio_input_mode(m_gpio, (mraa_gpio_input_mode_t) mode);
}
/**
* Change Gpio output driver mode
*
* @param mode @param mode Set output driver mode
* @return Result of operation
*/
Result
outputMode(OutputMode mode)
{
return (Result) mraa_gpio_out_driver_mode(m_gpio, (mraa_gpio_out_driver_mode_t) mode);
}
private:
mraa_gpio_context m_gpio;
#if defined(SWIGJAVASCRIPT)

View File

@@ -45,7 +45,7 @@ class I2c
public:
/**
* Instantiates an i2c bus. Multiple instances of the same bus can
* exist and the bus is not guarranteed to be on the correct address
* exist and the bus is not guaranteed to be on the correct address
* before read/write.
*
* @param bus The i2c bus to use
@@ -65,7 +65,7 @@ class I2c
/**
* I2C constructor, takes a pointer to a I2C context and initialises the I2C class
*
* @param void * to an I2C context
* @param i2c_context void * to an I2C context
*/
I2c(void* i2c_context)
{
@@ -76,7 +76,7 @@ class I2c
}
/**
* Closes the I2c Bus used. This does not guarrantee the bus will not
* Closes the I2c Bus used. This does not guarantee the bus will not
* be usable by anyone else or communicates this disconnect to any
* slaves.
*/

View File

@@ -27,22 +27,37 @@
#include "common.h"
#include "iio_kernel_headers.h"
/** Mraa Iio Channels */
typedef struct {
/** Channel index */
int index;
/** Channel enabled/disabled */
int enabled;
/** Channel type */
char* type;
/** Channel endianes */
mraa_boolean_t lendian;
/** Channel signed */
int signedd;
/** Channel offset */
unsigned int offset;
/** Channel mask */
uint64_t mask;
/** Channel used bits */
unsigned int bits_used;
/** Channel bytes */
unsigned int bytes;
/** Channel shift */
unsigned int shift;
/** Channel location */
unsigned int location;
} mraa_iio_channel;
/** Mraa Iio Event */
typedef struct {
/** Event name */
char* name;
/** Event enabled/disabled */
int enabled;
} mraa_iio_event;
@@ -74,44 +89,171 @@ typedef struct _iio* mraa_iio_context;
/**
* Initialise iio context
*
* @param bus iio device to use
* @param device iio device to use
* @return i2c context or NULL
*/
mraa_iio_context mraa_iio_init(int device);
/**
* 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* data), void* args);
/**
* Get device name
*
* @param dev The iio context
* @return Name of the device
*/
const char* mraa_iio_get_device_name(mraa_iio_context dev);
/**
* Get device number
*
* @param name Name of the device
* @return Device Number
*/
int mraa_iio_get_device_num_by_name(const char* name);
/**
* Read size
*
* @param dev The iio context
* @return Size
*/
int mraa_iio_read_size(mraa_iio_context dev);
/**
* Get channels
*
* @param dev The iio context
* @return Channels
*/
mraa_iio_channel* mraa_iio_get_channels(mraa_iio_context dev);
/**
* Get channels count
*
* @param dev The iio context
* @return Channels count
*/
int mraa_iio_get_channel_count(mraa_iio_context dev);
/**
* Read float from file
*
* @param dev The iio context
* @param filename Filename
* @param data Data
* @return Result of operation
*/
mraa_result_t mraa_iio_read_float(mraa_iio_context dev, const char* filename, float* data);
/**
* Read int from file
*
* @param dev The iio context
* @param filename Filename
* @param data Data
* @return Result of operation
*/
mraa_result_t mraa_iio_read_int(mraa_iio_context dev, const char* filename, int* data);
/**
* Read String from file
*
* @param dev The iio context
* @param filename Filename
* @param data Data
* @param max_len Max lenght to read
* @return Result of operation
*/
mraa_result_t mraa_iio_read_string(mraa_iio_context dev, const char* filename, char* data, int max_len);
/**
* Write float
*
* @param dev The iio context
* @param attr_chan Channel attributes
* @param data Float to write
* @return Result of operation
*/
mraa_result_t mraa_iio_write_float(mraa_iio_context dev, const char* attr_chan, const float data);
/**
* Write int
*
* @param dev The iio context
* @param attr_chan Channel attributes
* @param data Int to write
* @return Result of operation
*/
mraa_result_t mraa_iio_write_int(mraa_iio_context dev, const char* attr_chan, const int data);
/**
* Write string
*
* @param dev The iio context
* @param attr_chan Channel attributes
* @param data String to write
* @return Result of operation
*/
mraa_result_t mraa_iio_write_string(mraa_iio_context dev, const char* attr_chan, const char* data);
/**
* Get channel data
*
* @param dev The iio context
* @return Result of operation
*/
mraa_result_t mraa_iio_get_channel_data(mraa_iio_context dev);
/**
* Get event data
*
* @param dev The iio context
* @return Result of operation
*/
mraa_result_t mraa_iio_get_event_data(mraa_iio_context dev);
/**
* Event poll
*
* @param dev The iio context
* @param data Data
* @return Result of operation
*/
mraa_result_t mraa_iio_event_poll(mraa_iio_context dev, struct iio_event_data* data);
/**
* Setup event callback
*
* @param dev The iio context
* @param fptr Callback
* @param args Arguments
* @return Result of operation
*/
mraa_result_t
mraa_iio_event_setup_callback(mraa_iio_context dev, void (*fptr)(struct iio_event_data* data, void* args), void* args);
/**
* Extract event
*
* @param event Event
* @param chan_type Channel type
* @param modifier Modifier
* @param type Type
* @param direction Direction
* @param channel Channel
* @param channel2 Channel2
* @param different Different
* @return Result of operation
*/
mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
int* chan_type,
int* modifier,
@@ -121,11 +263,32 @@ mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
int* channel2,
int* different);
/**
* 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

@@ -25,28 +25,40 @@
#pragma once
#include <stdexcept>
#include <sstream>
#include <sstream>
#include "iio.h"
#include "types.hpp"
namespace mraa
{
/** Iio Event Data */
struct IioEventData
{
/** Channel Type */
int channelType;
/** Modifier */
int modifier;
/** Type */
int type;
/** Direction */
int direction;
/** Channel */
int channel;
/** Channel 2 */
int channel2;
/** Difference */
int diff;
};
/** Iio Handler */
class IioHandler
{
public:
/** onIioEvent Handler */
virtual void onIioEvent(const IioEventData& eventData) = 0;
/** Destructor */
virtual ~IioHandler() {}; // add an empty destructor to get rid of warning
};
@@ -55,7 +67,7 @@ public:
*
* This file defines the C++ iio interface for libmraa
*
* @snippet iio_dummy_test.cpp Interesting
* @snippet Iio-dummy.cpp Interesting
*/
class Iio
{

View File

@@ -115,12 +115,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;
};

View File

@@ -45,6 +45,7 @@ extern "C" {
#include "common.h"
/** Mraa Pwm Context */
typedef struct _pwm* mraa_pwm_context;
/**

View File

@@ -71,7 +71,7 @@ class Pwm
* Pwm constructor, takes a pointer to the PWM context and
* initialises the class
*
* @param void * to a PWM context
* @param pwm_context void * to a PWM context
*/
Pwm(void* pwm_context)
{

View File

@@ -70,6 +70,12 @@ class Spi
}
}
/**
* Initialise SPI object using 'raw' mode. Mraa will go and grab the spidev device lablled /dev/spidev[bus].[cs]
*
* @param bus to use
* @param cs to use
*/
Spi(int bus, int cs)
{
m_spi = mraa_spi_init_raw(bus, cs);
@@ -83,7 +89,7 @@ class Spi
* Spi Constructor, takes a pointer to a SPI context and initialises
* the SPI class
*
* @param void * to SPI context
* @param spi_context void * to SPI context
*/
Spi(void* spi_context)
{

View File

@@ -46,11 +46,16 @@ typedef enum {
MRAA_BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
MRAA_BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
MRAA_INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */
MRAA_96BOARDS = 9, /**< Linaro 96boards */
MRAA_96BOARDS = 9, /**< Linaro 96boards */
MRAA_INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
MRAA_UP = 12, /**< The UP Board */
MRAA_INTEL_GT_TUCHUCK = 13, /**< The Intel GT Tuchuck Board */
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
MRAA_UP = 12, /**< The UP Board */
MRAA_INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
#if __STDC_VERSION__ >= 199901L
MRAA_INTEL_GT_TUCHUCK = MRAA_INTEL_JOULE_EXPANSION, // deprecated
#endif
MRAA_PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
MRAA_DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
// USB platform extenders start at 256
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
@@ -58,6 +63,7 @@ typedef enum {
// contains bit 9 so is subplatform
MRAA_GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
MRAA_ANDROID_PERIPHERALMANAGER = 95, /**< Android Things peripheral manager platform */
MRAA_MOCK_PLATFORM = 96, /**< Mock platform, which requires no real hardware */
MRAA_JSON_PLATFORM = 97, /**< User initialised platform from json*/
MRAA_NULL_PLATFORM = 98, /**< Platform with no capabilities that hosts a sub platform */
@@ -239,12 +245,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

@@ -51,12 +51,15 @@ typedef enum {
INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
INTEL_UP = 12, /**< The UP Board */
INTEL_GT_TUCHUCK = 13, /**< The Intel GT Board */
INTEL_JOULE_EXPANSION = 13,/**< The Intel Joule Expansion Board */
PHYBOARD_WEGA = 14, /**< The phyBOARD-Wega */
DE_NANO_SOC = 15, /**< Terasic DE-Nano-SoC Board */
FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
ANDROID_PERIPHERALMANAGER = 95, /**< Android Things peripheral manager platform */
NULL_PLATFORM = 98,
UNKNOWN_PLATFORM =
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
@@ -228,7 +231,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 +239,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

@@ -45,6 +45,7 @@ extern "C" {
#include "common.h"
/** Mraa Uart Context */
typedef struct _uart* mraa_uart_context;
/**
@@ -72,6 +73,18 @@ mraa_uart_context mraa_uart_init_raw(const char* path);
*/
mraa_result_t mraa_uart_flush(mraa_uart_context dev);
/**
* Send a break to the device.
* Blocks until complete.
*
* @param dev The UART context
* @param duration When 0, send a break lasting at least 250
* milliseconds, and not more than 500 milliseconds. When non zero,
* the break duration is implementation specific.
* @return Result of operation
*/
mraa_result_t mraa_uart_sendbreak(mraa_uart_context dev, int duration);
/**
* Set the baudrate.
* Takes an int and will attempt to decide what baudrate is
@@ -136,6 +149,41 @@ mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t n
*/
const char* mraa_uart_get_dev_path(mraa_uart_context dev);
/**
* Get the current settings of an UART. This is an unintrusive function. Meaning
* it intends not to change anything, only read the values without disturbing.
*
* All but the first index parameter are "outparameters". That means they can
* contain values on return. If any parameter is not interesting, a null pointer
* can be sent instead as a placeholder.
* The devpath parameter can be either in or out parameter. In case of a negative
* index, the UART is identified using *devpath instead. This functionality is
* intended for and needed by for instance USB serial adapters.
*
* In case of a non-success return value, the outparameters are undefined.
*
* @param index uart index to look up, if negative, *devpath will be used instead
* @param devpath points to the device path of the UART, eg: /dev/ttyS0
* @param name outparameter that on return will point to the name of the UART
* @param baudrate pointer to an integer to contain the current baudrate (0--4M)
* @param databits pointer to an integer to contain the number databits (5--8)
* @param stopbits pointer to an integer to contain the number stopbits (1--2)
* @param parity will contain the current parity mode
* @param rtscts will point to non-zero if CTS/RTS flow control is enabled, zero otherwise
* @param xonxoff will point to a non-zero value if xon/xoff flow control is enabled
* @return result
*/
mraa_result_t
mraa_uart_settings(int index,
const char **devpath,
const char **name,
int* baudrate,
int* databits,
int* stopbits,
mraa_uart_parity_t* parity,
unsigned int* rtscts,
unsigned int* xonxoff);
/**
* Destroy a mraa_uart_context
*

View File

@@ -64,7 +64,7 @@ class Uart
* Uart Constructor, takes a string to the path of the serial
* interface that is needed.
*
* @param uart the index of the uart set to use
* @param path the index of the uart set to use
*/
Uart(std::string path)
{
@@ -79,7 +79,7 @@ class Uart
* Uart Constructor, takes a pointer to the UART context and initialises
* the UART class
*
* @param void * to a UART context
* @param uart_context void * to a UART context
*/
Uart(void* uart_context)
{
@@ -124,7 +124,7 @@ class Uart
}
/**
* Write bytes in String object to a device
* Write bytes in char* buffer to a device
*
* @param data buffer pointer
* @param length maximum size of buffer
@@ -160,7 +160,7 @@ class Uart
/**
* Write bytes in String object to a device
*
* @param string to write
* @param data string to write
* @return the number of bytes written, or -1 if an error occurred
*/
int
@@ -197,6 +197,21 @@ class Uart
return (Result) mraa_uart_flush(m_uart);
}
/**
* Send a break to the device.
* Blocks until complete.
*
* @param duration When 0, send a break lasting at least 250
* milliseconds, and not more than 500 milliseconds. When non zero,
* the break duration is implementation specific.
* @return Result of operation
*/
Result
sendBreak(int duration)
{
return (Result) mraa_uart_sendbreak(m_uart, duration);
}
/**
* Set the baudrate.
* Takes an int and will attempt to decide what baudrate is
@@ -258,12 +273,11 @@ class Uart
/**
* Set the blocking state for write operations
*
* @param dev The UART context
* @param nonblock new nonblocking state
* @return Result of operation
*/
Result
SetNonBlocking(bool nonblock)
setNonBlocking(bool nonblock)
{
return (Result) mraa_uart_set_non_blocking(m_uart, nonblock);
}

View File

@@ -64,19 +64,23 @@ extern "C" {
#include "common.h"
#include "uart.h"
/* for now, we simply use the normal MRAA UART context */
/** 8 bytes (64 bits) for a device rom code */
#define MRAA_UART_OW_ROMCODE_SIZE 8
/** for now, we simply use the normal MRAA UART context */
typedef struct _mraa_uart_ow {
/** Uart Context */
mraa_uart_context uart;
/* search state */
unsigned char ROM_NO[8]; /* 8 byte (64b) rom code */
/** search state */
unsigned char ROM_NO[MRAA_UART_OW_ROMCODE_SIZE]; /* 8 byte (64b) rom code */
/** Context laxt discrepancy */
int LastDiscrepancy;
/** Context las family discrepancy */
int LastFamilyDiscrepancy;
/** Context las device flag */
mraa_boolean_t LastDeviceFlag;
} *mraa_uart_ow_context;
/* 8 bytes (64 bits) for a device rom code */
static const int MRAA_UART_OW_ROMCODE_SIZE = 8;
/**
* UART One Wire ROM related Command bytes
*/

View File

@@ -46,8 +46,8 @@ class UartOW
* UartOW Constructor, takes a pin number which will map directly to the
* linux uart number, this 'enables' the uart, nothing more
*
* @throws std::invalid_argument in case of error
* @param uart the index of the uart to use
* @throws std::invalid_argument in case of error
*/
UartOW(int uart)
{
@@ -62,8 +62,8 @@ class UartOW
* UartOW Constructor, takes a string to the path of the serial
* interface that is needed.
*
* @throws std::invalid_argument in case of error
* @param path the file path for the UART to use
* @throws std::invalid_argument in case of error
*/
UartOW(std::string path)
{
@@ -233,7 +233,7 @@ class UartOW
mraa::Result
command(uint8_t command, std::string id)
{
if (id.empty() == 0)
if (id.empty())
return (mraa::Result) mraa_uart_ow_command(m_uart, command, NULL);
else {
if (id.size() != 8) {
@@ -241,7 +241,7 @@ class UartOW
throw std::invalid_argument(std::string(__FUNCTION__) +
": id must be 8 bytes only");
}
return (mraa::Result) mraa_uart_ow_command(m_uart, command, (uint8_t*) id.c_str());
return (mraa::Result) mraa_uart_ow_command(m_uart, command, (uint8_t*) id.data());
}
}
@@ -268,7 +268,7 @@ class UartOW
uint8_t
crc8(std::string buffer)
{
return mraa_uart_ow_crc8((uint8_t*) buffer.c_str(), buffer.size());
return mraa_uart_ow_crc8((uint8_t*) buffer.data(), buffer.size());
}
private:

View File

@@ -23,13 +23,16 @@ if (UV_ROOT_DIR)
endif()
# Now look for node. Flag an error if not found
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h"
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h" "src/node.h"
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
if (NODE_ROOT_DIR)
add_include_dir(${NODE_ROOT_DIR}/include/src)
add_include_dir(${NODE_ROOT_DIR}/src)
add_include_dir(${NODE_ROOT_DIR}/include/node)
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
else()
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - node.h not found")

152
docker-compose.yaml Normal file
View File

@@ -0,0 +1,152 @@
version: '2.1'
services:
base:
image: dnoliver/mraa-base
environment:
- http_proxy
- https_proxy
- no_proxy
- BUILDDOC=${BUILDDOC:-OFF}
- BUILDSWIG=${BUILDSWIG:-OFF}
- BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF}
- BUILDTESTS=${BUILDTESTS:-ON}
- USEPYTHON3TESTS=${USEPYTHON3TESTS:-OFF}
- BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF}
- BUILDSWIGNODE=${BUILDSWIGNODE:-OFF}
- USBPLAT=${USBPLAT:-OFF}
- FIRMATA=${FIRMATA:-OFF}
- ONEWIRE=${ONEWIRE:-ON}
- JSONPLAT=${JSONPLAT:-OFF}
- IMRAA=${IMRAA:-OFF}
- FTDI4222=${FTDI4222:-OFF}
- IPK=${IPK:-OFF}
- RPM=${RPM:-OFF}
- ENABLEEXAMPLES=${ENABLEEXAMPLES:-ON}
- INSTALLGPIOTOOL=${INSTALLGPIOTOOL:-OFF}
- INSTALLTOOLS=${INSTALLTOOLS:-ON}
- CC=${CC:-clang-3.8}
- CXX=${CXX:-clang++-3.8}
- BUILDARCH=${BUILDARCH}
volumes:
- .:${MRAA_SRC_DIR:-/usr/src/app}
doc:
extends: base
image: dnoliver/mraa-all
environment:
- BUILDSWIG=ON
- BUILDSWIGPYTHON=ON
- BUILDSWIGNODE=ON
- BUILDSWIGJAVA=ON
- BUILDDOC=ON
command: bash -c "./scripts/run-cmake.sh && ./scripts/build-doc.sh"
sonar-scan:
extends: base
image: dnoliver/mraa-all
environment:
- BUILDSWIG=ON
- BUILDSWIGPYTHON=ON
- BUILDSWIGNODE=ON
- BUILDSWIGJAVA=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: base
image: dnoliver/mraa-all
environment:
- USBPLAT=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
firmata:
extends: base
image: dnoliver/mraa-all
environment:
- FIRMATA=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
imraa:
extends: base
image: dnoliver/mraa-all
environment:
- IMRAA=ON
- FIRMATA=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
ftdi4442:
extends: base
image: dnoliver/mraa-all
environment:
- FTDI4222=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild"
ipk:
extends: base
image: dnoliver/mraa-all
environment:
- IPK=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild package"
rpm:
extends: base
image: dnoliver/mraa-all
environment:
- RPM=ON
command: bash -c "./scripts/run-cmake.sh && make -Cbuild package"
python2:
extends: base
image: dnoliver/mraa-python
environment:
- BUILDSWIG=ON
- BUILDSWIGPYTHON=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make _python2-mraa && ctest --output-on-failure"
python3:
extends: python2
environment:
- USEPYTHON3TESTS=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make _python3-mraa && ctest --output-on-failure"
java:
extends: base
image: dnoliver/mraa-java
environment:
- BUILDSWIG=ON
- BUILDSWIGJAVA=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make mraajava && ctest --output-on-failure"
android:
extends: java
image: dnoliver/mraa-android
environment:
- BUILDARCH=PERIPHERALMAN
command: bash -c "./scripts/build-android.sh"
node4:
extends: base
image: dnoliver/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: dnoliver/mraa-node5
node6:
extends: node4
image: dnoliver/mraa-node6

56
docs/96boards.md Normal file
View File

@@ -0,0 +1,56 @@
96Boards Development Platform {#_96boards}
=============================
96Boards is a range of hardware specifications created by Linaro to make the latest ARM-based processors available to developers at a reasonable cost. The specifications are open and define a standard board layout for SoC-agnostic (processor independent) development platforms that can be used by software application, hardware device, kernel and other system software developers. Boards produced to the 96Boards specifications are suitable for rapid prototyping, hobbyist projects or incorporation into new systems for a wide range of applications including desktop and laptop computing, the digital home, digital signage, point of sale (POS), high-end audio, robotics and drones, artificial intelligence, virtual reality, IoT and industrial control.
Standardized expansion buses for peripheral I/O have led to a wide range of compatible add-on mezzanine boards that will work across a variety of 96Boards products. Users have access to a wide range of boards with different features at various price points. In addition, some SoC vendors have announced long term availability of the SoC to encourage their use in products with long life cycles.
Board Support
-------------
- [DragonBoard 410c](http://www.96boards.org/product/dragonboard410c/)
- [HiKey](http://www.96boards.org/product/hikey/)
- [Bubblegum-96](http://www.96boards.org/product/bubblegum-96/)
Interface notes
---------------
- **GPIO**: Pin 28 / GPIO-F is a Multi-Purpose pin
- **UART**: UART1 can be used for serial access
Pin Mapping
-----------
Pin mapping table shows signals pertaining to 40-pin low speed expansion header based on [96Boards Consumer Edition Specification](https://github.com/96boards/documentation/blob/master/Specifications/96Boards-CE-Specification.pdf).
| 96Boards Signals | PIN | PIN | 96Boards Signals |
|:------------------|:------|------:|:-------------------|
| GND | 1 | 2 | GND |
| UART0_CTS | 3 | 4 | PWR_BTN_N |
| UART0_TxD | 5 | 6 | RST_BTN_N |
| UART0_RxD | 7 | 8 | SPI0_SCLK |
| UART1_RTS | 9 | 10 | SPI0_DIN |
| UART1_TxD | 11 | 12 | SPI0_CS |
| UART1_RxD | 13 | 14 | SPI0_DOUT |
| I2C0_SCL | 15 | 16 | PCM_FS |
| I2C0_SDA | 17 | 18 | PCM_CLK |
| I2C1_SCL | 19 | 20 | PCM_DO |
| I2C1_SDA | 21 | 22 | PCM_DI |
| GPIO-A | 23 | 24 | GPIO-B |
| GPIO-C | 25 | 26 | GPIO-D |
| GPIO-E | 27 | 28 | GPIO-F |
| GPIO-G | 29 | 30 | GPIO-H |
| GPIO-I | 31 | 32 | GPIO-J |
| GPIO-K | 33 | 34 | GPIO-L |
| +1V8 | 35 | 36 | SYS_DCIN |
| +5V | 37 | 38 | SYC_DCIN |
| GND | 39 | 40 | GND |
Resources
---------
The following links will take you to addition 96Boards resources
- [Website](http://www.96boards.org/)
- [Forums](https://discuss.96boards.org/)
- [Documentation Repo](https://github.com/96boards/documentation)

View File

@@ -4,20 +4,21 @@ libmraa uses cmake in order to make compilation relatively painless. CMake runs
build out of tree so the recommended way is to clone from git and make a `build/`
directory inside the clone directory.
For building imraa check [building imraa](./imraa.md)
For building imraa check @ref buildingimraa page.
## Build dependencies
Not all these are required but if you're unsure of what you're doing this is
what you'll need:
* [SWIG](http://swig.org) 3.0.5+
* [git](http://git-scm.com)
* [python](http://python.org) 2.7 or 3.4+ (you'll need not just the interpreter but python-dev)
* [node.js](http://nodejs.org) 0.10.x or 0.12.x (you'll need not just the interpreter but nodejs-dev)
* [node.js](http://nodejs.org) 4.x recommended (you'll need not just the interpreter but nodejs-dev)
* [CMake](http://cmake.org) 2.8.8+ (3.1+ is recommended for node.js version 2+)
* [json-c](https://github.com/json-c/json-c) 0.12+ (0.10+ probably works in reality)
For Debian-like distros the below command installs the basic set:
```bash
sudo apt-get install git build-essential swig3.0 python-dev nodejs-dev cmake
sudo apt-get install git build-essential swig3.0 python-dev nodejs-dev cmake libjson-c-dev
```
To build the documentation you'll also need:
@@ -52,8 +53,9 @@ Currently our install logic puts Python bindings into standard paths, which
do not work on Debian due to their
[policy](http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-paths).
We are working on a permanent solution, in the meanwhile please use this command
after `make install` to link installed modules where Debian's Python expects them:
We are working on a permanent solution, in the meantime please use this command
after `make install` to link installed modules where Debian's Python expects
them:
```bash
sudo ln -s <your install prefix, e.g. /usr>/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages
@@ -91,30 +93,37 @@ Disabling Python module building:
Building doc, this will require [SPHINX](http://sphinx-doc.org) &
[Doxygen](http://doxygen.org):
`-DBUILDDOC=ON`
You will also require clone git submodules from your existing checkout:
`git submodule update --init --recursive`
Then from doxygen2jsdoc dir:
`npm install`
Then from doxyport dir:
`make setup`
Override build architecture (this is useful because on x86 ARM code is not
compiled so use this flag to force the target arch)
`-DBUILDARCH=arm`
You can also enable -Wall for gcc before running cmake by exporting your wanted
CC flags to the CC env var
`export CC="gcc -Wall"`
Sometimes it's nice to build a static libary, on Linux systems just set
`-DBUILD_SHARED_LIBS=OFF`
## Dependencies continued
You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
JavaScript & Python modules. If your version of SWIG is older than this then
please see above for disabling `SWIGNODE`. Otherwise you will get a weird build
failure when building the JavaScript module. The Python module builds with SWIG
2.x.
2.x but we don't test it.
During the build, we'll assume you're building from git, note that if you
compile with `git` installed your version of mraa will be tagged `-dirty`. This
simply means `git` wasn't installed or that you where building from a tarball.
You can modify `build/src/version.c` before running `make` if this is incorrect.
The instructions listed here all assume that `build/` is an empty dir that lives
inside the cloned repository of mraa.
If you have multiple versions of Python then mraa can get confused, we
recommend using virtualenv to select which version of Python you want. We test
2.7 the most but SWIG will generate valid 3.x Python code but we do not
generally support building both at once.
compile with `git` installed your version of mraa will be versioned with `git
desribe --tag` to make it easy for intentification. You can easily modify
version.c in build/src. If you don't build from a git tree then you will simply
have a version which matches the latest released version of mraa.
## Using a Yocto/OE toolchain
@@ -131,7 +140,6 @@ make
## Using Coverity
Static analysis is routinely performed using Coverity on libmraa's codebase.
This is the procedure to submit a build to Coverity. You'll need to install
`coverity-submit` for your OS.
@@ -160,7 +168,7 @@ To run, make sure `libmraajava.so` is in `LD_LIBRARY_PATH`
jave -cp $DIR_WHERE_YOU_INSTALLED_MRAA/mraa.jar:. Example
~~~~~~~~~~~~~
If you want to add or improve Java bindings for mraa, please follow the [Creating Java Bindings Guide](https://github.com/intel-iot-devkit/upm/blob/master/docs/creating_java_bindings.md).
If you want to add or improve Java bindings for mraa, please follow the <a href="https://github.com/intel-iot-devkit/upm/blob/master/docs/creating_java_bindings.md">Creating Java Bindings Guide</a>.
## Building an IPK/RPM package using `cpack`
@@ -178,3 +186,123 @@ build machine.
~~~~~~~~~~~~~{.sh}
cmake -DRPM=ON -DCMAKE_INSTALL_PREFIX=/usr ..
~~~~~~~~~~~~~
## Building for the Android Things Peripheralmanager Client
Requirements:
* Android [Things Native Library](https://github.com/androidthings/native-libandroidthings)
* Android NDK >= 14b
The [Things Native Library](https://github.com/androidthings/native-libandroidthings) contains a CMake find_package module
[FindAndroidThings.cmake](https://github.com/androidthings/native-libandroidthings/blob/master/FindAndroidThings.cmake). Make sure the directory containing this module is
added to the CMAKE_MODULE_PATH.
### NDK r14b
~~~~~~~~~~~~~{.sh}
cmake -DBUILDSWIG=OFF -DBUILDARCH=PERIPHERALMAN -DANDROID_TOOLCHAIN_NAME=x86-i686 -DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk-r14b/build/cmake/android.toolchain.cmake -DCMAKE_MODULE_PATH=/path/to/native-libandroidthings ..
~~~~~~~~~~~~~
## Building with Docker
You can use `docker` and `docker-compose` to generate a complete build environment
for mraa without having to install any other tool.
Requirements:
* [docker](https://www.docker.com/get-docker) >= 1.12.6
* [docker-compose](https://docs.docker.com/compose/install/) >= 1.9.0
**NOTE:** docker-compose is an optional requirement. It actually make running complex
docker build and run command easier. But you can just use docker to build and run.
### Using Docker Images to build Mraa
**tl;dr:** Just use this commands to build mraa:
```sh
# Build mraa documentation
$ docker-compose run doc
# Build mraa python2 package and run python2 tests
$ docker-compose run python2
# Build mraa python3 package and run python3 tests
$ docker-compose run python3
# Build mraa java package and run java tests
$ docker-compose run java
# Build mraa node4 package
$ docker-compose run node4
# Build mraa node5 package
$ docker-compose run node5
# Build mraa node6 package
$ docker-compose run node6
# Build mraa for android things package
$ docker-compose run android
# Run Sonar Qube Scans for mraa
$ docker-compose run sonar-scan
```
**docker-compose** will take a look at the `docker-compose.yaml` file in the repository
root directory, pull the required docker image, and run an specific command to build
mraa for the requested target.
Once the build is completed, you will have a `build/` folder in the repository root with all
the compiled code. This `build/` folder is created by using a docker volume. The `build\`
folder contents is reused each time you execute `docker-compose run [TARGET]`.
To know more about volumes in Docker, visit the [Docker Volume Documentation](https://docs.docker.com/engine/tutorials/dockervolumes/).
You can also start an interactive session inside the docker container if you need to run some
custom build commands:
```sh
# Start an interactive bash shell inside the container
$ docker-compose run python2 bash
# From now, all the commands are executed inside the container
$ cd build && cmake -DBUILDSWIGPYTHON=ON .. && make clean all
```
If you don't want to use docker-compose, you can also use `docker run` to build mraa.
For example, to build mraa for python2, you can do:
```sh
# From the repository root folder
$ docker run \
--volume=$(pwd):/usr/src/app \
--env BUILDSWIG=ON \
--env BUILDSWIGPYTHON=ON \
--env BUILDSWIGJAVA=OFF \
--env BUILDSWIGNODE=OFF \
dnoliver/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, unlinke docker-compose, do 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 \
dnoliver/mraa-python \
bash -c "./scripts/run-cmake.sh && make -Cbuild _python2-mraa"
```

View File

@@ -5,6 +5,48 @@ This changelog is meant as a quick & rough guide to what has changed between
versions. The API is now fairly stable but when new calls/features are added
they are listed here. Anything pre 0.2.x is ignored.
**1.7.0**
* Peripheral I/O support for Android Things
* Deprecation of node v0.10.x and 0.12.x
* 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 +61,25 @@ they are listed here. Anything pre 0.2.x is ignored.
**1.2.0**
* JSON platform support
* mock I2c functionality
* Intel Grosse Tete PWM fix
* Intel Joule PWM fix
* AIO firmata bug fix
**1.1.2**
* Mock platform support
* mraa-i2c treats i2c buses by default as linux
* grosse tete i2c fixes
* Intel Joule i2c fixes
* travis now uses 14.04 instead of 12.04
**1.1.1**
* IIO 4.6 kernel matrix support
* Intel Grosse Tete radio led support
* Intel Joule radio led support
* mraa_init_io() examples
* MRAAPLATFORMFORCE fixes
* fix python documentation
**1.1.0**
* build python2 & python3 bindings
* Intel Grosse Tete support
* Intel Joule support
* mraa_init_io() generic funtion
* mraa-gpio fixes
* edison PWM 0% improvements

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

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

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

@@ -45,9 +45,10 @@ Specific platform information for supported platforms is documented here:
- @ref rasppi
- @ref bananapi
- @ref beaglebone
- @ref phyboard-wega
- @ref nuc5
- @ref up
- @ref grossetete
- @ref joule
- @ref ft4222
## DEBUGGING
@@ -55,7 +56,7 @@ Specific platform information for supported platforms is documented here:
Sometimes it just doesn't want to work, let us try and help you, you can file
issues in github or join us in #mraa on freenode IRC, hang around for a little
while because we're not necessarily on 24/7, but we'll get back to you! Have a
glance at our @debugging page too
glance at our @ref debugging page too
## COMPILING

View File

@@ -45,9 +45,10 @@ Specific platform information for supported platforms is documented here:
- @ref rasppi
- @ref bananapi
- @ref beaglebone
- @ref phyboard-wega
- @ref nuc5
- @ref up
- @ref grossetete
- @ref joule
- @ref ft4222
## DEBUGGING
@@ -55,7 +56,7 @@ Specific platform information for supported platforms is documented here:
Sometimes it just doesn't want to work, let us try and help you, you can file
issues in github or join us in #mraa on freenode IRC, hang around for a little
while because we're not necessarily on 24/7, but we'll get back to you! Have a
glance at our @debugging page too
glance at our @ref debugging page too
## COMPILING

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 |

View File

@@ -1,12 +1,14 @@
Intel(R) Minnowboard Max {#minnowmax}
========================
Intel(R) MinnowBoard Max / MinnowBoard Turbot {#minnowmax}
=============================================
MinnowBoard MAX is an open hardware embedded board designed with the Intel(R)
Atom(TM) E38xx series SOC (Fromerly Bay Trail).
Atom(TM) E38xx series SOC (formely Bay Trail). The MinnowBoard Turbot is a
backward compatible revision with performance and hardware improvements.
https://www.minnowboard.org/learn-more/minnowboard-max-compatible-with-upgrades
For product overview and faq see
http://www.minnowboard.org/faq-minnowboard-max/
For product overview and faq see https://www.minnowboard.org/faq
For technical details see http://www.elinux.org/Minnowboard:MinnowMax
For technical details see https://www.minnowboard.org/board-viewer or the
legacy board https://www.minnowboard.org/minnowboard-max
Supported Firmware
------------------
@@ -55,4 +57,6 @@ bus #7.
| 23 | 23 | GPIO_S5_1 | 83 | GPIO |
| 24 | 24 | PWM1 | 249 | PWM Chip 1 Channel 0 |
| 25 | 25 | S5_4 | 84 | GPIO |
| 26 | 26 | IBL_8254 | 208 | GPIO |
| 26 | 26 | IBL_8254 | 208 | GPIO / I2S MCLK (tb) |
*(tb) New assignment on the MinnowBoard Turbot

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

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!

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
-----------
@@ -48,13 +51,13 @@ Note that there is an enum to use wiringPi style numbers.
| 4 | P1-04 | 5V VCC | | |
| 5 | P1-05 | I2C SCL1 | 3 | I2C1 (/dev/i2c-1) |
| 6 | P1-06 | GND | | |
| 7 | P1-07 | GPIO(4) | 4 | |
| 7 | P1-07 | GPIO(4) | 4 | ADC0 (iio:device0) |
| 8 | P1-08 | UART TX1 | 14 | UART1 (/dev/ttyS1) |
| 9 | P1-09 | GND | | |
| 10 | P1-10 | UART RX1 | 15 | UART1 (/dev/ttyS1) |
| 11 | P1-11 | GPIO(17) | 17 | |
| 12 | P1-12 | I2S CLK | 18 | I2S0 (PCM Audio) |
| 13 | P1-13 | UART RX2 | 27 | UART2 (/dev/ttyS2) |
| 13 | P1-13 | GPIO(27) | 27 | |
| 14 | P1-14 | GND | | |
| 15 | P1-15 | GPIO(22) | 22 | |
| 16 | P1-16 | GPIO(23) | 23 | |
@@ -63,7 +66,7 @@ Note that there is an enum to use wiringPi style numbers.
| 19 | P1-19 | SPI MOSI | 10 | SPI2 (/dev/spidev2.x)|
| 20 | P1-20 | GND | | |
| 21 | P1-21 | SPI MISO | 9 | SPI2 (/dev/spidev2.x)|
| 22 | P1-22 | UART TX2 | 25 | UART2 (/dev/ttyS2) |
| 22 | P1-22 | GPIO(25) | 25 | |
| 23 | P1-23 | SPI SCL | 11 | SPI2 (/dev/spidev2.x)|
| 24 | P1-24 | SPI CS0 | 8 | SPI2 (/dev/spidev2.0)|
| 25 | P1-25 | GND | | |

1
doxyport Submodule

Submodule doxyport added at db3e1a6eb8

View File

@@ -11,8 +11,11 @@ add_executable (blink_onboard blink_onboard.c)
add_executable (uart uart.c)
add_executable (mraa-gpio mraa-gpio.c)
add_executable (mraa-i2c mraa-i2c.c)
add_executable (mraa-uart mraa-uart.c)
add_executable (spi_max7219 spi_max7219.c)
add_executable (iio_driver iio_driver.c)
if (NOT ANDROID_TOOLCHAIN)
add_executable (iio_driver iio_driver.c)
endif ()
include_directories(${PROJECT_SOURCE_DIR}/api)
# FIXME Hack to access mraa internal types used by mraa-i2c
@@ -32,9 +35,11 @@ target_link_libraries (blink_onboard mraa)
target_link_libraries (uart mraa)
target_link_libraries (mraa-gpio mraa)
target_link_libraries (mraa-i2c mraa)
target_link_libraries (mraa-uart mraa)
target_link_libraries (spi_max7219 mraa)
target_link_libraries (iio_driver mraa)
if (NOT ANDROID_TOOLCHAIN)
target_link_libraries (iio_driver mraa)
endif ()
if (ONEWIRE)
add_executable (uart_ow uart_ow.c)
target_link_libraries (uart_ow mraa)
@@ -47,7 +52,9 @@ if (FIRMATA)
target_link_libraries (i2c_firmata mraa)
endif ()
add_subdirectory (c++)
if (NOT ANDROID_TOOLCHAIN)
add_subdirectory (c++)
endif ()
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/mraa/examples)
@@ -58,4 +65,5 @@ endif()
if (INSTALLTOOLS)
install (TARGETS mraa-gpio DESTINATION bin)
install (TARGETS mraa-i2c DESTINATION bin)
install (TARGETS mraa-uart DESTINATION bin)
endif()

View File

@@ -1,5 +1,6 @@
/*
* Author: Nandkishor Sonar
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -23,30 +24,49 @@
*/
#include <unistd.h>
//! [Interesting]
#include <signal.h>
#include "mraa/aio.h"
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing down nicely\n");
running = -1;
}
}
//! [Interesting]
int
main()
{
mraa_aio_context adc_a0;
uint16_t adc_value = 0;
float adc_value_float = 0.0;
mraa_result_t r = MRAA_SUCCESS;
adc_a0 = mraa_aio_init(0);
if (adc_a0 == NULL) {
return 1;
}
for (;;) {
signal(SIGINT, sig_handler);
while (running == 0) {
adc_value = mraa_aio_read(adc_a0);
adc_value_float = mraa_aio_read_float(adc_a0);
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
fprintf(stdout, "ADC A0 read float - %.5f (Ctrl+C to exit)\n", adc_value_float);
}
mraa_aio_close(adc_a0);
r = mraa_aio_close(adc_a0);
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
return MRAA_SUCCESS;
return r;
}
//! [Interesting]

View File

@@ -1,5 +1,6 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -25,9 +26,21 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "mraa/gpio.h"
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing down nicely\n");
running = -1;
}
}
int
main(int argc, char** argv)
{
@@ -35,6 +48,7 @@ main(int argc, char** argv)
mraa_gpio_context gpio, gpio_in = NULL;
const char* board_name = mraa_get_platform_name();
int ledstate = 0;
mraa_result_t r = MRAA_SUCCESS;
switch (platform) {
case MRAA_INTEL_GALILEO_GEN1:
@@ -46,11 +60,14 @@ main(int argc, char** argv)
// lure put an LED on pin 21
gpio = mraa_gpio_init(21);
break;
case MRAA_INTEL_JOULE_EXPANSION:
gpio = mraa_gpio_init(101);
break;
default:
gpio = mraa_gpio_init(13);
}
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s (Ctrl+C to exit)\n", mraa_get_version(), board_name);
if (gpio == NULL) {
@@ -70,8 +87,11 @@ main(int argc, char** argv)
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
for (;;) {
signal(SIGINT, sig_handler);
while (running == 0) {
if (gpio_in != NULL && mraa_gpio_read(gpio_in) == 0) {
mraa_gpio_close(gpio_in);
return 0;
}
ledstate = !ledstate;
@@ -79,5 +99,10 @@ main(int argc, char** argv)
sleep(1);
}
return 0;
r = mraa_gpio_close(gpio);
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
return r;
}

View File

@@ -1,5 +1,6 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributors: Alex Tereschenko <alex.mkrs@gmail.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -22,26 +23,36 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//! [Interesting]
#include <signal.h>
#include "mraa.hpp"
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing down nicely\n");
running = -1;
}
}
//! [Interesting]
int
main()
{
uint16_t adc_value;
float adc_value_float;
mraa::Aio* a0;
mraa::Aio a0(0);
a0 = new mraa::Aio(0);
if (a0 == NULL) {
return MRAA_ERROR_UNSPECIFIED;
}
signal(SIGINT, sig_handler);
for (;;) {
adc_value = a0->read();
adc_value_float = a0->readFloat();
while (running == 0) {
adc_value = a0.read();
adc_value_float = a0.readFloat();
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
fprintf(stdout, "ADC A0 read float - %.5f (Ctrl+C to exit)\n", adc_value_float);
}
return MRAA_SUCCESS;

View File

@@ -55,23 +55,19 @@ main(int argc, char** argv)
signal(SIGINT, sig_handler);
//! [Interesting]
mraa::Gpio* gpio = new mraa::Gpio(iopin);
if (gpio == NULL) {
return mraa::ERROR_UNSPECIFIED;
}
mraa::Result response = gpio->dir(mraa::DIR_OUT);
mraa::Gpio gpio(iopin);
mraa::Result response = gpio.dir(mraa::DIR_OUT);
if (response != mraa::SUCCESS) {
mraa::printError(response);
return 1;
}
while (running == 0) {
response = gpio->write(1);
response = gpio.write(1);
sleep(1);
response = gpio->write(0);
response = gpio.write(0);
sleep(1);
}
delete gpio;
return response;
//! [Interesting]
}

View File

@@ -99,28 +99,27 @@ main()
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
//! [Interesting]
mraa::I2c* i2c;
i2c = new mraa::I2c(0);
mraa::I2c i2c(0);
i2c->address(HMC5883L_I2C_ADDR);
i2c.address(HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
rx_tx_buf[1] = GA_1_3_REG;
i2c->write(rx_tx_buf, 2);
i2c.write(rx_tx_buf, 2);
//! [Interesting]
i2c->address(HMC5883L_I2C_ADDR);
i2c.address(HMC5883L_I2C_ADDR);
rx_tx_buf[0] = HMC5883L_MODE_REG;
rx_tx_buf[1] = HMC5883L_CONT_MODE;
i2c->write(rx_tx_buf, 2);
i2c.write(rx_tx_buf, 2);
signal(SIGINT, sig_handler);
while (running == 0) {
i2c->address(HMC5883L_I2C_ADDR);
i2c->writeByte(HMC5883L_DATA_REG);
i2c.address(HMC5883L_I2C_ADDR);
i2c.writeByte(HMC5883L_DATA_REG);
i2c->address(HMC5883L_I2C_ADDR);
i2c->read(rx_tx_buf, DATA_REG_SIZE);
i2c.address(HMC5883L_I2C_ADDR);
i2c.read(rx_tx_buf, DATA_REG_SIZE);
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
@@ -138,7 +137,6 @@ main()
printf("Heading : %f\n", direction * 180 / M_PI);
sleep(1);
}
delete i2c;
return MRAA_SUCCESS;
}

View File

@@ -107,6 +107,7 @@ protected:
}
};
//! [Interesting]
int
main()
{
@@ -154,4 +155,4 @@ main()
delete iio_device;
return EXIT_SUCCESS;
}
//! [Interesting]

View File

@@ -1,5 +1,6 @@
/*
* Author: Brendan Le Foll
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -38,13 +39,14 @@ interrupt(void* args)
int
main()
{
mraa::Gpio* x = new mraa::Gpio(6);
mraa::Gpio x(6);
x->dir(mraa::DIR_IN);
x.dir(mraa::DIR_IN);
x->isr(mraa::EDGE_BOTH, &interrupt, NULL);
x.isr(mraa::EDGE_BOTH, &interrupt, NULL);
for (;;) {
int i = 100;
for (; i > 0; --i) {
if (counter != oldcounter) {
fprintf(stdout, "timeout counter == %d\n", counter);
oldcounter = counter;
@@ -53,5 +55,5 @@ main()
sleep(1);
}
return EXIT_SUCCESS;
return MRAA_SUCCESS;
}

View File

@@ -43,25 +43,19 @@ main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
mraa::Pwm* pwm;
pwm = new mraa::Pwm(3);
if (pwm == NULL) {
return MRAA_ERROR_UNSPECIFIED;
}
mraa::Pwm pwm(3);
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
pwm->enable(true);
pwm.enable(true);
float value = 0.0f;
while (running == 0) {
value = value + 0.01f;
pwm->write(value);
pwm.write(value);
usleep(50000);
if (value >= 1.0f) {
value = 0.0f;
}
}
delete pwm;
//! [Interesting]
return MRAA_SUCCESS;

View File

@@ -45,9 +45,7 @@ main()
signal(SIGINT, sig_handler);
//! [Interesting]
mraa::Spi* spi;
spi = new mraa::Spi(0);
mraa::Spi spi(0);
uint8_t data[] = { 0x00, 100 };
uint8_t rxBuf[2];
@@ -56,7 +54,7 @@ main()
int i;
for (i = 90; i < 130; i++) {
data[1] = i;
recv = spi->write(data, 2);
recv = spi.write(data, 2);
printf("Writing -%i", i);
if (recv) {
printf("RECIVED-%i-%i\n", recv[0], recv[1]);
@@ -66,14 +64,13 @@ main()
}
for (i = 130; i > 90; i--) {
data[1] = i;
if (spi->transfer(data, rxBuf, 2) == mraa::SUCCESS) {
if (spi.transfer(data, rxBuf, 2) == mraa::SUCCESS) {
printf("Writing -%i", i);
printf("RECIVED-%i-%i\n", rxBuf[0], rxBuf[1]);
}
usleep(100000);
}
}
delete spi;
//! [Interesting]
return mraa::SUCCESS;

View File

@@ -27,39 +27,37 @@
//! [Interesting]
#include "uart_ow.hpp"
using namespace std;
int
main(int argc, char** argv)
{
mraa::UartOW* uart = new mraa::UartOW(0);
mraa::UartOW uart(0);
// Reset the ow bus and see if anything is present
mraa::Result rv;
if ((rv = uart->reset()) == mraa::SUCCESS) {
cout << "Reset succeeded, device(s) detected!" << endl;
if ((rv = uart.reset()) == mraa::SUCCESS) {
std::cout << "Reset succeeded, device(s) detected!" << std::endl;
} else {
cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << endl;
std::cout << "Reset failed, returned " << int(rv) << ". No devices on bus?" << std::endl;
return 1;
}
cout << "Looking for devices..." << endl;
std::cout << "Looking for devices..." << std::endl;
;
uint8_t count = 0;
// start the search from scratch
string id = uart->search(true);
std::string id = uart.search(true);
if (id.empty()) {
cout << "No devices detected." << endl;
std::cout << "No devices detected." << std::endl;
return 1;
}
while (!id.empty()) {
// hack so we don't need to cast each element of the romcode
// for printf purposes
uint8_t* ptr = (uint8_t*) id.c_str();
uint8_t* ptr = (uint8_t*) id.data();
// The first byte (0) is the device type (family) code.
// The last byte (7) is the rom code CRC value. The
@@ -70,12 +68,10 @@ main(int argc, char** argv)
count++;
// continue the search with start argument set to false
id = uart->search(false);
id = uart.search(false);
}
cout << "Exiting..." << endl;
delete uart;
std::cout << "Exiting..." << std::endl;
return 0;
}

View File

@@ -49,6 +49,7 @@ main()
value = 0.0f;
}
float output = mraa_pwm_read(pwm);
printf("PWM value is %f\n", output);
}
//! [Interesting]
return 0;

View File

@@ -56,7 +56,7 @@ main()
mraa_firmata_response(firm, interrupt);
uint8_t* buffer = calloc(4, 0);
char* buffer = calloc(4, 0);
if (buffer == NULL) {
free(firm);
return EXIT_FAILURE;

View File

@@ -1,5 +1,6 @@
/*
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -24,14 +25,28 @@
#include "stdio.h"
#include "unistd.h"
#include <signal.h>
#include "mraa.h"
int running = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("closing down nicely\n");
running = -1;
}
}
int
main(int argc, char** argv)
{
mraa_result_t r = MRAA_SUCCESS;
mraa_init();
fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n", mraa_get_version());
fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6 (Ctrl+C to exit)\n", mraa_get_version());
//! [Interesting]
mraa_gpio_context gpio;
@@ -40,13 +55,18 @@ main(int argc, char** argv)
mraa_gpio_dir(gpio, MRAA_GPIO_IN);
for (;;) {
signal(SIGINT, sig_handler);
while (running == 0) {
fprintf(stdout, "Gpio is %d\n", mraa_gpio_read(gpio));
sleep(1);
}
mraa_gpio_close(gpio);
r = mraa_gpio_close(gpio);
//! [Interesting]
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
return 0;
return r;
}

View File

@@ -55,7 +55,7 @@ interrupt(char* data)
mraa_iio_channel* channels = mraa_iio_get_channels(iio_device0);
int i = 0;
for (i; i < mraa_iio_get_channel_count(iio_device0); i++) {
for (; i < mraa_iio_get_channel_count(iio_device0); i++) {
if (channels[i].enabled) {
printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
switch (channels[i].bytes) {

View File

@@ -1,5 +1,6 @@
/*
* Author: Brendan Le Foll
* Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -52,7 +53,8 @@ main()
mraa_gpio_isr(x, edge, &interrupt, NULL);
for (;;) {
int i = 100;
for (; i > 0; --i) {
if (counter != oldcounter) {
fprintf(stdout, "timeout counter == %d\n", counter);
oldcounter = counter;

View File

@@ -44,11 +44,12 @@ public class AioA0 {
public static void main(String[] args) {
Aio a0 = new Aio(0);
while (true) {
for (int i = 100; i > 0; --i) {
int adc_value = a0.read();
float adc_value_float = a0.readFloat();
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
Thread.sleep(500);
}
}

View File

@@ -61,7 +61,7 @@ public class BlinkIO {
System.exit(1);
}
while (true) {
for (int i = 100; i > 0; --i) {
gpio.write(1);
Thread.sleep(1000);
gpio.write(0);

View File

@@ -64,7 +64,7 @@ public class BlinkOnboard {
}
boolean state = false;
while (true) {
for (int i = 100; i > 0; --i) {
if (gpio_in != null && gpio_in.read() == 0) {
return;
}

View File

@@ -44,7 +44,7 @@ public class CyclePwm3 {
pwm.enable(true);
float value = 0;
while (true) {
for (int i = 100; i > 0; --i) {
value += 0.01;
pwm.write(value);
Thread.sleep(50);

View File

@@ -50,8 +50,8 @@ public class FTDITest {
/* Blink FTDI board LED */
Gpio led = new Gpio(514);
led.dir(Dir.DIR_OUT);
for (int i = 0;; i = (i + 1) % 2) {
led.write(i);
for (int i = 100; i > 0; --i) {
led.write(i % 2);
Thread.sleep(500);
}
} else {

View File

@@ -44,12 +44,13 @@ public class GpioMmapped {
String version = mraa.getVersion();
System.out.println("hello mraa");
System.out.println(String.format("Version: %s", version));
System.out.println(String.format("Platform: %s", board));
Gpio gpio = new Gpio(1);
gpio.useMmap(true);
while (true) {
for (int i = 1000; i > 0; --i) {
gpio.write(1);
Thread.sleep(50);
gpio.write(0);

View File

@@ -46,7 +46,7 @@ public class GpioRead6 {
gpio.dir(Dir.DIR_IN);
while (true) {
for (int i = 100; i > 0; --i) {
System.out.format("Gpio is %d\n", gpio.read());
Thread.sleep(1000);
}

View File

@@ -110,16 +110,16 @@ public class I2cCompass {
conf_buf[1] = HMC5883L_CONT_MODE;
i2c.write(conf_buf);
while (true) {
for (int i = 100; i > 0; --i) {
i2c.address(HMC5883L_I2C_ADDR);
i2c.writeByte(HMC5883L_DATA_REG);
i2c.address(HMC5883L_I2C_ADDR);
i2c.read(rx_tx_buf);
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_X_LSB_REG] & 0xFF);
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Z_LSB_REG] & 0xFF);
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | (rx_tx_buf[HMC5883L_Y_LSB_REG] & 0xFF);
direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);

View File

@@ -43,7 +43,7 @@ public class SpiMCP4261 {
System.out.println("Hello, SPI initialised");
byte data[] = {0x00, 100};
while (true) {
for (int cnt = 100; cnt > 0; --cnt) {
for (int i = 90; i < 130; i++) {
data[1] = (byte) i;
byte[] recv = spi.write(data);

View File

@@ -22,11 +22,13 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
"use strict";
var analogPin0 = new m.Aio(0); //setup access analog inpuput pin 0
var analogValue = analogPin0.read(); //read the value of the analog pin
var analogValueFloat = analogPin0.readFloat(); //read the pin value as a float
const mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
let analogPin0 = new mraa.Aio(0); //setup access analog inpuput pin 0
let analogValue = analogPin0.read(); //read the value of the analog pin
let analogValueFloat = analogPin0.readFloat(); //read the pin value as a float
console.log(analogValue); //write the value of the analog pin to the console
console.log(analogValueFloat.toFixed(5)); //write the value in the float format

View File

@@ -22,19 +22,18 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
"use strict";
var myLed = new m.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
myLed.dir(m.DIR_OUT); //set the gpio direction to output
var ledState = true; //Boolean to hold the state of Led
const mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
function periodicActivity()
{
myLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low)
ledState = !ledState; //invert the ledState
setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds)
let myLed = new mraa.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
myLed.dir(mraa.DIR_OUT); //set the gpio direction to output
let ledState = true; //Boolean to hold the state of Led
function periodicActivity() {
myLed.write(ledState ? 1 : 0); //if ledState is true then write a '1' (high) otherwise write a '0' (low)
ledState = !ledState; //invert the ledState
}
periodicActivity(); //call the periodicActivity function
setInterval(periodicActivity, 1000); //call the periodicActivity function every second

View File

@@ -22,17 +22,17 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
"use strict";
var myDigitalPin = new m.Gpio(6); //setup digital read on pin 6
myDigitalPin.dir(m.DIR_IN); //set the gpio direction to input
const mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
periodicActivity(); //call the periodicActivity function
let myDigitalPin = new mraa.Gpio(6); //setup digital read on pin 6
myDigitalPin.dir(mraa.DIR_IN); //set the gpio direction to input
function periodicActivity() //
{
var myDigitalValue = myDigitalPin.read(); //read the digital value of the pin
console.log('Gpio is ' + myDigitalValue); //write the read value out to the console
setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds)
function periodicActivity() {
let myDigitalValue = myDigitalPin.read(); //read the digital value of the pin
console.log('Gpio value is ' + myDigitalValue); //write the read value out to the console
}
setInterval(periodicActivity, 1000); //call the indicated function every 1 second (1000 milliseconds)

View File

@@ -22,9 +22,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console
"use strict";
var myDigitalPin = new m.Gpio(5); //setup digital read on pin 5
myDigitalPin.dir(m.DIR_OUT); //set the gpio direction to output
const mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
let myDigitalPin = new mraa.Gpio(5); //setup digital read on pin 5
myDigitalPin.dir(mraa.DIR_OUT); //set the gpio direction to output
myDigitalPin.write(1); //set the digital pin to high (1)

View File

@@ -24,29 +24,32 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
"use strict";
x = new m.I2c(0)
x.address(0x77)
const mraa = require('mraa'); //require mraa
let i2cDevice = new mraa.I2c(0);
i2cDevice.address(0x77);
// initialise device
if (x.readReg(0xd0) != 0x55) {
console.log("error");
if (i2cDevice.readReg(0xd0) != 0x55) {
console.log("error");
}
// we want to read temperature so write 0x2e into control reg
x.writeReg(0xf4, 0x2e)
i2cDevice.writeReg(0xf4, 0x2e);
// read a 16bit reg, obviously it's uncalibrated so mostly a useless value :)
console.log(x.readWordReg(0xf6))
console.log(i2cDevice.readWordReg(0xf6));
// and we can do the same thing with the read()/write() calls if we wished
// thought I'd really not recommend it!
buf = new Buffer(2)
buf[0] = 0xf4
buf[1] = 0x2e
console.log(buf.toString('hex'))
x.write(buf)
let buf = new Buffer(2);
buf[0] = 0xf4;
buf[1] = 0x2e;
console.log(buf.toString('hex'));
i2cDevice.write(buf);
x.writeByte(0xf6)
d = x.read(2)
i2cDevice.writeByte(0xf6);
let result = i2cDevice.read(2);
console.log(result.toString('hex'));

View File

@@ -22,7 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var mraa = require('mraa');
"use strict";
const mraa = require('mraa');
console.log('MRAA Version: ' + mraa.getVersion());
// open connection to firmata

View File

@@ -22,12 +22,14 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var mraa = require('mraa');
"use strict";
const mraa = require('mraa');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
input: process.stdin,
output: process.stdout
});
function printUsage() {
@@ -42,16 +44,16 @@ function getVersion() {
}
function setPin() {
var pinNumber = arguments[0];
var pinValue = arguments[1];
var pin = new mraa.Gpio(pinNumber);
let pinNumber = arguments[0];
let pinValue = arguments[1];
let pin = new mraa.Gpio(pinNumber);
pin.dir(mraa.DIR_OUT);
pin.write(pinNumber, pinValue);
}
function getPin() {
var pinNumber = arguments[0];
var pin = new mraa.Gpio(pinNumber);
let pinNumber = arguments[0];
let pin = new mraa.Gpio(pinNumber);
pin.dir(mraa.DIR_IN);
console.log('Gpio ' + pinNumber + ' = ' + pin.read());
}
@@ -61,9 +63,9 @@ function onPinLevelChange() {
}
function monitorPin() {
var pinNumber = arguments[0];
let pinNumber = arguments[0];
try {
var pin = new mraa.Gpio(pinNumber);
let pin = new mraa.Gpio(pinNumber);
pin.dir(mraa.DIR_IN);
pin.isr(mraa.EDGE_BOTH, onPinLevelChange);
rl.question('Press ENTER to stop', function(answer) {
@@ -71,37 +73,37 @@ function monitorPin() {
pin.isrExit();
});
} catch (err) {
console.log(err.message);
console.log(err.message);
}
}
const args = process.argv;
const argc = args.length;
if (argc >= 3) {
const cmd = args[2];
if (argc > 3) {
const pinNumber = parseInt(args[3]);
}
switch (args[2]) {
case "version":
getVersion();
break;
case "get":
var pinNumber = parseInt(args[3]);
getPin(pinNumber);
break;
case "set":
var pinNumber = parseInt(args[3]);
var pinValue = parseInt(args[4]);
getPin(pinNumber, pinValue);
break;
case "monitor":
var pinNumber = parseInt(args[3]);
monitorPin(pinNumber);
break;
default:
console.log("Invalid command " + args[2]);
break;
case "version":
getVersion();
break;
case "get":
getPin(pinNumber);
break;
case "set":
let pinValue = parseInt(args[4]);
getPin(pinNumber, pinValue);
break;
case "monitor":
monitorPin(pinNumber);
break;
default:
console.log("Invalid command " + args[2]);
break;
}
} else {
console.log("Command not specified");
printUsage();
}

View File

@@ -22,27 +22,29 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa');
"use strict";
const mraa = require('mraa');
// GPIO-PIN
m.gpioFromDesc("gpio-1");
mraa.gpioFromDesc("gpio-1");
// GPIO-RAW-RAWPIN
m.gpioFromDesc("gpio-raw-131");
mraa.gpioFromDesc("gpio-raw-131");
// AIO-PIN
m.aioFromDesc("aio-1");
mraa.aioFromDesc("aio-1");
//PWM-PIN
m.pwmFromDesc("pwm-6");
mraa.pwmFromDesc("pwm-6");
// PWM-RAW-CHIPID-PIN
m.pwmFromDesc("pwm-raw-0-1")
mraa.pwmFromDesc("pwm-raw-0-1")
// UART-INDEX: the index is the one represented internally in the uart_dev array
m.uartFromDesc("uart-0");
mraa.uartFromDesc("uart-0");
// UART-RAW-PATH
m.uartFromDesc("uart-raw-/dev/ttyS0");
mraa.uartFromDesc("uart-raw-/dev/ttyS0");
// SPI-INDEX: same as UART
m.spiFromDesc("spi-0");
mraa.spiFromDesc("spi-0");
// SPI-RAW-BUS-CS: USED to open and use /dev/spidev<BUS>.<CS>
m.spiFromDesc("spi-raw-0-1");
mraa.spiFromDesc("spi-raw-0-1");
// I2C-INDEX: same as UART
m.i2cFromDesc("i2c-0");
mraa.i2cFromDesc("i2c-0");
// I2C-RAW-BUS
m.i2cFromDesc("i2c-raw-0");
mraa.i2cFromDesc("i2c-raw-0");

View File

@@ -1,16 +1,18 @@
#!/usr/bin/env node
var m = require('mraa')
"use strict";
function h() {
console.log("HELLO!!!!")
const mraa = require('mraa');
function hello() {
console.log("HELLO!!!!");
}
x = new m.Gpio(14)
x.isr(m.EDGE_BOTH, h)
let pin = new mraa.Gpio(14);
pin.isr(mraa.EDGE_BOTH, hello);
setInterval(function() {
// It's important to refer to our GPIO context here,
// otherwise it will be garbage-collected
console.log("Waiting for an interrupt at GPIO pin " + x.getPin() + "...")
}, 10000)
console.log("Waiting for an interrupt at GPIO pin " + pin.getPin() + "...");
}, 10000);

View File

@@ -22,13 +22,15 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
"use strict";
x = new m.I2c(0)
x.address(0x62)
x.writeReg(0, 0)
x.writeReg(1, 0)
const mraa = require('mraa'); //require mraa
x.writeReg(0x08, 0xAA)
x.writeReg(0x04, 255)
x.writeReg(0x02, 255)
let i2cDevice = new mraa.I2c(0);
i2cDevice.address(0x62);
i2cDevice.writeReg(0, 0);
i2cDevice.writeReg(1, 0);
i2cDevice.writeReg(0x08, 0xAA);
i2cDevice.writeReg(0x04, 255);
i2cDevice.writeReg(0x02, 255);

View File

@@ -24,15 +24,15 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
x = new m.Spi(0)
buf = new Buffer(4)
buf[0] = 0xf4
buf[1] = 0x2e
buf[2] = 0x3e
buf[3] = 0x4e
buf2 = x.write(buf)
console.log("Sent: " + buf.toString('hex') + ". Received: " + buf2.toString('hex'))
"use strict";
const mraa = require('mraa'); //require mraa
let spiDevice = new mraa.Spi(0);
let buf = new Buffer(4);
buf[0] = 0xf4;
buf[1] = 0x2e;
buf[2] = 0x3e;
buf[3] = 0x4e;
let buf2 = spiDevice.write(buf);
console.log("Sent: " + buf.toString('hex') + ". Received: " + buf2.toString('hex'));

View File

@@ -22,33 +22,35 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var m = require('mraa'); //require mraa
console.log('MRAA Version: ' + m.getVersion());
u = new m.Uart(0)
"use strict";
const mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion());
let uart = new mraa.Uart(0);
console.log("Note: connect Rx and Tx of UART with a wire before use");
function sleep(delay) {
delay += new Date().getTime();
while (new Date() < delay) { }
delay += new Date().getTime();
while (new Date() < delay) {}
}
console.log("Set UART parameters");
u.setBaudRate(115200);
u.setMode(8, 0, 1);
u.setFlowcontrol(false, false);
uart.setBaudRate(115200);
uart.setMode(8, 0, 1);
uart.setFlowcontrol(false, false);
sleep(200);
console.log("First write-read circle:");
u.writeStr("test\n");
uart.writeStr("test\n");
sleep(200);
console.log(u.readStr(6));
console.log(uart.readStr(6));
sleep(200);
console.log("Second write-read circle:");
u.writeStr("2nd test\n");
uart.writeStr("2nd test\n");
sleep(200);
console.log(u.readStr(10));
console.log(uart.readStr(10));

View File

@@ -144,7 +144,6 @@ i2c_set_exit:
void
i2c_detect_devices(int bus)
{
mraa_result_t status = MRAA_SUCCESS;
mraa_i2c_context i2c = mraa_i2c_init(bus);
if (i2c == NULL) {
return;
@@ -167,16 +166,16 @@ int
process_command(int argc, char** argv)
{
int status = 0;
if (strcmp(argv[1], "help") == 0) {
if (strncmp(argv[1], "help", strlen("help") + 1) == 0) {
print_help();
return 0;
} else if (strcmp(argv[1], "version") == 0) {
} else if (strncmp(argv[1], "version", strlen("version") + 1) == 0) {
print_version();
return 0;
} else if (strcmp(argv[1], "list") == 0) {
} else if (strncmp(argv[1], "list", strlen("list") + 1) == 0) {
print_busses();
return 0;
} else if (strcmp(argv[1], "detect") == 0) {
} else if (strncmp(argv[1], "detect", strlen("detect") + 1) == 0) {
if (argc == 3) {
int bus = strtol(argv[2], NULL, 0);
i2c_detect_devices(bus);
@@ -185,10 +184,11 @@ process_command(int argc, char** argv)
print_command_error();
return 1;
}
} else if ((strcmp(argv[1], "get") == 0) || (strcmp(argv[1], "getrpt") == 0)) {
} else if ((strncmp(argv[1], "get", strlen("get") + 1) == 0) ||
(strncmp(argv[1], "getrpt", strlen("getrpt") + 1) == 0)) {
if (argc == 5) {
int interation = 0;
mraa_boolean_t should_repeat = strcmp(argv[1], "getrpt") == 0;
mraa_boolean_t should_repeat = strncmp(argv[1], "getrpt", strlen("getrpt") + 1) == 0;
int bus = strtol(argv[2], NULL, 0);
uint8_t device_address = strtol(argv[3], NULL, 0);
uint8_t register_address = strtol(argv[4], NULL, 0);
@@ -212,7 +212,7 @@ process_command(int argc, char** argv)
status = 1;
}
return status;
} else if ((strcmp(argv[1], "set") == 0)) {
} else if ((strncmp(argv[1], "set", strlen("set") + 1) == 0)) {
if (argc == 6) {
int bus = strtol(argv[2], NULL, 0);
uint8_t device_address = strtol(argv[3], NULL, 0);
@@ -247,12 +247,14 @@ run_interactive_mode()
fprintf(stdout, "Command: ");
fgets(command, 80, stdin);
command[strlen(command) - 1] = 0;
if (strcmp(command, "q") == 0)
if (strncmp(command, "q", strlen("q") + 1) == 0)
return;
char* str = strtok(command, " ");
int len = 0;
while (str != NULL) {
arg = malloc(strlen(str) + 1);
argv[argc++] = strcpy(arg, str);
len = strlen(str) + 1;
arg = malloc(len);
argv[argc++] = strncpy(arg, str, len);
str = strtok(NULL, " ");
}
process_command(argc, argv);

301
examples/mraa-uart.c Normal file
View File

@@ -0,0 +1,301 @@
/*
* Author: Tapani Utriainen <tapani@technexion.com>
* Copyright (c) 2017 TechNexion Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include "mraa.h"
#ifndef FALSE
#define FALSE 0
#define TRUE (!FALSE)
#endif
static const char *undefined = "<undefined>";
static const char paritymode_table[] = {
[MRAA_UART_PARITY_NONE] = 'N',
[MRAA_UART_PARITY_EVEN] = 'E',
[MRAA_UART_PARITY_ODD] = 'O',
[MRAA_UART_PARITY_MARK] = 'M',
[MRAA_UART_PARITY_SPACE] = 'S'
};
/* ------------------------------------------------------------------------ */
mraa_uart_context
uarttool_find(const char *str) {
/* Try to find the uart by name, then by index, by devpath and as last resort create a raw uart */
int uart_index = mraa_uart_lookup(str);
if (uart_index < 0) {
/* name lookup failed, try index if the first character is a digit */
if (isdigit(*str)) {
uart_index = atoi(str);
} else {
const char *devpath;
int number_of_uarts = mraa_get_uart_count();
for (uart_index = 0; uart_index < number_of_uarts; uart_index++) {
mraa_result_t res = mraa_uart_settings(uart_index, NULL, &devpath, NULL, NULL, NULL, NULL, NULL, NULL);
if (res == MRAA_SUCCESS && devpath != NULL && !strcmp(devpath, str)) break;
}
if (uart_index >= number_of_uarts) {
return mraa_uart_init_raw(str);
}
}
}
return mraa_uart_init(uart_index);
}
/* ------------------------------------------------------------------------ */
double
now(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return (double)tv.tv_usec * 1e-6 + (double)tv.tv_sec;
}
/* ------------------------------------------------------------------------ */
void
uarttool_read_and_print(mraa_uart_context uart, double receive_timeout) {
char buf;
do {
double start = now();
if (mraa_uart_data_available(uart, 1.0 + receive_timeout * 1000.0)) {
mraa_uart_read(uart, &buf, 1);
putchar(buf);
fflush(stdout);
}
receive_timeout -= now() - start;
} while (receive_timeout > 0.0);
}
/* ------------------------------------------------------------------------ */
void
uarttool_usage(const char *name) {
printf("Usage: %s { list | dev device } [ baud bps ] [ databits d ] [ parity p ] [ stopbits s ] [ ctsrts mode ] [ send string ] [ recv timeout ] [ show ]\n\n", name);
printf("Simple tool to test UART functionality. Needs either list or dev arguments, the others are optional\n");
printf(" list : lists uarts on the system (non intrusive)\n");
printf(" dev : select uart device, can be by name, by device name or by index (as listed in list)\n");
printf(" baud : set the baudrate to given parameter, in bits per second\n");
printf(" parity : set parity mode to given parameter - can be E, O, or N\n");
printf(" stopbits : set the number of stopbits - can be 1 or 2\n");
printf(" ctsrts : set CTS/RTS flow control to either on or off\n");
printf(" send : transmits a string\n");
printf(" recv : reads data on uart for timeout seconds, and displays the result on stdout\n");
printf(" show : show settings of selected uart\n");
}
/* ------------------------------------------------------------------------ */
int
main(int argc, const char** argv) {
mraa_uart_context uart = NULL;
int uart_index, i;
int baudrate = 115200, stopbits = 1, databits = 8;
mraa_uart_parity_t parity = MRAA_UART_PARITY_NONE;
unsigned int ctsrts = FALSE, xonxoff = FALSE;
const char *name = NULL, *dev = NULL;
double recieve_timeout = 0.0;
int recieve = FALSE; /* whether we are requested to receive */
int send = FALSE; /* whether we are requested to send or not */
const char *to_send; /* data to send, assigned during parsing of command line */
int show = FALSE; /* whether to show uart settings after everything else*/
/* Initialize MRAA. Init is done automatically if libmraa is compiled
with a compiler that supports __attribute__((constructor)), like
GCC and CLANG
*/
mraa_init();
if (argc <= 1) {
uarttool_usage(argv[0]);
} else
if (!strcmp(argv[1], "list")) {
int number_of_uarts = mraa_get_uart_count();
for (uart_index = 0; uart_index < number_of_uarts; uart_index++) {
mraa_result_t res = mraa_uart_settings(uart_index, &name, &dev, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
if (res == MRAA_SUCCESS) {
if (name == NULL) name = undefined;
if (dev == NULL) dev = undefined;
printf("%i. %-12s %-16s %7i %i%c%i %s %s\n", uart_index, name, dev, baudrate, databits, paritymode_table[parity], stopbits, ctsrts?"CTSRTS":"(none)", xonxoff?"XONXOFF":"(none) ");
} else {
printf("%i. ---- error reading uart information ----\n", uart_index);
}
}
} else {
for (i=1; i<argc; i++) {
if (!strcmp(argv[i], "dev")) {
uart = uarttool_find(argv[i+1]);
if (uart == NULL) {
fprintf(stderr, "%s : cannot find uart %s\n", argv[0], argv[i+1]);
break;
}
dev = mraa_uart_get_dev_path(uart);
mraa_result_t res = mraa_uart_settings(-1, &dev, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
if (res != MRAA_SUCCESS) {
fprintf(stderr, "warning: problems accessing uart settings, attempting to continue\n");
}
} else
/* Baudrate setting */
if (!strcmp(argv[i], "baud") || !strcmp(argv[i], "baudrate")) {
if (i+1 >= argc || !isdigit(argv[i+1][0])) {
fprintf(stderr, "%s : %s needs number as argument\n", argv[0], argv[i]);
break;
}
baudrate = atoi(argv[i+1]);
if (uart != NULL) {
mraa_uart_set_baudrate(uart, baudrate);
}
i++;
} else
/* Accept a few variants of the flow control setting name */
if (!strcmp(argv[i], "ctsrts") || !strcmp(argv[i], "rtscts") || !strcmp(argv[i], "crtscts")) {
if (i+1 >= argc || argv[i+1][0] != 'o') {
fprintf(stderr, "%s : ctsrts needs either on or off as argument\n", argv[0]);
break;
}
ctsrts = !strcmp(argv[i+1], "on") ? 1u : 0u;
xonxoff = 0u;
if (uart != NULL) {
mraa_uart_set_flowcontrol(uart, xonxoff, ctsrts);
}
i++;
} else
/* Number of stopbits */
if (!strcmp(argv[i], "stopbits")) {
if (i+1 >= argc || !isdigit(argv[i+1][0])) {
fprintf(stderr, "%s : %s needs number as argument\n", argv[0], argv[i]);
break;
}
stopbits = atoi(argv[i+1]);
if (stopbits < 1 || stopbits > 2) {
stopbits = 1;
fprintf(stderr, "%s : invalid number of stopbits, bust be 1 or 2\n", argv[0]);
}
if (uart != NULL) {
mraa_uart_set_mode(uart, databits, parity, stopbits);
}
i++;
} else
/* Databits */
if (!strcmp(argv[i], "databits") || !strcmp(argv[i], "bytesize")) {
if (i+1 >= argc || !isdigit(argv[i+1][0])) {
fprintf(stderr, "%s : %s needs number as argument\n", argv[0], argv[i]);
break;
}
databits = atoi(argv[i+1]);
if (uart != NULL) {
mraa_uart_set_mode(uart, databits, parity, stopbits);
}
i++;
} else
/* Parity mode, uses paritmode array */
if (!strcmp(argv[i], "paritybits") || !strcmp(argv[i], "parity")) {
int j;
if (i+1 >= argc) {
fprintf(stderr, "%s : %s needs 'O','E' or 'N' as argument\n", argv[0], argv[i]);
break;
}
/* Even if there were gaps between declared array elements, they would be initialized to 0 compile time */
for (j=0; j<sizeof(paritymode_table); j++) {
if (paritymode_table[j] == toupper(argv[i+1][0])) {
parity = j;
break;
}
}
if (j >= sizeof(paritymode_table)) {
fprintf(stderr, "warning: unrecognized parity mode %s (ignoring)\n", argv[i+1]);
}
if (uart != NULL) {
mraa_uart_set_mode(uart, databits, parity, stopbits);
}
i++;
} else
/* Show settings */
if (!strcmp(argv[i], "show")) {
show = TRUE;
} else
/* Send data */
if (!strcmp(argv[i], "send")) {
if (i+1 >= argc) {
fprintf(stderr, "%s : %s needs string as argument\n", argv[0], argv[i]);
break;
}
send = TRUE;
to_send = argv[i+1];
i++;
} else
if (!strcmp(argv[i], "receive") || !strcmp(argv[i], "recieve") || !strcmp(argv[i], "recv")) {
if (i+1 >= argc) {
fprintf(stderr, "%s : %s needs a timeout (in seconds, fractional ok) as argument\n", argv[0], argv[i]);
break;
}
recieve = TRUE;
recieve_timeout = atof(argv[i+1]);
i++;
}
}
if (i == argc && uart != NULL) {
if (send) {
mraa_uart_write(uart, to_send, strlen(to_send)+1);
}
if (recieve) {
uarttool_read_and_print(uart, recieve_timeout);
}
if (show) {
if (recieve) putchar('\n');
dev = mraa_uart_get_dev_path(uart);
mraa_uart_settings(-1, &dev, &name, &baudrate, &databits, &stopbits, &parity, &ctsrts, &xonxoff);
printf("%-12s %-16s %7i %i%c%i %s %s\n", name!=NULL?name:undefined, dev, baudrate, databits, paritymode_table[parity], stopbits, ctsrts?"CTS/RTS":"(no hw)", xonxoff?"XONXOFF":"(no sw)");
}
} else {
uarttool_usage(argv[0]);
}
}
mraa_deinit();
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,26 @@
{
"version": "0.1.0",
"platform":[
{
"id":301,
"name":"Intel Aero",
"pin_count": 0,
"gpio_count": 0,
"i2c_count": 1,
"aio_count": 0,
"spi_count": 1,
"uart_count": 0,
}
],
"layout":[
],
"GPIO":[
],
"I2C": [
{ "index": 0, "bus" : 2, "default":true }
],
"SPI": [
{ "index":0, "bus": 3, "slaveselect": 0, "default": true}
],
}

View File

@@ -1,73 +1,74 @@
{
"version": "1.0.0",
"platform":[
{ "id":300,
"name":"Turbot",
"pin_count": 28,
"gpio_count": 28,
"i2c_count": 1,
"aio_count": 0,
"spi_count": 1,
"uart_count": 1,
"pwmDefPeriod":500,
"pwmMaxPeriod":1000000000,
"pwmMinPeriod":1
"version": "1.1.0",
"platform": [
{
"id":300,
"name":"Turbot",
"pin_count": 28,
"gpio_count": 28,
"i2c_count": 1,
"aio_count": 0,
"spi_count": 1,
"uart_count": 1,
"pwmDefPeriod":500,
"pwmMaxPeriod":1000000000,
"pwmMinPeriod":1
}
],
"layout":[
{"label": "INVALID", "invalid": true},
{"label": "GND"},
{"label": "GND"},
{"label": "5v"},
{"label": "3.3v"},
{"label": "SPI_CS"},
{"label": "UART1TX"},
{"label": "SPIMISO"},
{"label": "UART1RX"},
{"label": "SPIMOSI"},
{"label": "UART1CT"},
{"label": "SPI_CLK"},
{"label": "UART1RT"},
{"label": "I2C_SCL"},
{"label": "I2S_CLK"},
{"label": "I2C_SDA"},
{"label": "I2S_FRM"},
{"label": "UART2TX"},
{"label": "I2S_DO"},
{"label": "UART2RX"},
{"label": "I2S_DI"},
{"label": "S5_0"},
{"label": "PWM0"},
{"label": "S5_1"},
{"label": "PWM1"},
{"label": "S5_4"},
{"label": "I2S_MCLK"},
{"label": "S5_22"}
"layout": [
{"label": "INVALID", "invalid": true},
{"label": "GND"},
{"label": "GND"},
{"label": "5v"},
{"label": "3.3v"},
{"label": "SPI_CS"},
{"label": "UART1TX"},
{"label": "SPIMISO"},
{"label": "UART1RX"},
{"label": "SPIMOSI"},
{"label": "UART1CT"},
{"label": "SPI_CLK"},
{"label": "UART1RT"},
{"label": "I2C_SCL"},
{"label": "I2S_CLK"},
{"label": "I2C_SDA"},
{"label": "I2S_FRM"},
{"label": "UART2TX"},
{"label": "I2S_DO"},
{"label": "UART2RX"},
{"label": "I2S_DI"},
{"label": "S5_0"},
{"label": "PWM0"},
{"label": "S5_1"},
{"label": "PWM1"},
{"label": "S5_4"},
{"label": "I2S_MCLK"},
{"label": "S5_22"}
],
"GPIO": [
{ "index": 10, "rawpin": 483 },
{ "index": 12, "rawpin": 482 },
{ "index": 14, "rawpin": 472 },
{ "index": 16, "rawpin": 473 },
{ "index": 18, "rawpin": 475 },
{ "index": 20, "rawpin": 474 },
{ "index": 21, "rawpin": 338 },
{ "index": 23, "rawpin": 339 },
{ "index": 25, "rawpin": 340 },
{ "index": 26, "rawpin": 509 },
{ "index": 27, "rawpin": 360 }
],
"GPIO":[
{ "index": 10, "rawpin": 483 },
{ "index": 12, "rawpin": 482 },
{ "index": 14, "rawpin": 472 },
{ "index": 16, "rawpin": 473 },
{ "index": 18, "rawpin": 475 },
{ "index": 20, "rawpin": 474 },
{ "index": 21, "rawpin": 338 },
{ "index": 23, "rawpin": 339 },
{ "index": 25, "rawpin": 340 },
{ "index": 26, "rawpin": 509 },
{ "index": 27, "rawpin": 360 }
"I2C": [
{ "sclpin":13, "sdapin":15, "bus": 9, "index": 0, "default":true }
],
"I2C": [
{ "sclpin":13, "sdapin":15, "rawpin": 0, "index": 0, "default":true }
],
"PWM": [
{ "index":22, "rawpin":0, "chipID":0},
{ "index":24, "rawpin":0, "chipID":1 }
],
"SPI": [
{ "index":0, "chipID": 0, "clock": 11, "miso": 7, "mosi": 9, "chipselect": 5, "default": true}
],
"UART":[
{ "index":0, "chipID":0, "rawpin":0, "path":"/dev/ttyS0", "default":true}
]
"PWM": [
{ "index":22, "rawpin":0, "chipID":0},
{ "index":24, "rawpin":0, "chipID":1 }
],
"SPI": [
{ "index":0, "bus": 0, "slaveselect": 0, "clock": 11, "miso": 7, "mosi": 9, "chipselect": 5, "default": true}
],
"UART": [
{ "index":0, "chipID":0, "rawpin":0, "path":"/dev/ttyS0", "default":true}
]
}

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python
# Author: Henry Bruce <henry.bruce@intel.com>
# Copyright (c) 2016 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
# Read from MCP3004 ADC pin 0 in single ended mode
import mraa
import time
dev = mraa.Spi(0)
txbuf = bytearray(3)
txbuf[0] = 0x01
txbuf[1] = 0x80
txbuf[2] = 0x00
while True:
rxbuf = dev.write(txbuf)
value = ((rxbuf[1] & 0x03) << 8) | rxbuf[2]
print value
time.sleep(0.5)

View File

@@ -85,4 +85,5 @@ main(int argc, char** argv)
mraa_spi_stop(spi);
//! [Interesting]
return 0;
}

View File

@@ -33,7 +33,6 @@ main(int argc, char** argv)
//! [Interesting]
mraa_spi_context spi;
spi = mraa_spi_init(0);
unsigned int response = 0;
printf("Hello, SPI initialised\n");
uint8_t data[] = { 0x00, 100 };
uint8_t* recv;

View File

@@ -1,10 +1,11 @@
add_executable (imraa imraa.c)
add_executable (imraa imraa.c imraa_arduino.c imraa_io.c imraa_lock.c)
include_directories (${PROJECT_SOURCE_DIR}/api)
include_directories (${PROJECT_SOURCE_DIR}/include)
include_directories (${PROJECT_SOURCE_DIR}/api/mraa)
include_directories (${PROJECT_SOURCE_DIR}/imraa)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
find_package (JSON-C REQUIRED)
include_directories (${JSON-C_INCLUDE_DIR})

View File

@@ -1,7 +1,7 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Longwei Su <lsu@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -29,395 +29,23 @@
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <json-c/json.h>
#include <libudev.h>
#include <error.h>
#include <sys/types.h>
#include <mraa/uart.h>
#include <mraa/gpio.h>
#include <mraa/i2c.h>
#include <mraa/pwm.h>
#include <json-c/json.h>
#include <argp.h>
#include <mraa_internal.h>
#include <imraa_arduino.h>
#include <imraa_io.h>
#include <imraa_lock.h>
#define IMRAA_CONF_FILE "/etc/imraa.conf"
typedef struct mraa_io_objects_t {
const char* type;
int index;
bool raw;
const char* label;
} mraa_io_objects_t;
const char*
imraa_list_serialport()
{
struct udev* udev;
struct udev_enumerate* enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device* dev;
const char* ret = NULL;
udev = udev_new();
if (!udev) {
printf("Can't create udev, check libudev\n");
exit(1);
}
enumerate = udev_enumerate_new(udev);
udev_enumerate_add_match_subsystem(enumerate, "tty");
udev_enumerate_add_match_property(enumerate, "ID_VENDOR_ID", "8087");
udev_enumerate_add_match_property(enumerate, "ID_MODEL_ID", "0ab6");
// udev_enumerate_add_match_property(enumerate, "ID_SERIAL",
// "Intel_ARDUINO_101_AE6642SQ55000RS");
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
udev_list_entry_foreach(dev_list_entry, devices)
{
const char* path;
path = udev_list_entry_get_name(dev_list_entry);
dev = udev_device_new_from_syspath(udev, path);
ret = udev_device_get_devnode(dev);
}
udev_enumerate_unref(enumerate);
udev_unref(udev);
if (ret) {
printf("Ardunio 101 Device Node Path: %s\n", ret);
} else {
printf("Can't detect any Ardunio 101 Device on tty\n");
}
return ret;
}
mraa_result_t
imraa_reset_arduino(const char* modem)
{
mraa_uart_context uart;
uart = mraa_uart_init_raw(modem);
mraa_uart_set_baudrate(uart, 1200);
if (uart == NULL) {
fprintf(stderr, "UART failed to setup\n");
return MRAA_ERROR_UNSPECIFIED;
}
mraa_uart_stop(uart);
mraa_deinit();
return MRAA_SUCCESS;
}
int
imraa_flash_101(const char* bin_path, const char* bin_file_name, const char* tty)
{
if (imraa_reset_arduino(tty) != MRAA_SUCCESS) {
fprintf(stderr, "Failed to reset arduino on %s for unknown reason, carrying on...\n", tty);
}
char* ln = NULL;
size_t len = 0;
bool board_found = false;
const char* dfu_list = "/dfu-util -d ,8087:0ABA -l";
size_t bin_path_len = strlen(bin_path);
char* full_dfu_list = (char*) calloc((bin_path_len + strlen(dfu_list) + 1), sizeof(char));
if (!full_dfu_list) {
printf("imraa_flash_101 can't allocate string buffer for dfu list\n");
exit(1);
}
strncat(full_dfu_list, bin_path, strlen(bin_path));
strncat(full_dfu_list, dfu_list, strlen(dfu_list));
int i;
// dfu list is still needed, as the time for reset and recognized is varies from platform to
// platform.
// once dfu able to query available devices, then it is ready to flash
for (i = 0; i < 10 && board_found == false; i++) {
printf("Waiting for device...\n");
// dfu-util -d,8087:0ABA -l
FILE* dfu_result = popen(full_dfu_list, "r");
if (dfu_result == NULL) {
printf("Failed to run command\n");
exit(1);
}
if (i == 4) {
printf("Flashing is taking longer than expected\n");
printf("Try pressing MASTER_RESET button\n");
}
while (getline(&ln, &len, dfu_result) != -1) {
if (strstr(ln, "sensor_core")) {
board_found = true;
printf("Device found!\n");
break;
}
}
sleep(1);
if (pclose(dfu_result) != 0) {
printf("Failed to close command\n");
exit(1);
}
}
free(ln);
if (board_found == false) {
printf("ERROR: Device is not responding.\n");
exit(1);
}
const char* dfu_upload = "/dfu-util -d ,8087:0ABA -D ";
const char* dfu_option = " -v -a 7 -R";
int buffersize = bin_path_len + strlen(dfu_upload) + strlen(bin_file_name) + strlen(dfu_option) + 1;
char* full_dfu_upload = calloc(buffersize, sizeof(char));
if (!full_dfu_upload) {
printf("imraa_flash_101 can't allocate string buffer for dfu flash\n");
exit(1);
}
strncat(full_dfu_upload, bin_path, strlen(bin_path));
strncat(full_dfu_upload, dfu_upload, strlen(dfu_upload));
strncat(full_dfu_upload, bin_file_name, strlen(bin_file_name));
strncat(full_dfu_upload, dfu_option, strlen(dfu_option));
printf("flash cmd: %s\n", full_dfu_upload);
int status = system(full_dfu_upload);
if (status != 0) {
printf("ERROR: Upload failed on %s\n", tty);
exit(1);
}
printf("SUCCESS: Sketch will execute in about 5 seconds.\n");
free(full_dfu_list);
free(full_dfu_upload);
sleep(5);
return 0;
}
void
imraa_write_lockfile(const char* lock_file_location, const char* serialport)
{
FILE* fh;
char str[10];
json_object* platform1 = json_object_new_object();
snprintf(str, 10, "%d", MRAA_NULL_PLATFORM);
json_object_object_add(platform1, "id", json_object_new_string(str));
json_object* platform2 = json_object_new_object();
snprintf(str, 10, "%d", MRAA_GENERIC_FIRMATA);
json_object_object_add(platform2, "id", json_object_new_string(str));
json_object_object_add(platform2, "uart", json_object_new_string(serialport));
json_object* platfroms = json_object_new_array();
json_object_array_add(platfroms, platform1);
json_object_array_add(platfroms, platform2);
json_object* lock_file = json_object_new_object();
json_object_object_add(lock_file, "Platform", platfroms);
fh = fopen(lock_file_location, "w");
if (fh != NULL) {
fputs(json_object_to_json_string_ext(lock_file, JSON_C_TO_STRING_PRETTY), fh);
fclose(fh);
} else {
fprintf(stderr, "can't write to lock file\n");
}
json_object_put(lock_file);
}
void
imraa_handle_subplatform(struct json_object* jobj, bool force_update)
{
struct json_object* platform;
int i, ionum;
const char* dfu_loc = NULL;
const char* lockfile_loc = NULL;
const char* flash_loc = NULL;
const char* usbserial = NULL;
struct json_object* dfu_location;
if (json_object_object_get_ex(jobj, "dfu-utils-location", &dfu_location) == true) {
if (json_object_is_type(dfu_location, json_type_string)) {
printf("dfu location: %s\n", json_object_get_string(dfu_location));
dfu_loc = json_object_get_string(dfu_location);
} else {
fprintf(stderr, "dfu location string incorrectly parsed\n");
}
}
struct json_object* lockfile_location;
if (json_object_object_get_ex(jobj, "lockfile-location", &lockfile_location) == true) {
if (json_object_is_type(lockfile_location, json_type_string)) {
printf("lock file location: %s\n", json_object_get_string(lockfile_location));
lockfile_loc = json_object_get_string(lockfile_location);
} else {
fprintf(stderr, "lock file string incorrectly parsed\n");
}
}
if (json_object_object_get_ex(jobj, "Platform", &platform) == true) {
if (json_object_is_type(platform, json_type_array)) {
ionum = json_object_array_length(platform);
for (i = 0; i < ionum; i++) {
struct json_object* ioobj = json_object_array_get_idx(platform, i);
json_object_object_foreach(ioobj, key, val)
{
if (strcmp(key, "flash") == 0) {
flash_loc = json_object_get_string(val);
}
if (strcmp(key, "usbserial") == 0) {
usbserial = json_object_get_string(val);
}
}
}
} else {
fprintf(stderr, "platform string incorrectly parsed\n");
}
}
if (flash_loc == NULL || usbserial == NULL ) {
printf("conf didn't give image location or usb serial, skip flashing\n");
return;
}
if (!dfu_loc) {
dfu_loc = "/usr/bin";
printf("No dfu path found, using default path /usr/bin instead");
}
if (!lockfile_loc) {
lockfile_loc = "/tmp/imraa.lock";
printf("No lock path found, using default lock file /tmp/imraa.lock instead");
}
// got flash? do flash
if (access(lockfile_loc, F_OK) != -1 && force_update == false) {
printf("already exist a lock file, skip flashing\n");
printf("force upgrade? remove the lockfile or run with force\n", lockfile_loc);
return;
} else {
fprintf(stdout, "Starting to flash board\n");
if (force_update) {
fprintf(stdout, "**Caution: force update mode**\n");
}
// TODO flash img checksum, and serialport validation?
const char* detected_serialport = imraa_list_serialport();
if (detected_serialport == NULL) {
printf("No subplatform detected, check USB connection, skip flashing\n");
return;
}
if (strcmp(usbserial, "auto") != 0 && strcmp(usbserial, detected_serialport) != 0) {
printf("given serial port didn't match detected serial port, skip flashing\n");
return;
}
if (imraa_flash_101(dfu_loc, flash_loc, detected_serialport) == 0) {
imraa_write_lockfile(lockfile_loc, detected_serialport);
} else {
fprintf(stderr, "invalid flashing paramenters, please check agian\n");
fprintf(stderr, "DFU Util location: %s\n", dfu_loc);
fprintf(stderr, "Flash Img location: %s\n", dfu_loc);
fprintf(stderr, "USB Serial: %s\n", usbserial);
fprintf(stderr, "Flash failed, push master reset and try again\n");
}
}
}
void
imraa_handle_IO(struct json_object* jobj)
{
struct mraa_io_objects_t* mraa_io_obj;
struct json_object* ioarray;
int ionum = 0;
int i;
if (json_object_object_get_ex(jobj, "IO", &ioarray) == true) {
ionum = json_object_array_length(ioarray);
printf("Length of IO array is %d\n", ionum);
mraa_io_obj = (mraa_io_objects_t*) malloc(ionum * sizeof(mraa_io_objects_t));
if (!mraa_io_obj) {
printf("imraa_handle_IO malloc failed\n");
exit(1);
}
int index2 = -1;
; // optional index for io configuration;
if (json_object_is_type(ioarray, json_type_array)) {
for (i = 0; i < ionum; i++) {
struct json_object* ioobj = json_object_array_get_idx(ioarray, i);
struct json_object* x;
if (json_object_object_get_ex(ioobj, "type", &x) == true) {
mraa_io_obj[i].type = json_object_get_string(x);
}
if (json_object_object_get_ex(ioobj, "index", &x) == true) {
mraa_io_obj[i].index = json_object_get_int(x);
}
if (json_object_object_get_ex(ioobj, "raw", &x) == true) {
mraa_io_obj[i].raw = json_object_get_boolean(x);
}
if (json_object_object_get_ex(ioobj, "label", &x) == true) {
mraa_io_obj[i].label = json_object_get_string(x);
}
if (json_object_object_get_ex(ioobj, "index2", &x) == true) {
index2 = json_object_get_int(x);
}
// starting io configuration
if (strcmp(mraa_io_obj[i].type, "gpio") == 0) {
mraa_gpio_context gpio = NULL;
if (mraa_io_obj[i].raw) {
gpio = mraa_gpio_init_raw(mraa_io_obj[i].index);
} else {
gpio = mraa_gpio_init(mraa_io_obj[i].index);
}
if (gpio != NULL) {
mraa_result_t r = mraa_gpio_owner(gpio, 0);
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
mraa_gpio_close(gpio);
}
} else if (strcmp(mraa_io_obj[i].type, "i2c") == 0) {
mraa_i2c_context i2c = NULL;
if (mraa_io_obj[i].raw) {
i2c = mraa_i2c_init_raw(mraa_io_obj[i].index);
} else {
i2c = mraa_i2c_init(mraa_io_obj[i].index);
}
if (i2c != NULL) {
mraa_i2c_stop(i2c);
}
} else if (strcmp(mraa_io_obj[i].type, "pwm") == 0) {
mraa_pwm_context pwm = NULL;
if (mraa_io_obj[i].raw) {
pwm = mraa_pwm_init_raw(index2, mraa_io_obj[i].index);
} else {
pwm = mraa_pwm_init(mraa_io_obj[i].index);
}
if (pwm != NULL) {
mraa_result_t r = mraa_pwm_owner(pwm, 0);
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
mraa_pwm_close(pwm);
}
} else if (strcmp(mraa_io_obj[i].type, "spi") == 0) {
mraa_spi_context spi = NULL;
if (mraa_io_obj[i].raw) {
spi = mraa_spi_init_raw(mraa_io_obj[i].index, index2);
} else {
spi = mraa_spi_init(mraa_io_obj[i].index);
}
if (spi != NULL) {
mraa_spi_stop(spi);
}
} else if (strcmp(mraa_io_obj[i].type, "uart") == 0) {
mraa_uart_context uart = NULL;
if (mraa_io_obj[i].raw) {
uart = mraa_uart_init_raw(mraa_io_obj[i].label);
} else {
uart = mraa_uart_init(mraa_io_obj[i].index);
}
if (uart != NULL) {
mraa_uart_stop(uart);
}
}
}
} else {
fprintf(stderr, "IO array incorrectly parsed\n");
}
free(mraa_io_obj);
}
}
int
check_version(struct json_object* jobj)
imraa_check_version(struct json_object* jobj)
{
struct json_object* imraa_version;
if (json_object_object_get_ex(jobj, "version", &imraa_version) == true) {
@@ -434,58 +62,82 @@ check_version(struct json_object* jobj)
return 0;
}
void
print_version()
const char *argp_program_version = "imraa version 2.0";
const char *argp_program_bug_address = "http://github.com/intel-iot-devkit/mraa/issues";
static char doc[] = "somestuff";
static char args_doc[] = "-i imraa.conf";
static struct argp_option options[] = {
{"verbose", 'v', 0, 0, "Produce verbose output" },
{"quiet", 'q', 0, 0, "Don't produce any output" },
{"silent", 's', 0, OPTION_ALIAS },
{"force", 'f', 0, 0, "Force update" },
{"arduino", 'a', 0, 0, "Arduino detection" },
{"input", 'i', "FILE", 0,
"configuration file" },
{ 0 }
};
struct arguments
{
fprintf(stdout, "Version %s on %s\n", mraa_get_version(), mraa_get_platform_name());
char *args[2];
int silent, verbose, force, arduino;
char *input_file;
};
static error_t
parse_opt(int key, char *arg, struct argp_state *state)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
struct arguments *arguments = state->input;
switch(key) {
case 'q': case 's':
arguments->silent = 1;
break;
case 'v':
arguments->verbose = 1;
break;
case 'a':
arguments->arduino = 1;
break;
case 'f':
arguments->force = 1;
break;
case 'i':
arguments->input_file = arg;
break;
case ARGP_KEY_ARG:
break;
case ARGP_KEY_END:
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
void
print_help()
{
fprintf(stdout, "version Get mraa version and board name\n");
fprintf(stdout, "force Force update subplatform\n");
fprintf(stdout, "conf_path Force update with override configuration\n");
}
void
print_command_error()
{
fprintf(stdout, "Invalid command, options are:\n");
print_help();
exit(EXIT_FAILURE);
}
static struct argp argp = { options, parse_opt, args_doc, doc};
int
main(int argc, char** argv)
{
char* buffer = NULL;
char* imraa_conf_file = IMRAA_CONF_FILE;
long fsize;
bool force_update = false;
int i = 0;
uint32_t ionum = 0;
struct arguments arguments;
if (argc > 2) {
print_command_error();
}
arguments.silent = 0;
arguments.verbose = 0;
arguments.force = 0;
arguments.input_file = IMRAA_CONF_FILE;
if (argc > 1) {
if (strcmp(argv[1], "help") == 0) {
print_help();
return EXIT_SUCCESS;
} else if (strcmp(argv[1], "version") == 0) {
print_version();
return EXIT_SUCCESS;
} else if (strcmp(argv[1], "force") == 0) {
force_update = true;
} else {
imraa_conf_file = argv[1];
force_update = true;
}
}
argp_parse(&argp, argc, argv, 0, 0, &arguments);
FILE* fh = fopen(imraa_conf_file, "r");
FILE* fh = fopen(arguments.input_file, "r");
if (fh == NULL) {
fprintf(stderr, "Failed to open configuration file\n");
return EXIT_FAILURE;
@@ -497,28 +149,33 @@ main(int argc, char** argv)
buffer = calloc(fsize, sizeof(char));
if (buffer != NULL) {
int result = fread(buffer, sizeof(char), fsize, fh);
if (result != fsize) {
printf("imraa conf reading error");
if (result != (fsize - 1)) {
printf("imraa conf reading error\n");
}
} else {
printf("imraa read_conf buffer can't allocated\n");
exit(1);
}
// call reduced imraa_init (not that mraa_init) will already have been called
imraa_init();
json_object* jobj = json_tokener_parse(buffer);
if (check_version(jobj) != 0) {
if (imraa_check_version(jobj) != 0) {
printf("version of configuration file is not compatible, please check again\n");
} else {
mraa_platform_t type = mraa_get_platform_type();
imraa_handle_subplatform(jobj, force_update);
if (type == MRAA_NULL_PLATFORM || type == MRAA_UNKNOWN_PLATFORM) {
printf("imraa: Failed to do IO pinmuxing on null/unkown platform\n");
} else {
imraa_handle_IO(jobj);
if (arguments.arduino) {
imraa_handle_subplatform(jobj, arguments.force);
}
if (type == MRAA_NULL_PLATFORM || type == MRAA_UNKNOWN_PLATFORM) {
printf("imraa: attempting to do IO pinmuxing on null/unkown platform\n");
}
imraa_handle_IO(jobj);
}
fclose(fh);
json_object_put(jobj);
free(buffer);

View File

@@ -1,12 +1,8 @@
{
"version": "0.9.6",
"version": "2.0",
"lockfile-location": "/tmp/imraa.lock",
"dfu-utils-location": "/usr/bin",
"Platform" :[
{"id":"1280", "flash":"/usr/share/mraa/firmata101.ino.bin", "usbserial": "auto"}
],
"IO": [
{"type":"gpio", "index":0, "raw": false, "label": "none"},
{"type":"i2c", "index":0, "raw": false, "label": "i2c-0"}
]
}

12
imraa/imraa.io.conf Normal file
View File

@@ -0,0 +1,12 @@
{
"version": "1.4.0",
"lockfile-location": "/tmp/imraa.lock",
"dfu-utils-location": "/usr/bin",
"Platform" :[
{"id":"1280", "flash":"/usr/share/mraa/firmata101.ino.bin", "usbserial": "auto"}
],
"IO": [
{"type":"gpio", "index":0, "raw": false, "label": "none", "user": "brendan", "group": "brendan"},
{"type":"i2c", "index":0, "raw": false, "label": "i2c-0", "user": "brendan", "group": "user"}
]
}

View File

@@ -3,7 +3,7 @@ Description=imraa
[Service]
Type=oneshot
ExecStart=/usr/bin/imraa
ExecStart=/usr/bin/imraa -a
[Install]
WantedBy = multi-user.target
WantedBy=multi-user.target

279
imraa/imraa_arduino.c Normal file
View File

@@ -0,0 +1,279 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Longwei Su <lsu@ics.com>
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <json-c/json.h>
#include <libudev.h>
#include <argp.h>
#include <error.h>
#include <mraa/uart.h>
#include <mraa/gpio.h>
#include <mraa/i2c.h>
#include <mraa/pwm.h>
#include <mraa_internal.h>
#include <imraa_lock.h>
const char*
imraa_get_101_serialport()
{
struct udev* udev;
struct udev_enumerate* enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device* dev;
const char* ret = NULL;
udev = udev_new();
if (!udev) {
printf("Can't create udev, check libudev\n");
exit(1);
}
enumerate = udev_enumerate_new(udev);
udev_enumerate_add_match_subsystem(enumerate, "tty");
udev_enumerate_add_match_property(enumerate, "ID_VENDOR_ID", "8087");
udev_enumerate_add_match_property(enumerate, "ID_MODEL_ID", "0ab6");
// udev_enumerate_add_match_property(enumerate, "ID_SERIAL",
// "Intel_ARDUINO_101_AE6642SQ55000RS");
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
udev_list_entry_foreach(dev_list_entry, devices)
{
const char* path;
path = udev_list_entry_get_name(dev_list_entry);
dev = udev_device_new_from_syspath(udev, path);
ret = udev_device_get_devnode(dev);
}
udev_enumerate_unref(enumerate);
udev_unref(udev);
if (ret) {
printf("Ardunio 101 Device Node Path: %s\n", ret);
} else {
printf("Can't detect any Ardunio 101 Device on tty\n");
}
return ret;
}
mraa_result_t
imraa_reset_arduino(const char* modem)
{
mraa_uart_context uart;
uart = mraa_uart_init_raw(modem);
mraa_uart_set_baudrate(uart, 1200);
if (uart == NULL) {
fprintf(stderr, "UART failed to setup\n");
return MRAA_ERROR_UNSPECIFIED;
}
mraa_uart_stop(uart);
mraa_deinit();
return MRAA_SUCCESS;
}
int
imraa_flash_101(const char* bin_path, const char* bin_file_name, const char* tty)
{
if (imraa_reset_arduino(tty) != MRAA_SUCCESS) {
fprintf(stderr, "Failed to reset arduino on %s for unknown reason, carrying on...\n", tty);
}
char* ln = NULL;
size_t len = 0;
bool board_found = false;
const char* dfu_list = "/dfu-util -d ,8087:0ABA -l";
size_t bin_path_len = strlen(bin_path);
char* full_dfu_list = (char*) calloc((bin_path_len + strlen(dfu_list) + 1), sizeof(char));
if (!full_dfu_list) {
printf("imraa_flash_101 can't allocate string buffer for dfu list\n");
exit(1);
}
strncat(full_dfu_list, bin_path, strlen(bin_path));
strncat(full_dfu_list, dfu_list, strlen(dfu_list));
int i;
// dfu list is still needed, as the time for reset and recognized is varies from platform to
// platform.
// once dfu able to query available devices, then it is ready to flash
for (i = 0; i < 10 && board_found == false; i++) {
printf("Waiting for device...\n");
// dfu-util -d,8087:0ABA -l
FILE* dfu_result = popen(full_dfu_list, "r");
if (dfu_result == NULL) {
printf("Failed to run command\n");
exit(1);
}
if (i == 4) {
printf("Flashing is taking longer than expected\n");
printf("Try pressing MASTER_RESET button\n");
}
while (getline(&ln, &len, dfu_result) != -1) {
if (strstr(ln, "sensor_core")) {
board_found = true;
printf("Device found!\n");
break;
}
}
sleep(1);
if (pclose(dfu_result) != 0) {
printf("Failed to close command\n");
exit(1);
}
}
free(ln);
if (board_found == false) {
printf("ERROR: Device is not responding.\n");
exit(1);
}
const char* dfu_upload = "/dfu-util -d ,8087:0ABA -D ";
const char* dfu_option = " -v -a 7 -R";
int buffersize = bin_path_len + strlen(dfu_upload) + strlen(bin_file_name) + strlen(dfu_option) + 1;
char* full_dfu_upload = calloc(buffersize, sizeof(char));
if (!full_dfu_upload) {
printf("imraa_flash_101 can't allocate string buffer for dfu flash\n");
exit(1);
}
strncat(full_dfu_upload, bin_path, strlen(bin_path));
strncat(full_dfu_upload, dfu_upload, strlen(dfu_upload));
strncat(full_dfu_upload, bin_file_name, strlen(bin_file_name));
strncat(full_dfu_upload, dfu_option, strlen(dfu_option));
printf("flash cmd: %s\n", full_dfu_upload);
int status = system(full_dfu_upload);
if (status != 0) {
printf("ERROR: Upload failed on %s\n", tty);
exit(1);
}
printf("SUCCESS: Sketch will execute in about 5 seconds.\n");
free(full_dfu_list);
free(full_dfu_upload);
sleep(5);
return 0;
}
void
imraa_handle_subplatform(struct json_object* jobj, bool force_update)
{
struct json_object* platform;
int i, ionum;
const char* dfu_loc = NULL;
const char* lockfile_loc = NULL;
const char* flash_loc = NULL;
const char* usbserial = NULL;
struct json_object* dfu_location;
if (json_object_object_get_ex(jobj, "dfu-utils-location", &dfu_location) == true) {
if (json_object_is_type(dfu_location, json_type_string)) {
printf("dfu location: %s\n", json_object_get_string(dfu_location));
dfu_loc = json_object_get_string(dfu_location);
} else {
fprintf(stderr, "dfu location string incorrectly parsed\n");
}
}
struct json_object* lockfile_location;
if (json_object_object_get_ex(jobj, "lockfile-location", &lockfile_location) == true) {
if (json_object_is_type(lockfile_location, json_type_string)) {
printf("lock file location: %s\n", json_object_get_string(lockfile_location));
lockfile_loc = json_object_get_string(lockfile_location);
} else {
fprintf(stderr, "lock file string incorrectly parsed\n");
}
}
if (json_object_object_get_ex(jobj, "Platform", &platform) == true) {
if (json_object_is_type(platform, json_type_array)) {
ionum = json_object_array_length(platform);
for (i = 0; i < ionum; i++) {
struct json_object* ioobj = json_object_array_get_idx(platform, i);
json_object_object_foreach(ioobj, key, val)
{
if (strcmp(key, "flash") == 0) {
flash_loc = json_object_get_string(val);
}
if (strcmp(key, "usbserial") == 0) {
usbserial = json_object_get_string(val);
}
}
}
} else {
fprintf(stderr, "platform string incorrectly parsed\n");
}
}
if (flash_loc == NULL || usbserial == NULL ) {
printf("conf didn't give image location or usb serial, skip flashing\n");
return;
}
if (!dfu_loc) {
dfu_loc = "/usr/bin";
printf("No dfu path found, using default path /usr/bin instead");
}
if (!lockfile_loc) {
lockfile_loc = "/tmp/imraa.lock";
printf("No lock path found, using default lock file /tmp/imraa.lock instead");
}
// got flash? do flash
if (access(lockfile_loc, F_OK) != -1 && force_update == false) {
printf("already exist a lock file, skip flashing\n");
printf("force upgrade? remove the lockfile or run with force\n");
return;
} else {
fprintf(stdout, "Starting to flash board\n");
if (force_update) {
fprintf(stdout, "**Caution: force update mode**\n");
}
// TODO flash img checksum, and serialport validation?
const char* detected_serialport = imraa_get_101_serialport();
if (detected_serialport == NULL) {
printf("No subplatform detected, check USB connection, skip flashing\n");
return;
}
if (strcmp(usbserial, "auto") != 0 && strcmp(usbserial, detected_serialport) != 0) {
printf("given serial port didn't match detected serial port, skip flashing\n");
return;
}
if (imraa_flash_101(dfu_loc, flash_loc, detected_serialport) == 0) {
imraa_write_lockfile(lockfile_loc, detected_serialport);
} else {
fprintf(stderr, "invalid flashing paramenters, please check agian\n");
fprintf(stderr, "DFU Util location: %s\n", dfu_loc);
fprintf(stderr, "Flash Img location: %s\n", dfu_loc);
fprintf(stderr, "USB Serial: %s\n", usbserial);
fprintf(stderr, "Flash failed, push master reset and try again\n");
}
}
}

29
imraa/imraa_arduino.h Normal file
View File

@@ -0,0 +1,29 @@
/*
* Author: Brendan Le Foll <brendan.le.folL@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
void imraa_handle_subplatform(struct json_object* jobj, bool force_update);

178
imraa/imraa_io.c Normal file
View File

@@ -0,0 +1,178 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Copyright (c) 2015-2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <error.h>
#include <sys/types.h>
#include <json-c/json.h>
#include <pwd.h>
#include <mraa/uart.h>
#include <mraa/gpio.h>
#include <mraa/i2c.h>
#include <mraa/pwm.h>
#include <mraa_internal.h>
#include <imraa_arduino.h>
#define SYSFS_CLASS_GPIO "/sys/class/gpio"
#define MAX_SIZE 64
typedef struct mraa_io_objects_t {
const char* type;
int index;
bool raw;
const char* label;
const char* user;
} mraa_io_objects_t;
void
imraa_handle_IO(struct json_object* jobj)
{
struct mraa_io_objects_t* mraa_io_obj;
struct json_object* ioarray;
int ionum = 0;
int i;
if (json_object_object_get_ex(jobj, "IO", &ioarray) == true) {
ionum = json_object_array_length(ioarray);
printf("Length of IO array is %d\n", ionum);
mraa_io_obj = (mraa_io_objects_t*) calloc(ionum, sizeof(mraa_io_objects_t));
if (!mraa_io_obj) {
printf("imraa_handle_IO malloc failed\n");
exit(1);
}
int index2 = -1;
// optional index for io configuration;
if (json_object_is_type(ioarray, json_type_array)) {
for (i = 0; i < ionum; i++) {
struct json_object* ioobj = json_object_array_get_idx(ioarray, i);
struct json_object* x;
if (json_object_object_get_ex(ioobj, "type", &x) == true) {
mraa_io_obj[i].type = json_object_get_string(x);
}
if (json_object_object_get_ex(ioobj, "index", &x) == true) {
mraa_io_obj[i].index = json_object_get_int(x);
}
if (json_object_object_get_ex(ioobj, "raw", &x) == true) {
mraa_io_obj[i].raw = json_object_get_boolean(x);
}
if (json_object_object_get_ex(ioobj, "label", &x) == true) {
mraa_io_obj[i].label = json_object_get_string(x);
}
if (json_object_object_get_ex(ioobj, "index2", &x) == true) {
index2 = json_object_get_int(x);
}
if (json_object_object_get_ex(ioobj, "user", &x) == true) {
mraa_io_obj[i].user = json_object_get_string(x);
}
// starting io configuration
if (strcmp(mraa_io_obj[i].type, "gpio") == 0) {
mraa_gpio_context gpio = NULL;
if (mraa_io_obj[i].raw) {
gpio = mraa_gpio_init_raw(mraa_io_obj[i].index);
} else {
gpio = mraa_gpio_init(mraa_io_obj[i].index);
}
if (gpio != NULL) {
if (mraa_io_obj[i].user != NULL) {
int sysfs_gpio_pin = mraa_gpio_get_pin_raw(gpio);
if (sysfs_gpio_pin >= 0) {
char bu[MAX_SIZE];
snprintf(bu, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/value", sysfs_gpio_pin);
struct passwd* user = getpwnam(mraa_io_obj[i].user);
if (user != NULL) {
if (chown(bu, user->pw_uid, user->pw_gid) == -1) {
fprintf(stderr, "Couldn't change ownership of file %s to %d:%d\n", bu, user->pw_uid, user->pw_gid);
} else {
fprintf(stderr, "Invalid user %s\n", mraa_io_obj[i].user);
}
}
}
mraa_result_t r = mraa_gpio_owner(gpio, 0);
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
}
mraa_gpio_close(gpio);
} else if (strcmp(mraa_io_obj[i].type, "i2c") == 0) {
mraa_i2c_context i2c = NULL;
if (mraa_io_obj[i].raw) {
i2c = mraa_i2c_init_raw(mraa_io_obj[i].index);
} else {
i2c = mraa_i2c_init(mraa_io_obj[i].index);
}
if (i2c != NULL) {
mraa_i2c_stop(i2c);
}
} else if (strcmp(mraa_io_obj[i].type, "pwm") == 0) {
mraa_pwm_context pwm = NULL;
if (mraa_io_obj[i].raw) {
pwm = mraa_pwm_init_raw(index2, mraa_io_obj[i].index);
} else {
pwm = mraa_pwm_init(mraa_io_obj[i].index);
}
if (pwm != NULL) {
mraa_result_t r = mraa_pwm_owner(pwm, 0);
if (r != MRAA_SUCCESS) {
mraa_result_print(r);
}
mraa_pwm_close(pwm);
}
} else if (strcmp(mraa_io_obj[i].type, "spi") == 0) {
mraa_spi_context spi = NULL;
if (mraa_io_obj[i].raw) {
spi = mraa_spi_init_raw(mraa_io_obj[i].index, index2);
} else {
spi = mraa_spi_init(mraa_io_obj[i].index);
}
if (spi != NULL) {
mraa_spi_stop(spi);
}
} else if (strcmp(mraa_io_obj[i].type, "uart") == 0) {
mraa_uart_context uart = NULL;
if (mraa_io_obj[i].raw) {
uart = mraa_uart_init_raw(mraa_io_obj[i].label);
} else {
uart = mraa_uart_init(mraa_io_obj[i].index);
}
if (uart != NULL) {
mraa_uart_stop(uart);
}
}
}
}
} else {
fprintf(stderr, "IO array incorrectly parsed\n");
}
free(mraa_io_obj);
}
}

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