Compare commits

...

37 Commits

Author SHA1 Message Date
Thomas Ingleby
2a682aaa65 python: doc: add python doc to python3
Make sure that right python is used for the right bindings docs

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2016-08-13 13:33:58 +02:00
Brendan Le Foll
d700cae7c4 mraa: Update to v1.2.3
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-10 11:33:28 +01:00
Brendan Le Foll
356096350b README.md: Add travis build status
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-10 11:21:54 +01:00
Brendan Le Foll
b4919de733 .travis.yml: Add npmpkg travis builds
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-10 11:21:54 +01:00
Brendan Le Foll
49ee1ebef5 Revert "binding.gyp.cmake: Fix npm builds by stopping dependency on json-c"
This reverts commit 50213f97bc. This sets
JSONPLAT during compilation and doesn't disable it during cmake's configure
process which is done by jenkins. This means that mraa_init_platform_json never
gets define since it's under an #ifndef
2016-08-10 09:17:48 +01:00
Brendan Le Foll
c0fbccb3b6 mraa: Update to v1.2.2
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-09 14:10:48 +01:00
Thomas Ingleby
fce4daab02 mraa: Correct spelling of capabilities
Type was correctly spelt, but the member in the platform strut was not.
My mistake from 2014.

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2016-08-08 21:44:00 +02:00
Brendan Le Foll
29be2b64c0 mraa: Update to v1.2.1
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-03 16:50:09 +01:00
Brendan Le Foll
50213f97bc binding.gyp.cmake: Fix npm builds by stopping dependency on json-c
This disables JSONPLAT but means we can build on stuff without json-c

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-03 16:49:30 +01:00
Brendan Le Foll
e675123d50 mraa: Update to v1.2.0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-03 13:29:15 +01:00
Brendan Le Foll
36153ad7ad intel_galileo_rev_d.c: Move code for gen1 from pwm.c to advance function
This re-enables correct PWM on gen1

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-03 13:27:35 +01:00
Brendan Le Foll
aed965c27d pwm.c: Remove manual gpio muxing when using a pin that has both pwm & gpio enabled
This fixes PWM on the GT platform. The code was only used on gen1 galileo and
is rarely used because it's the only platform in mraa that supports 2 functions
on the same pin without any time of advanced function pointer being called
(gen2/edison). GT however has kernel side muxing which causes the gpio to be
initialised meaning the PWM channel is never set to active as it's activated
after the GPIO is opened and the GPIO keeps precendence

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-08-03 13:25:32 +01:00
Houman Brinjcargorabi
5d763cb7e5 Example: Added example json file for reference
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Houman Brinjcargorabi
5d94d0a13c travisl.yml: Added the ability to build with json plat to the tests
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Houman Brinjcargorabi
ca0d740ee0 CMakeLists: Added json platform options and build
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Houman Brinjcargorabi
c7570ff7c2 types.h: Added json platform type
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Houman Brinjcargorabi
a8a7771a16 mraa_internal_types: Changed pinmap type from unsigned to signed Int
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Houman Brinjcargorabi
1ce0b138d2 mraa_internal_types.h: changed unsigned ints in board_t to ints and removed const modifiers
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Houman Brinjcargorabi
8ba8ce3b26 mraa.c: Added init platform from json file
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:33:29 +01:00
Alex Tereschenko
346f447c4d mock: added I2C functionality
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:28:53 +01:00
Alex Tereschenko
26718a67a2 mock: split out aio and gpio implementations to separate files
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:28:53 +01:00
Alex Tereschenko
0021b1aace i2c: fixed i2c_stop_replace function never being called
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:28:53 +01:00
Alex Tereschenko
da3efdc4b9 i2c: added standard context validity checks
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:28:53 +01:00
Houman Brinjcargorabi
230b6084ba firmata_mraa.c: Fixed aio bug
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-27 11:10:54 +01:00
Brendan Le Foll
8cd1a06562 mraa: Update to v1.1.2
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-12 12:31:23 +01:00
Brendan Le Foll
874d0f47bd gt: allow for i2c bus to move around a little
Unfortunately GT has alot of i2c buses, the second lot of designware buses can
turn up after the i915 i2c buses but since they all have the same name, we do a
dumb check to see if they are 5/6 or 9/10. Hopefully future kernel/firmware
will let us do something smarter.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-12 12:26:46 +01:00
Brendan Le Foll
6c9aeb9b9e mraa-i2c: stop switching on every platform type and assume linux
This patch makes mraa-i2c give sensible bus numbers

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-12 12:09:37 +01:00
Alex Tereschenko
63b244cfc3 mock: added AIO pin and logic
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-11 10:48:43 +01:00
Alex Tereschenko
917a1bd371 aio: added context validity and replace function checks to aio_close()
Added standard context validity check, another check for a replace function
and corrected a return statement to fit our standard code style.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-11 10:48:43 +01:00
Alex Tereschenko
e43459d031 aio: added standard context validity check to aio_read()
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-11 10:48:43 +01:00
Mihai Tudor Panu
eabee5f864 gt-tuchuck: fix I2C bus typos in board definition file
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-09 08:40:10 +01:00
Jamie Tanna
a22ff43f59 travis-ci: Update infrastructure to Trusty Tahr
Update Travis to use the latest version of Ubuntu: 14.04.3 Trusty Tahr.

- Fix issue where Node v0.10 did not get installed, therefore builds
  would fail. In addition, don't hardcode the path to Node v0.10.36 as
  there have since been updates to v0.10.
- Fix issue where CMake cannot find the PythonLibs folder, fixed via
  https://github.com/travis-ci/travis-ci/issues/5326
- Ensure that we have the Python2 development headers

Signed-off-by: Jamie Tanna <jamie@jamietanna.co.uk>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-08 16:01:30 +01:00
Alex Tereschenko
1af737f3d9 mock: mraa with mock platform now works in Windows under MSYS2
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-05 19:32:58 +01:00
Alex Tereschenko
bcb6adc551 mock: added mraa mock platform infra and GPIO implementation
Mock platform allows one to use mraa without having any real HW.

This commit makes necessary foundational changes and implements
GPIO functionality as well as adds respective tests.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-05 16:19:05 +01:00
Houman Brinjcargorabi
593fd0be54 mraa.c: Removed duplicate sys/stat.h
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-05 11:11:19 +01:00
Houman Brinjcargorabi
3992f9d596 mraa.c: Remove duplicate string.h include
Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-05 11:03:44 +01:00
Brendan Le Foll
43718e7cbf imraa.c: Remove double include unistd.h
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2016-07-04 11:21:04 +01:00
79 changed files with 4023 additions and 640 deletions

View File

@@ -1,27 +1,43 @@
language: cpp
sudo: false
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
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
- if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
- 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 NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
- mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DCMAKE_INSTALL_PREFIX:PATH=../install -DSWIG_EXECUTABLE=/home/travis/bin/swig -DSWIG_DIR:PATH=/home/travis/share/swig/3.0.10/ .. && make install && make test
- 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:
@@ -31,6 +47,9 @@ addons:
- g++-4.8
- cmake
- python
- python-dev
- python3
- python3-dev
- git
- libjson0
- libjson0-dev

View File

@@ -31,7 +31,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.1.1-dirty")
set (VERSION "v1.2.3-dirty")
endif ()
message (STATUS "INFO - libmraa Version ${VERSION}")
@@ -71,6 +71,7 @@ option (BUILDSWIGJAVA "Build Java API." OFF)
option (USBPLAT "Detection USB platform." OFF)
option (FIRMATA "Add Firmata support to mraa." OFF)
option (ONEWIRE "Add Onewire support to mraa." ON)
option (JSONPLAT "Add Platform loading via a json file." ON)
option (IMRAA "Add Imraa support to mraa." OFF)
option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
option (IPK "Generate IPK using CPack" OFF)
@@ -78,9 +79,10 @@ option (RPM "Generate RPM using CPack" OFF)
option (ENABLEEXAMPLES "Disable building of examples" ON)
option (INSTALLGPIOTOOL "Install gpio tool" OFF)
option (INSTALLTOOLS "Install all tools" OFF)
option (BUILDARCH "Override architecture to build for - override" OFF)
option (BUILDTESTS "Override the addition of tests" ON)
set (BUILDARCH "" CACHE STRING "Override architecture to build for")
set (MRAAPLATFORMFORCE "ALL" CACHE STRING "Override platform to build for")
if (NOT BUILDSWIG)
@@ -103,8 +105,10 @@ if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
set (X86PLAT ON)
elseif (DETECTED_ARCH MATCHES "arm.*")
set (ARMPLAT ON)
elseif (DETECTED_ARCH STREQUAL "MOCK")
set (MOCKPLAT ON)
else ()
message (FATAL_ERROR "Only x86 and arm platforms currently supported")
message (FATAL_ERROR "Only x86, arm and mock platforms currently supported")
endif()
if (BUILDSWIGPYTHON OR BUILDTESTS)

View File

@@ -15,6 +15,8 @@ The intent is to make it easier for developers and sensor manufacturers to map
their sensors & actuators on top of supported hardware and to allow control of
low level communication protocol by high level languages & constructs.
[![Build Status](https://travis-ci.org/intel-iot-devkit/mraa.svg?branch=master)](https://travis-ci.org/intel-iot-devkit/mraa)
Supported Boards
================
@@ -39,6 +41,10 @@ USB
---
* [FT4222](../master/docs/ftdi_ft4222.md)
Mock
----
* [Generic simulated board](../master/docs/mock.md)
Installing on your board
========

View File

@@ -44,6 +44,7 @@
if (res != MRAA_SUCCESS) \
return res;} while(0)
/** @file
*
* This file defines the basic shared values for libmraa
@@ -306,6 +307,16 @@ mraa_result_t mraa_remove_subplatform(mraa_platform_t subplatformtype);
*/
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
* was initially run in or a direct path
*
* @return mraa_result indicating success
*/
mraa_result_t mraa_init_json_platform(const char* path);
#ifdef __cplusplus
}
#endif

View File

@@ -327,4 +327,18 @@ initIo(std::string desc)
return new T(mraa_init_io(desc.c_str()));
}
/**
* Instantiate an unknown board using a json file
*
* @param Path to the json file, relative to the folder the program
* was initially run in or a direct path
*
* @return Result indicating success
*/
inline Result
initJsonPlatform(std::string path)
{
return (Result) mraa_init_json_platform(path.c_str());
}
}

View File

@@ -106,7 +106,12 @@ enum iio_event_direction {
};
//linux/iio/events.h
#if defined(MSYS)
#define __USE_LINUX_IOCTL_DEFS
#include <sys/ioctl.h>
#else
#include <linux/ioctl.h>
#endif
/**
* struct iio_event_data - The actual event being pushed to userspace

View File

@@ -58,6 +58,8 @@ typedef enum {
// contains bit 9 so is subplatform
MRAA_GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
MRAA_MOCK_PLATFORM = 96, /**< Mock platform, which requires no real hardware */
MRAA_JSON_PLATFORM = 97, /**< User initialised platform from json*/
MRAA_NULL_PLATFORM = 98, /**< Platform with no capabilities that hosts a sub platform */
MRAA_UNKNOWN_PLATFORM =
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */

View File

@@ -3,7 +3,7 @@
# JSON-C_LIBRARIES - library directories
find_package (PkgConfig)
pkg_check_modules (PC_JSON-C QUIET json-c)
pkg_search_module (PC_JSON-C QUIET json-c json)
find_path (JSON-C_INCLUDE_DIR json.h HINTS ${PC_JSON-C_INCLUDEDIR}
${PC_JSON-C_INCLUDE_DIRS} PATH_SUFFIXES json-c json)

View File

@@ -5,6 +5,29 @@ 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.2.3**
* Revert 1.2.1 binding.gyp changed that had side effect of enabling JSONPLAT in mraa.c
* improve travis.ci to load mraa.node as compiled from make npmpkg target
**1.2.2**
* remove jsonplat from prehashed npm builds (see docs/npm.md for details)
* internal spelling fix
**1.2.1**
* Fix npm pkg build - no other fix
**1.2.0**
* JSON platform support
* mock I2c functionality
* Intel Grosse Tete 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
* travis now uses 14.04 instead of 12.04
**1.1.1**
* IIO 4.6 kernel matrix support
* Intel Grosse Tete radio led support

92
docs/mock.md Normal file
View File

@@ -0,0 +1,92 @@
Mock platform {#mock}
=============
Mocking capability allows libmraa user to work with the library without any real
hardware available. Enabling this requires library recompilation with architecture
override (see Building section below). When mock is enabled, library simulates
actual HW operations at the backend so that for the application it looks
like a usual board. Being implemented at the backend, the functionality is available
in all language bindings libmraa supports.
Board configuration
-------------------
This feature is yet in the experimental mode and not all functionality is available.
Right now we simulate a single generic board with:
* GPIO (without ISR)
* ADC with 10 (std)/12 (max) bit resolution, which returns random values on read
* Single I2C bus with one device at address 0x33 and 10 bytes of register space,
which can be read or written in bytes or words (big-endian). Technically those
registers are just an array of `uint8_t`, so you can treat them as 10 single-byte
registers or 5 single-word ones or a mix thereof.
We plan to develop it further and all [contributions](../CONTRIBUTING.md) are more than welcome.
See the table below for pin layout and features
| MRAA Number | Pin Name | Notes |
|-------------|----------|---------------------------------------|
| 0 | GPIO0 | GPIO pin, no muxing, no ISR |
| 1 | ADC0 | AIO pin, returns random value on read |
| 2 | I2C0SDA | SDA pin for I2C0 bus |
| 3 | I2C0SCL | SCL pin for I2C0 bus |
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
CMake options.
### Linux
To build under Linux, follow standard instructions, just make sure to set
the `-DBUILDARCH="MOCK"` CMake option.
### Windows
Mocking capability allows us to build and use libmraa under Windows. That helps
if you e.g. don't want to leave your customary Windows-based Python IDE, but
want to develop libmraa-based programs.
Building Node.js bindings was not yet tested under Windows as MSYS2
does not have a ready-made package. Java was not tested either.
#### Prerequisites
You'll need the following to build libmraa under Windows:
* [MSYS2](http://mingw-w64.org/doku.php/download/msys2) basic installation
* Several additional packages, install them by running
```bash
pacman -S cmake base-devel gcc git
```
#### Compiling
The procedure is conceptually the same as under Linux - you first need to run
CMake with specific options to generate makefiles and then run make to build everything.
* Run MSYS2 shell (not a MinGW one)
* Clone the libmraa git repo (let's assume into `/home/test/mraa/mraa-src` dir)
* Create a build directory outside of the clone one (let's say `/home/test/mraa/mraa-build`)
* Run CMake, switching off unsupported options and enabling mock platform:
```bash
cmake ../mraa-src/ -DBUILDARCH="MOCK" -DBUILDSWIGNODE=OFF -DENABLEEXAMPLES=OFF
```
* Make, install and test:
```bash
make clean && make install && make test
```
All tests should pass.
**Note:** To have autocompletion in Python IDE, just point it to MSYS2's Python
and make sure to specify any additional paths pointing to site-packages dir
with mraa module if IDE requires that ("Interpreter Paths" in PyCharm).
With the above settings the module will be installed into `/usr/local/lib/python2.7/site-packages`
and the libmraa itself - into `/usr/local/bin`.

View File

@@ -65,24 +65,13 @@ print_bus(mraa_board_t* board)
for (i = 0; i < board->i2c_bus_count; ++i) {
char* busType;
switch (board->platform_type) {
case MRAA_INTEL_GALILEO_GEN1:
case MRAA_INTEL_GALILEO_GEN2:
case MRAA_INTEL_EDISON_FAB_C:
case MRAA_INTEL_DE3815:
case MRAA_INTEL_MINNOWBOARD_MAX:
case MRAA_RASPBERRY_PI:
case MRAA_BEAGLEBONE:
case MRAA_BANANA:
case MRAA_UP:
bus = i;
busType = "linux";
break;
case MRAA_FTDI_FT4222:
busType = "ft4222";
bus = mraa_get_sub_platform_id(i);
break;
default:
busType = "unknown";
busType = "linux";
bus = i;
break;
}
int id = board->i2c_bus[i].bus_id;

View File

@@ -0,0 +1,73 @@
{
"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
}
],
"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 }
],
"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}
]
}

View File

@@ -26,7 +26,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>

View File

@@ -28,6 +28,8 @@ typedef struct {
typedef void (*__kernel_sighandler_t)(int);
typedef int __kernel_key_t;
typedef int __kernel_mqd_t;
#if !defined(MSYS)
#include <asm/posix_types.h>
#endif
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif

View File

@@ -0,0 +1,58 @@
/*
* This header was manually generated from a Linux kernel header
* linux/spi/spidev.h, to make information necessary for compilation
* to be available under MSYS. It contains only constants,
* structures, and macros generated from the original header, and thus,
* contains no copyrightable information.
*/
#ifndef _SPI_KERNEL_HEADERS_H
#define _SPI_KERNEL_HEADERS_H
#include <linux/types.h>
#define SPI_CPHA 0x01
#define SPI_CPOL 0x02
#define SPI_MODE_0 (0|0)
#define SPI_MODE_1 (0|SPI_CPHA)
#define SPI_MODE_2 (SPI_CPOL|0)
#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
#define SPI_IOC_MAGIC 'k'
struct spi_ioc_transfer {
__u64 tx_buf;
__u64 rx_buf;
__u32 len;
__u32 speed_hz;
__u16 delay_usecs;
__u8 bits_per_word;
__u8 cs_change;
__u8 tx_nbits;
__u8 rx_nbits;
__u16 pad;
};
#define SPI_MSGSIZE(N) \
((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \
? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
#define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, __u8)
#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, __u8)
#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, __u8)
#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, __u8)
#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, __u8)
#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, __u8)
#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, __u32)
#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, __u32)
#define SPI_IOC_RD_MODE32 _IOR(SPI_IOC_MAGIC, 5, __u32)
#define SPI_IOC_WR_MODE32 _IOW(SPI_IOC_MAGIC, 5, __u32)
#endif

40
include/mock/mock_board.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "mraa_internal.h"
#define MRAA_MOCK_PINCOUNT 4
mraa_board_t*
mraa_mock_board();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,44 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "mraa_internal.h"
mraa_result_t
mraa_mock_aio_init_internal_replace(mraa_aio_context dev, int pin);
mraa_result_t
mraa_mock_aio_close_replace(mraa_aio_context dev);
int
mraa_mock_aio_read_replace(mraa_aio_context dev);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,65 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "mraa_internal.h"
mraa_result_t
mraa_mock_gpio_init_internal_replace(mraa_gpio_context dev, int pin);
mraa_result_t
mraa_mock_gpio_close_replace(mraa_gpio_context dev);
mraa_result_t
mraa_mock_gpio_dir_replace(mraa_gpio_context dev, mraa_gpio_dir_t dir);
mraa_result_t
mraa_mock_gpio_read_dir_replace(mraa_gpio_context dev, mraa_gpio_dir_t* dir);
int
mraa_mock_gpio_read_replace(mraa_gpio_context dev);
mraa_result_t
mraa_mock_gpio_write_replace(mraa_gpio_context dev, int value);
mraa_result_t
mraa_mock_gpio_edge_mode_replace(mraa_gpio_context dev, mraa_gpio_edge_t mode);
mraa_result_t
mraa_mock_gpio_isr_replace(mraa_gpio_context dev, mraa_gpio_edge_t mode, void (*fptr)(void*), void* args);
mraa_result_t
mraa_mock_gpio_isr_exit_replace(mraa_gpio_context dev);
mraa_result_t
mraa_mock_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_t mode);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,81 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "mraa_internal.h"
// Mock I2C device address
#define MOCK_I2C_DEV_ADDR 0x33
// Mock I2C device data registers block length in bytes. Our code assumes it's >= 1.
#define MOCK_I2C_DEV_DATA_LEN 10
// Initial value for each byte in the mock I2C device data registers
#define MOCK_I2C_DEV_DATA_INIT_BYTE 0xAB
mraa_result_t
mraa_mock_i2c_init_bus_replace(mraa_i2c_context dev);
mraa_result_t
mraa_mock_i2c_stop_replace(mraa_i2c_context dev);
mraa_result_t
mraa_mock_i2c_set_frequency_replace(mraa_i2c_context dev, mraa_i2c_mode_t mode);
mraa_result_t
mraa_mock_i2c_address_replace(mraa_i2c_context dev, uint8_t addr);
int
mraa_mock_i2c_read_replace(mraa_i2c_context dev, uint8_t* data, int length);
int
mraa_mock_i2c_read_byte_replace(mraa_i2c_context dev);
int
mraa_mock_i2c_read_byte_data_replace(mraa_i2c_context dev, uint8_t command);
int
mraa_mock_i2c_read_bytes_data_replace(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length);
int
mraa_mock_i2c_read_word_data_replace(mraa_i2c_context dev, uint8_t command);
mraa_result_t
mraa_mock_i2c_write_replace(mraa_i2c_context dev, const uint8_t* data, int length);
mraa_result_t
mraa_mock_i2c_write_byte_replace(mraa_i2c_context dev, const uint8_t data);
mraa_result_t
mraa_mock_i2c_write_byte_data_replace(mraa_i2c_context dev, const uint8_t data, const uint8_t command);
mraa_result_t
mraa_mock_i2c_write_word_data_replace(mraa_i2c_context dev, const uint16_t data, const uint8_t command);
#ifdef __cplusplus
}
#endif

View File

@@ -48,6 +48,7 @@ typedef struct {
mraa_result_t (*gpio_dir_replace) (mraa_gpio_context dev, mraa_gpio_dir_t dir);
mraa_result_t (*gpio_dir_pre) (mraa_gpio_context dev, mraa_gpio_dir_t dir);
mraa_result_t (*gpio_dir_post) (mraa_gpio_context dev, mraa_gpio_dir_t dir);
mraa_result_t (*gpio_read_dir_replace) (mraa_gpio_context dev, mraa_gpio_dir_t *dir);
int (*gpio_read_replace) (mraa_gpio_context dev);
mraa_result_t (*gpio_write_replace) (mraa_gpio_context dev, int value);
@@ -56,6 +57,8 @@ typedef struct {
mraa_result_t (*gpio_mmap_setup) (mraa_gpio_context dev, mraa_boolean_t en);
mraa_result_t (*gpio_interrupt_handler_init_replace) (mraa_gpio_context dev);
mraa_result_t (*gpio_wait_interrupt_replace) (mraa_gpio_context dev);
mraa_result_t (*gpio_isr_replace) (mraa_gpio_context dev, mraa_gpio_edge_t mode, void (*fptr)(void*), void* args);
mraa_result_t (*gpio_isr_exit_replace) (mraa_gpio_context dev);
mraa_result_t (*i2c_init_pre) (unsigned int bus);
mraa_result_t (*i2c_init_bus_replace) (mraa_i2c_context dev);
@@ -75,6 +78,7 @@ typedef struct {
mraa_result_t (*i2c_stop_replace) (mraa_i2c_context dev);
mraa_result_t (*aio_init_internal_replace) (mraa_aio_context dev, int pin);
mraa_result_t (*aio_close_replace) (mraa_aio_context dev);
int (*aio_read_replace) (mraa_aio_context dev);
mraa_result_t (*aio_get_valid_fp) (mraa_aio_context dev);
mraa_result_t (*aio_init_pre) (unsigned int aio);

View File

@@ -37,6 +37,7 @@ extern "C" {
#include "mraa_lang_func.h"
extern mraa_board_t* plat;
extern char* platform_name;
extern mraa_iio_info_t* plat_iio;
extern mraa_lang_func_t* lang_func;
@@ -62,6 +63,13 @@ mraa_platform_t mraa_x86_platform();
*/
mraa_platform_t mraa_arm_platform();
/**
* setup a mock platform
*
* @return mraa_platform_t of the init'ed platform
*/
mraa_platform_t mraa_mock_platform();
/**
* runtime detect running usb platform extender
*

View File

@@ -40,6 +40,46 @@
#define MRAA_IO_SETUP_FAILURE -2
#define MRAA_NO_SUCH_IO -1
// Json platform keys
#define INDEX_KEY "index"
#define NAME_KEY "name"
#define PIN_COUNT_KEY "pin_count"
#define GPIO_COUNT_KEY "gpio_count"
#define AIO_COUNT_KEY "aio_count"
#define SPI_COUNT_KEY "spi_count"
#define I2C_COUNT_KEY "i2c_count"
#define UART_COUNT_KEY "uart_count"
#define PWMDEFAULT_KEY "pwmDefPeriod"
#define PWMMAX_KEY "pwmMaxPeriod"
#define PWMMIN_KEY "pwmMinPeriod"
#define LABEL_KEY "label"
#define DEFAULT_KEY "default"
#define INVALID_KEY "invalid"
#define SCLPIN_KEY "sclpin"
#define SDAPIN_KEY "sdapin"
#define CHIP_ID_KEY "chipID"
#define RAW_PIN_KEY "rawpin"
#define RXPIN_KEY "rx"
#define TXPIN_KEY "tx"
#define UART_PATH_KEY "path"
#define CLOCK_KEY "clock"
#define MISO_KEY "miso"
#define MOSI_KEY "mosi"
#define CS_KEY "chipselect"
#define PIN_KEY "pin"
#define IO_KEY "layout"
#define PLATFORM_KEY "platform"
// IO keys
#define GPIO_KEY "GPIO"
#define SPI_KEY "SPI"
#define UART_KEY "UART"
#define I2C_KEY "I2C"
#define PWM_KEY "PWM"
#define AIO_KEY "AIO"
#define MRAA_JSONPLAT_ENV_VAR "MRAA_JSON_PLATFORM"
#ifdef FIRMATA
struct _firmata {
/*@*/
@@ -71,6 +111,10 @@ struct _gpio {
mraa_result_t (*mmap_write) (mraa_gpio_context dev, int value);
int (*mmap_read) (mraa_gpio_context dev);
mraa_adv_func_t* advance_func; /**< override function table */
#if defined(MOCKPLAT)
mraa_gpio_dir_t mock_dir; /**< mock direction of the pin */
int mock_state; /**< mock state of the pin */
#endif
/*@}*/
};
@@ -85,6 +129,11 @@ struct _i2c {
unsigned long funcs; /**< /dev/i2c-* device capabilities as per https://www.kernel.org/doc/Documentation/i2c/functionality */
void *handle; /**< generic handle for non-standard drivers that don't use file descriptors */
mraa_adv_func_t* advance_func; /**< override function table */
#if defined(MOCKPLAT)
uint8_t mock_dev_addr; /**< address of the mock I2C device */
uint8_t mock_dev_data_len; /**< mock device data register block length in bytes */
uint8_t* mock_dev_data; /**< mock device data register block contents */
#endif
/*@}*/
};
@@ -213,7 +262,7 @@ typedef struct {
typedef struct {
/*@{*/
unsigned int pinmap; /**< sysfs pin */
int pinmap; /**< sysfs pin */
unsigned int parent_id; /** parent chip id */
unsigned int mux_total; /** Numfer of muxes needed for operation of pin */
mraa_mux_t mux[6]; /** Array holding information about mux */
@@ -237,7 +286,7 @@ typedef struct {
typedef struct {
/*@{*/
char name[MRAA_PIN_NAME_SIZE]; /**< Pin's real world name */
mraa_pincapabilities_t capabilites; /**< Pin Capabiliites */
mraa_pincapabilities_t capabilities; /**< Pin Capabiliites */
mraa_pin_t gpio; /**< GPIO structure */
mraa_pin_t pwm; /**< PWM structure */
mraa_pin_t aio; /**< Anaglog Pin */
@@ -283,7 +332,7 @@ typedef struct {
unsigned int index; /**< ID as exposed in the system */
int rx; /**< uart rx */
int tx; /**< uart tx */
const char* device_path; /**< To store "/dev/ttyS1" for example */
char* device_path; /**< To store "/dev/ttyS1" for example */
/*@}*/
} mraa_uart_dev_t;
@@ -294,8 +343,8 @@ typedef struct {
typedef struct _board_t {
/*@{*/
int phy_pin_count; /**< The Total IO pins on board */
unsigned int gpio_count; /**< GPIO Count */
unsigned int aio_count; /**< Analog side Count */
int gpio_count; /**< GPIO Count */
int aio_count; /**< Analog side Count */
int i2c_bus_count; /**< Usable i2c Count */
mraa_i2c_bus_t i2c_bus[12]; /**< Array of i2c */
unsigned int def_i2c_bus; /**< Position in array of default i2c bus */
@@ -312,7 +361,7 @@ typedef struct _board_t {
int pwm_max_period; /**< Maximum period in us */
int pwm_min_period; /**< Minimum period in us */
mraa_platform_t platform_type; /**< Platform type */
const char* platform_name; /**< Platform Name pointer */
char* platform_name; /**< Platform Name pointer */
const char* platform_version; /**< Platform versioning info */
mraa_pininfo_t* pins; /**< Pointer to pin array */
mraa_adv_func_t* adv_func; /**< Pointer to advanced function disptach table */

View File

@@ -84,8 +84,27 @@ set (mraa_LIB_ARM_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/arm/banana.c
)
set (mraa_LIB_MOCK_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/mock/mock.c
${PROJECT_SOURCE_DIR}/src/mock/mock_board.c
${PROJECT_SOURCE_DIR}/src/mock/mock_board_gpio.c
${PROJECT_SOURCE_DIR}/src/mock/mock_board_aio.c
${PROJECT_SOURCE_DIR}/src/mock/mock_board_i2c.c
)
if (JSONPLAT)
find_package (JSON-C QUIET)
if (${JSON-C_FOUND})
set (mraa_LIB_SRCS_NOAUTO
${mraa_LIB_SRCS_NOAUTO}
${PROJECT_SOURCE_DIR}/src/json/jsonplatform.c
)
endif ()
endif ()
set (mraa_LIBS ${CMAKE_THREAD_LIBS_INIT})
if (X86PLAT)
add_subdirectory(x86)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DX86PLAT=1")
@@ -96,6 +115,14 @@ if (ARMPLAT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARMPLAT=1")
endif()
if (MOCKPLAT)
add_subdirectory(mock)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMOCKPLAT=1")
if (MSYS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMSYS=1")
endif ()
endif()
if (USBPLAT)
message (STATUS "INFO - Adding USB platforms")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSBPLAT=1")
@@ -120,11 +147,24 @@ if (USBPLAT)
add_subdirectory(usb)
endif ()
if (IMRAA)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
find_package (JSON-C REQUIRED)
include_directories (${JSON-C_INCLUDE_DIR})
set (mraa_LIBS ${mraa_LIBS} ${JSON-C_LIBRARIES})
if (JSONPLAT OR IMRAA)
find_package (JSON-C QUIET)
if (NOT ${JSON-C_FOUND})
if (IMRAA)
message (FATAL_ERROR "Enabled IMRAA but JSON-C library not found")
elseif (JSONPLAT)
message (WARNING "Enabled JSONPLAT but JSON-C library not found: Ignoring JSONPLAT")
endif ()
else ()
if (JSONPLAT)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DJSONPLAT=1")
endif ()
if (IMRAA)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIMRAA=1")
endif ()
include_directories (${JSON-C_INCLUDE_DIR})
set (mraa_LIBS ${mraa_LIBS} ${JSON-C_LIBRARIES})
endif ()
endif ()
set (mraa_LIB_SRCS
@@ -218,4 +258,9 @@ set_target_properties(
SOVERSION ${mraa_VERSION_MAJOR}
VERSION ${mraa_VERSION_STRING}
)
install(TARGETS mraa DESTINATION ${LIB_INSTALL_DIR})
if (MSYS)
# Under MSYS we have to put our generated DLL into bin, otherwise it's not picked up
install(TARGETS mraa DESTINATION ${CMAKE_INSTALL_BINDIR})
else ()
install(TARGETS mraa DESTINATION ${LIB_INSTALL_DIR})
endif ()

View File

@@ -113,7 +113,7 @@ mraa_aio_init(unsigned int aio)
syslog(LOG_ERR, "aio: requested channel out of range");
return NULL;
}
if (board->pins[pin].capabilites.aio != 1) {
if (board->pins[pin].capabilities.aio != 1) {
syslog(LOG_ERR, "aio: pin %i not capable of aio", pin);
return NULL;
}
@@ -156,6 +156,11 @@ mraa_aio_init(unsigned int aio)
int
mraa_aio_read(mraa_aio_context dev)
{
if (dev == NULL) {
syslog(LOG_ERR, "aio: read: context is invalid");
return -1;
}
if (IS_FUNC_DEFINED(dev, aio_read_replace)) {
return dev->advance_func->aio_read_replace(dev);
}
@@ -220,13 +225,22 @@ mraa_aio_read_float(mraa_aio_context dev)
mraa_result_t
mraa_aio_close(mraa_aio_context dev)
{
if (NULL != dev) {
if (dev->adc_in_fp != -1)
close(dev->adc_in_fp);
free(dev);
if (dev == NULL) {
syslog(LOG_ERR, "aio: close: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
return (MRAA_SUCCESS);
if (IS_FUNC_DEFINED(dev, aio_close_replace)) {
return dev->advance_func->aio_close_replace(dev);
}
if (dev->adc_in_fp != -1) {
close(dev->adc_in_fp);
}
free(dev);
return MRAA_SUCCESS;
}
mraa_result_t

View File

@@ -63,9 +63,9 @@ void mraa_96boards_pininfo(mraa_board_t* board, int index, int sysfs_pin,
vsnprintf(pininfo->name, MRAA_PIN_NAME_SIZE, fmt, arg_ptr);
va_end(arg_ptr);
if (sysfs_pin >= 0)
pininfo->capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
pininfo->capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
else
pininfo->capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
pininfo->capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
pininfo->gpio.pinmap = sysfs_pin;
pininfo->gpio.mux_total = 0;
}

View File

@@ -305,37 +305,37 @@ mraa_banana()
b->adv_func->gpio_mmap_setup = &mraa_banana_mmap_setup;
strncpy(b->pins[0].name, "INVALID", MRAA_PIN_NAME_SIZE);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "3V3", MRAA_PIN_NAME_SIZE);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
if (i2c2 == 1) {
strncpy(b->pins[3].name, "TWI2-SDA", MRAA_PIN_NAME_SIZE); // PB21 Pin53 TWI2-SDA
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
} else {
strncpy(b->pins[3].name, "PB21", MRAA_PIN_NAME_SIZE); // PB21 Pin53 TWI2-SDA
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[3].gpio.pinmap = 53;
strncpy(b->pins[4].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
if (i2c2 == 1) {
strncpy(b->pins[5].name, "TWI2-SCK", MRAA_PIN_NAME_SIZE); // PB20 Pin52 TWI2-SCK
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
} else {
strncpy(b->pins[5].name, "PB20", MRAA_PIN_NAME_SIZE); // PB20 Pin52 TWI2-SCK
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[5].gpio.pinmap = 52;
strncpy(b->pins[6].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
if (platform_detected == PLATFORM_BANANA_PRO) {
strncpy(b->pins[7].name, "PH02", MRAA_PIN_NAME_SIZE); // PH2 Pin226
@@ -344,7 +344,7 @@ mraa_banana()
strncpy(b->pins[7].name, "PI03", MRAA_PIN_NAME_SIZE); // PI3 Pin259 PWM
b->pins[7].gpio.pinmap = 259;
}
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
if (platform_detected == PLATFORM_BANANA_PRO) {
strncpy(b->pins[8].name, "UART4_TX", MRAA_PIN_NAME_SIZE); // PH4 Pin228 UART4_TX
@@ -353,10 +353,10 @@ mraa_banana()
strncpy(b->pins[8].name, "UART3_TX", MRAA_PIN_NAME_SIZE); // PH0 Pin224 UART3_TX
b->pins[8].gpio.pinmap = 224;
}
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
strncpy(b->pins[9].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
if (platform_detected == PLATFORM_BANANA_PRO) {
strncpy(b->pins[10].name, "UART4_RX", MRAA_PIN_NAME_SIZE); // PH5 Pin229 UART4_RX
@@ -365,10 +365,10 @@ mraa_banana()
strncpy(b->pins[10].name, "UART3_RX", MRAA_PIN_NAME_SIZE); // PH1 Pin225 UART3_RX
b->pins[10].gpio.pinmap = 225;
}
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
strncpy(b->pins[11].name, "PI19", MRAA_PIN_NAME_SIZE); // PI19 Pin275 IO+UART2_RX
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[11].gpio.pinmap = 275;
if (platform_detected == PLATFORM_BANANA_PRO) {
@@ -378,143 +378,143 @@ mraa_banana()
strncpy(b->pins[12].name, "PH02", MRAA_PIN_NAME_SIZE); // PH2 Pin226
b->pins[12].gpio.pinmap = 226;
}
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
strncpy(b->pins[13].name, "PI18", MRAA_PIN_NAME_SIZE); // PI18 Pin274 UART2_TX
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[13].gpio.pinmap = 274;
strncpy(b->pins[14].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[15].name, "PI17", MRAA_PIN_NAME_SIZE); // PI17 Pin273 UART2_CTS
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].gpio.pinmap = 273;
strncpy(b->pins[16].name, "PH20", MRAA_PIN_NAME_SIZE); // PH20 Pin 244 CAN_TX
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].gpio.pinmap = 244;
strncpy(b->pins[17].name, "3V3", MRAA_PIN_NAME_SIZE);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[18].name, "PH21", MRAA_PIN_NAME_SIZE); // PH21 Pin245 CAN_RX
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].gpio.pinmap = 245;
strncpy(b->pins[19].name, "SPI0MOSI", MRAA_PIN_NAME_SIZE); // PI12 SPI0
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[19].gpio.pinmap = 268;
strncpy(b->pins[20].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[20].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[21].name, "SPI0MISO", MRAA_PIN_NAME_SIZE); // PI13 SPI0
b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[21].gpio.pinmap = 269;
strncpy(b->pins[22].name, "PI16", MRAA_PIN_NAME_SIZE); // PI16 UART2_RTS
b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[22].gpio.pinmap = 272;
strncpy(b->pins[23].name, "SPI0CLK", MRAA_PIN_NAME_SIZE); // PI11 SPI0
b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[23].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[23].gpio.pinmap = 267;
strncpy(b->pins[24].name, "SPI0CS0", MRAA_PIN_NAME_SIZE); // PI10 SPI0
b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[24].gpio.pinmap = 266;
strncpy(b->pins[25].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[25].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[26].name, "SPI0CS1", MRAA_PIN_NAME_SIZE); // PI14 SPI0
b->pins[26].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[26].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[26].gpio.pinmap = 270;
if (platform_detected == PLATFORM_BANANA_PI) {
strncpy(b->pins[27].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[28].name, "3V3", MRAA_PIN_NAME_SIZE);
b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[29].name, "PH05", MRAA_PIN_NAME_SIZE); // PH5
b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].gpio.pinmap = 229;
strncpy(b->pins[30].name, "PI21", MRAA_PIN_NAME_SIZE); // PI21 UART7_RX
b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[30].gpio.pinmap = 277;
strncpy(b->pins[31].name, "PH03", MRAA_PIN_NAME_SIZE); // PH3
b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].gpio.pinmap = 227;
strncpy(b->pins[32].name, "PI20", MRAA_PIN_NAME_SIZE); // PI20 UART7_TX
b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[32].gpio.pinmap = 276;
strncpy(b->pins[33].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
if (platform_detected == PLATFORM_BANANA_PRO) {
strncpy(b->pins[27].name, "HAT_SDA", MRAA_PIN_NAME_SIZE); // PI1 TWI3-SDA i2c3
b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[27].gpio.pinmap = 257;
strncpy(b->pins[28].name, "HAT_SCK", MRAA_PIN_NAME_SIZE); // PI0 TWI3-SCK i2c3
b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[28].gpio.pinmap = 256;
strncpy(b->pins[29].name, "PB03", MRAA_PIN_NAME_SIZE); // PB3 IR0_TX/SPDIF_MCLK
b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].gpio.pinmap = 35;
strncpy(b->pins[30].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[31].name, "PI21", MRAA_PIN_NAME_SIZE); // PI21 UART7_RX
b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[31].gpio.pinmap = 277;
strncpy(b->pins[32].name, "PI20", MRAA_PIN_NAME_SIZE); // PI20 UART7_TX
b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[32].gpio.pinmap = 276;
strncpy(b->pins[33].name, "PB13", MRAA_PIN_NAME_SIZE); // PB13 SPDIF_D0
b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[33].gpio.pinmap = 45;
strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[35].name, "PB07", MRAA_PIN_NAME_SIZE); // PB07 I2S0_LRCK
b->pins[35].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[35].gpio.pinmap = 39;
strncpy(b->pins[36].name, "PB06", MRAA_PIN_NAME_SIZE); // PB06 I2S0BCLK
b->pins[36].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[36].gpio.pinmap = 38;
strncpy(b->pins[37].name, "PB05", MRAA_PIN_NAME_SIZE); // PB05 I2S0MCK
b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[37].gpio.pinmap = 37;
strncpy(b->pins[38].name, "PB12", MRAA_PIN_NAME_SIZE); // PB12 I2S0_DI
b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[38].gpio.pinmap = 44;
strncpy(b->pins[39].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[39].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[39].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[40].name, "PB08", MRAA_PIN_NAME_SIZE); // PB08 I2S0_DO0
b->pins[40].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[40].gpio.pinmap = 40;
}
@@ -528,7 +528,7 @@ mraa_banana()
b->gpio_count = 0;
int i;
for (i = 0; i < b->phy_pin_count; i++) {
if (b->pins[i].capabilites.gpio) {
if (b->pins[i].capabilities.gpio) {
b->gpio_count++;
}
}

View File

@@ -312,7 +312,7 @@ mraa_beaglebone_pwm_init_replace(int pin)
syslog(LOG_ERR, "pwm: Platform Not Initialised");
return NULL;
}
if (plat->pins[pin].capabilites.pwm != 1) {
if (plat->pins[pin].capabilities.pwm != 1) {
syslog(LOG_ERR, "pwm: pin not capable of pwm");
return NULL;
}
@@ -525,20 +525,20 @@ mraa_beaglebone()
b->adv_func->pwm_init_replace = &mraa_beaglebone_pwm_init_replace;
strncpy(b->pins[0].name, "INVALID", MRAA_PIN_NAME_SIZE);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
if (emmc_enabled == 1) {
strncpy(b->pins[3].name, "MMC1_D6", MRAA_PIN_NAME_SIZE);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[3].name, "GPIO38", MRAA_PIN_NAME_SIZE);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[3].gpio.pinmap = 38;
b->pins[3].gpio.parent_id = 0;
@@ -546,10 +546,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[4].name, "MMC1_D7", MRAA_PIN_NAME_SIZE);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[4].name, "GPIO39", MRAA_PIN_NAME_SIZE);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[4].gpio.pinmap = 39;
b->pins[4].gpio.parent_id = 0;
@@ -557,10 +557,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[5].name, "MMC1_D2", MRAA_PIN_NAME_SIZE);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[5].name, "GPIO34", MRAA_PIN_NAME_SIZE);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[5].gpio.pinmap = 34;
b->pins[5].gpio.parent_id = 0;
@@ -568,10 +568,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[6].name, "MMC1_D3", MRAA_PIN_NAME_SIZE);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[6].name, "GPIO35", MRAA_PIN_NAME_SIZE);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[6].gpio.pinmap = 35;
b->pins[6].gpio.parent_id = 0;
@@ -579,50 +579,50 @@ mraa_beaglebone()
// TODO TIMER4
strncpy(b->pins[7].name, "GPIO66", MRAA_PIN_NAME_SIZE);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 66;
b->pins[7].gpio.parent_id = 0;
b->pins[7].gpio.mux_total = 0;
// TODO TIMER7
strncpy(b->pins[8].name, "GPIO67", MRAA_PIN_NAME_SIZE);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 67;
b->pins[8].gpio.parent_id = 0;
b->pins[8].gpio.mux_total = 0;
// TODO TIMER5
strncpy(b->pins[9].name, "GPIO69", MRAA_PIN_NAME_SIZE);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 69;
b->pins[9].gpio.parent_id = 0;
b->pins[9].gpio.mux_total = 0;
// TODO TIMER6
strncpy(b->pins[10].name, "GPIO68", MRAA_PIN_NAME_SIZE);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[10].gpio.pinmap = 68;
b->pins[10].gpio.parent_id = 0;
b->pins[10].gpio.mux_total = 0;
strncpy(b->pins[11].name, "GPIO45", MRAA_PIN_NAME_SIZE);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].gpio.pinmap = 45;
b->pins[11].gpio.parent_id = 0;
b->pins[11].gpio.mux_total = 0;
strncpy(b->pins[12].name, "GPIO44", MRAA_PIN_NAME_SIZE);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].gpio.pinmap = 44;
b->pins[12].gpio.parent_id = 0;
b->pins[12].gpio.mux_total = 0;
if (ehrpwm2b_enabled == 1) {
strncpy(b->pins[13].name, "EHRPWM2B", MRAA_PIN_NAME_SIZE);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[13].name, "GPIO23", MRAA_PIN_NAME_SIZE);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[13].gpio.pinmap = 23;
b->pins[13].gpio.parent_id = 0;
@@ -631,42 +631,42 @@ mraa_beaglebone()
b->pins[13].pwm.mux_total = 0;
strncpy(b->pins[14].name, "GPIO26", MRAA_PIN_NAME_SIZE);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[14].gpio.pinmap = 26;
b->pins[14].gpio.parent_id = 0;
b->pins[14].gpio.mux_total = 0;
strncpy(b->pins[15].name, "GPIO47", MRAA_PIN_NAME_SIZE);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].gpio.pinmap = 47;
b->pins[15].gpio.parent_id = 0;
b->pins[15].gpio.mux_total = 0;
strncpy(b->pins[16].name, "GPIO46", MRAA_PIN_NAME_SIZE);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].gpio.pinmap = 46;
b->pins[16].gpio.parent_id = 0;
b->pins[16].gpio.mux_total = 0;
// TODO PWM0_SYNCO
strncpy(b->pins[17].name, "GPIO27", MRAA_PIN_NAME_SIZE);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[17].gpio.pinmap = 27;
b->pins[17].gpio.parent_id = 0;
b->pins[17].gpio.mux_total = 0;
strncpy(b->pins[18].name, "GPIO65", MRAA_PIN_NAME_SIZE);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].gpio.pinmap = 65;
b->pins[18].gpio.parent_id = 0;
b->pins[18].gpio.mux_total = 0;
if (ehrpwm2a_enabled == 1) {
strncpy(b->pins[19].name, "EHRPWM2A", MRAA_PIN_NAME_SIZE);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[19].name, "GPIO22", MRAA_PIN_NAME_SIZE);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[19].gpio.pinmap = 22;
b->pins[19].gpio.parent_id = 0;
@@ -676,10 +676,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[20].name, "MMC1_CMD", MRAA_PIN_NAME_SIZE);
b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[20].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[20].name, "GPIO63", MRAA_PIN_NAME_SIZE);
b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[20].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[20].gpio.pinmap = 63;
b->pins[20].gpio.parent_id = 0;
@@ -687,10 +687,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[21].name, "MMC1_CLK", MRAA_PIN_NAME_SIZE);
b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[21].name, "GPIO62", MRAA_PIN_NAME_SIZE);
b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[21].gpio.pinmap = 62;
b->pins[21].gpio.parent_id = 0;
@@ -698,10 +698,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[22].name, "MMC1_D5", MRAA_PIN_NAME_SIZE);
b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[22].name, "GPIO37", MRAA_PIN_NAME_SIZE);
b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[22].gpio.pinmap = 37;
b->pins[22].gpio.parent_id = 0;
@@ -709,10 +709,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[23].name, "MMC_D4", MRAA_PIN_NAME_SIZE);
b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[23].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[23].name, "GPIO36", MRAA_PIN_NAME_SIZE);
b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[23].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[23].gpio.pinmap = 36;
b->pins[23].gpio.parent_id = 0;
@@ -720,10 +720,10 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[24].name, "MMC_D1", MRAA_PIN_NAME_SIZE);
b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[24].name, "GPIO33", MRAA_PIN_NAME_SIZE);
b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[24].gpio.pinmap = 33;
b->pins[24].gpio.parent_id = 0;
@@ -731,27 +731,27 @@ mraa_beaglebone()
if (emmc_enabled == 1) {
strncpy(b->pins[25].name, "MMC1_D0", MRAA_PIN_NAME_SIZE);
b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[25].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[25].name, "GPIO32", MRAA_PIN_NAME_SIZE);
b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[25].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[25].gpio.pinmap = 32;
b->pins[25].gpio.parent_id = 0;
b->pins[25].gpio.mux_total = 0;
strncpy(b->pins[26].name, "GPIO61", MRAA_PIN_NAME_SIZE);
b->pins[26].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[26].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[26].gpio.pinmap = 61;
b->pins[26].gpio.parent_id = 0;
b->pins[26].gpio.mux_total = 0;
if (hdmi_enabled == 1) {
strncpy(b->pins[27].name, "LCD_VSYNC", MRAA_PIN_NAME_SIZE);
b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[27].name, "GPIO86", MRAA_PIN_NAME_SIZE);
b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[27].gpio.pinmap = 86;
b->pins[27].gpio.parent_id = 0;
@@ -759,10 +759,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[28].name, "LCD_PCLK", MRAA_PIN_NAME_SIZE);
b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[28].name, "GPIO88", MRAA_PIN_NAME_SIZE);
b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[28].gpio.pinmap = 88;
b->pins[28].gpio.parent_id = 0;
@@ -770,10 +770,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[29].name, "LCD_HSYNC", MRAA_PIN_NAME_SIZE);
b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[29].name, "GPIO87", MRAA_PIN_NAME_SIZE);
b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[29].gpio.pinmap = 87;
b->pins[29].gpio.parent_id = 0;
@@ -781,10 +781,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[30].name, "LCD_AC_BIAS", MRAA_PIN_NAME_SIZE);
b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[30].name, "GPIO89", MRAA_PIN_NAME_SIZE);
b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[30].gpio.pinmap = 89;
b->pins[30].gpio.parent_id = 0;
@@ -792,11 +792,11 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[31].name, "LCD_D14", MRAA_PIN_NAME_SIZE);
b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
// TODO UART5_CTS this is ignored when using ADAFRUIT
strncpy(b->pins[31].name, "GPIO10", MRAA_PIN_NAME_SIZE);
b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[31].gpio.pinmap = 10;
b->pins[31].gpio.parent_id = 0;
@@ -805,11 +805,11 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[32].name, "LCD_D15", MRAA_PIN_NAME_SIZE);
b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
// TODO UART5_RTS this is ignored when using ADAFRUIT
strncpy(b->pins[32].name, "GPIO11", MRAA_PIN_NAME_SIZE);
b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[32].gpio.pinmap = 11;
b->pins[32].gpio.parent_id = 0;
@@ -818,11 +818,11 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[33].name, "LCD_D13", MRAA_PIN_NAME_SIZE);
b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
// TODO UART4_RTS this is ignored when using ADAFRUIT
strncpy(b->pins[33].name, "GPIO9", MRAA_PIN_NAME_SIZE);
b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[33].gpio.pinmap = 9;
b->pins[33].gpio.parent_id = 0;
@@ -832,10 +832,10 @@ mraa_beaglebone()
// TODO PWM_1B
if (hdmi_enabled == 1) {
strncpy(b->pins[34].name, "LCD_D11", MRAA_PIN_NAME_SIZE);
b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[34].name, "GPIO81", MRAA_PIN_NAME_SIZE);
b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[34].gpio.pinmap = 81;
b->pins[34].gpio.parent_id = 0;
@@ -843,11 +843,11 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[35].name, "LCD_D12", MRAA_PIN_NAME_SIZE);
b->pins[35].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
// TODO UART4_CTS this is ignored when using ADAFRUIT
strncpy(b->pins[35].name, "GPIO8", MRAA_PIN_NAME_SIZE);
b->pins[35].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[35].gpio.pinmap = 8;
b->pins[35].gpio.parent_id = 0;
@@ -857,10 +857,10 @@ mraa_beaglebone()
// TODO PWM_1A
if (hdmi_enabled == 1) {
strncpy(b->pins[36].name, "LCD_D10", MRAA_PIN_NAME_SIZE);
b->pins[36].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[36].name, "GPIO80", MRAA_PIN_NAME_SIZE);
b->pins[36].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[36].gpio.pinmap = 80;
b->pins[36].gpio.parent_id = 0;
@@ -868,17 +868,17 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[37].name, "LCD_D8", MRAA_PIN_NAME_SIZE);
b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
if (uart5_enabled == 1) {
strncpy(b->pins[37].name, "UART5TX", MRAA_PIN_NAME_SIZE);
b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
} else {
strncpy(b->pins[37].name, "GPIO78", MRAA_PIN_NAME_SIZE);
b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
}
}
b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[37].gpio.pinmap = 78;
b->pins[37].gpio.parent_id = 0;
b->pins[37].gpio.mux_total = 0;
@@ -886,15 +886,15 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[38].name, "LCD_D9", MRAA_PIN_NAME_SIZE);
b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
// TODO UART5_RX
if (uart5_enabled == 1) {
strncpy(b->pins[38].name, "UART5RX", MRAA_PIN_NAME_SIZE);
b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
} else {
strncpy(b->pins[38].name, "GPIO79", MRAA_PIN_NAME_SIZE);
b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
}
}
b->pins[38].gpio.pinmap = 79;
@@ -904,10 +904,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[39].name, "LCD_D6", MRAA_PIN_NAME_SIZE);
b->pins[39].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[39].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[39].name, "GPIO76", MRAA_PIN_NAME_SIZE);
b->pins[39].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[39].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[39].gpio.pinmap = 76;
b->pins[39].gpio.parent_id = 0;
@@ -915,10 +915,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[40].name, "LCD_D7", MRAA_PIN_NAME_SIZE);
b->pins[40].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[40].name, "GPIO77", MRAA_PIN_NAME_SIZE);
b->pins[40].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[40].gpio.pinmap = 77;
b->pins[40].gpio.parent_id = 0;
@@ -926,10 +926,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[41].name, "LCD_D4", MRAA_PIN_NAME_SIZE);
b->pins[41].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[41].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[41].name, "GPIO74", MRAA_PIN_NAME_SIZE);
b->pins[41].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[41].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[41].gpio.pinmap = 74;
b->pins[41].gpio.parent_id = 0;
@@ -937,10 +937,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[42].name, "LCD_D5", MRAA_PIN_NAME_SIZE);
b->pins[42].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[42].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[42].name, "GPIO75", MRAA_PIN_NAME_SIZE);
b->pins[42].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[42].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[42].gpio.pinmap = 75;
b->pins[42].gpio.parent_id = 0;
@@ -948,10 +948,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[43].name, "LCD_D2", MRAA_PIN_NAME_SIZE);
b->pins[43].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[43].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[43].name, "GPIO72", MRAA_PIN_NAME_SIZE);
b->pins[43].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[43].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[43].gpio.pinmap = 72;
b->pins[43].gpio.parent_id = 0;
@@ -959,10 +959,10 @@ mraa_beaglebone()
if (hdmi_enabled == 1) {
strncpy(b->pins[44].name, "LCD_D3", MRAA_PIN_NAME_SIZE);
b->pins[44].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[44].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[44].name, "GPIO73", MRAA_PIN_NAME_SIZE);
b->pins[44].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[44].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
}
b->pins[44].gpio.pinmap = 73;
b->pins[44].gpio.parent_id = 0;
@@ -971,10 +971,10 @@ mraa_beaglebone()
// TODO PWM_2A
if (hdmi_enabled == 1) {
strncpy(b->pins[45].name, "LCD_D0", MRAA_PIN_NAME_SIZE);
b->pins[45].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[45].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[45].name, "GPIO70", MRAA_PIN_NAME_SIZE);
b->pins[45].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[45].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[45].gpio.pinmap = 70;
b->pins[45].gpio.parent_id = 0;
@@ -983,51 +983,51 @@ mraa_beaglebone()
// TODO PWM_2B
if (hdmi_enabled == 1) {
strncpy(b->pins[46].name, "LCD_D1", MRAA_PIN_NAME_SIZE);
b->pins[46].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[46].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[46].name, "GPIO71", MRAA_PIN_NAME_SIZE);
b->pins[46].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[46].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[46].gpio.pinmap = 71;
b->pins[46].gpio.parent_id = 0;
b->pins[46].gpio.mux_total = 0;
strncpy(b->pins[47].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[47].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[47].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[48].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[48].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[48].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[49].name, "3.3V", MRAA_PIN_NAME_SIZE);
b->pins[49].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[49].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[50].name, "3.3V", MRAA_PIN_NAME_SIZE);
b->pins[50].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[50].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[51].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[51].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[51].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[52].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[52].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[52].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[53].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[53].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[53].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[54].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[54].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[54].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[55].name, "PWR", MRAA_PIN_NAME_SIZE);
b->pins[55].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[55].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[56].name, "RESET", MRAA_PIN_NAME_SIZE);
b->pins[56].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[56].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
if (uart4_enabled == 1) {
strncpy(b->pins[57].name, "UART4_RX", MRAA_PIN_NAME_SIZE);
b->pins[57].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[57].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
} else {
strncpy(b->pins[57].name, "GPIO30", MRAA_PIN_NAME_SIZE);
b->pins[57].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[57].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
}
b->pins[57].gpio.pinmap = 30;
b->pins[57].gpio.parent_id = 0;
@@ -1035,17 +1035,17 @@ mraa_beaglebone()
b->pins[57].uart.mux_total = 0;
strncpy(b->pins[58].name, "GPIO60", MRAA_PIN_NAME_SIZE);
b->pins[58].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[58].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[58].gpio.pinmap = 60;
b->pins[58].gpio.parent_id = 0;
b->pins[58].gpio.mux_total = 0;
if (uart4_enabled == 1) {
strncpy(b->pins[59].name, "UART4_TX", MRAA_PIN_NAME_SIZE);
b->pins[59].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[59].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
} else {
strncpy(b->pins[59].name, "GPIO31", MRAA_PIN_NAME_SIZE);
b->pins[59].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[59].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
}
b->pins[59].gpio.pinmap = 31;
b->pins[59].gpio.parent_id = 0;
@@ -1054,10 +1054,10 @@ mraa_beaglebone()
if (ehrpwm1a_enabled == 1) {
strncpy(b->pins[60].name, "EHRPWM1A", MRAA_PIN_NAME_SIZE);
b->pins[60].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[60].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[60].name, "GPIO50", MRAA_PIN_NAME_SIZE);
b->pins[60].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[60].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[60].gpio.pinmap = 50;
b->pins[60].gpio.parent_id = 0;
@@ -1067,17 +1067,17 @@ mraa_beaglebone()
// TODO PWM_TRIP2_IN (not a PWM output, but used for sync cf ref. manual)
strncpy(b->pins[61].name, "GPIO48", MRAA_PIN_NAME_SIZE);
b->pins[61].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[61].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[61].gpio.pinmap = 48;
b->pins[61].gpio.parent_id = 0;
b->pins[61].gpio.mux_total = 0;
if (ehrpwm1b_enabled == 1) {
strncpy(b->pins[62].name, "EHRPWM1B", MRAA_PIN_NAME_SIZE);
b->pins[62].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[62].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
} else {
strncpy(b->pins[62].name, "GPIO51", MRAA_PIN_NAME_SIZE);
b->pins[62].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[62].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
}
b->pins[62].gpio.pinmap = 51;
b->pins[62].gpio.parent_id = 0;
@@ -1088,15 +1088,15 @@ mraa_beaglebone()
if ((i2c0_enabled == 1) || (spi0_enabled == 1)) {
if (i2c0_enabled == 1) {
strncpy(b->pins[63].name, "I2C1SCL", MRAA_PIN_NAME_SIZE);
b->pins[63].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
b->pins[63].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
}
if (spi0_enabled == 1) {
strncpy(b->pins[63].name, "SPI0CS0", MRAA_PIN_NAME_SIZE);
b->pins[63].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[63].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
}
} else {
strncpy(b->pins[63].name, "GPIO4", MRAA_PIN_NAME_SIZE);
b->pins[63].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
b->pins[63].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
}
b->pins[63].gpio.pinmap = 4;
b->pins[63].gpio.parent_id = 0;
@@ -1107,15 +1107,15 @@ mraa_beaglebone()
if ((i2c0_enabled == 1) || (spi0_enabled == 1)) {
if (i2c0_enabled == 1) {
strncpy(b->pins[64].name, "I2C1SDA", MRAA_PIN_NAME_SIZE);
b->pins[64].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
b->pins[64].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
}
if (spi0_enabled == 1) {
strncpy(b->pins[64].name, "SPI0D1", MRAA_PIN_NAME_SIZE);
b->pins[64].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[64].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
}
} else {
strncpy(b->pins[64].name, "GPIO5", MRAA_PIN_NAME_SIZE);
b->pins[64].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
b->pins[64].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 1, 0, 0 };
}
b->pins[64].gpio.pinmap = 5;
b->pins[64].gpio.parent_id = 0;
@@ -1125,11 +1125,11 @@ mraa_beaglebone()
if (i2c1_enabled == 1) {
strncpy(b->pins[65].name, "I2C2SCL", MRAA_PIN_NAME_SIZE);
b->pins[65].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[65].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[65].i2c.mux_total = 0;
} else {
strncpy(b->pins[65].name, "GPIO13", MRAA_PIN_NAME_SIZE);
b->pins[65].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[65].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
}
b->pins[65].gpio.pinmap = 13;
b->pins[65].gpio.parent_id = 0;
@@ -1138,11 +1138,11 @@ mraa_beaglebone()
if (i2c1_enabled == 1) {
strncpy(b->pins[66].name, "I2C2SDA", MRAA_PIN_NAME_SIZE);
b->pins[66].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[66].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[66].i2c.mux_total = 0;
} else {
strncpy(b->pins[66].name, "GPIO12", MRAA_PIN_NAME_SIZE);
b->pins[66].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[66].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
}
b->pins[66].gpio.pinmap = 12;
b->pins[66].gpio.parent_id = 0;
@@ -1152,19 +1152,19 @@ mraa_beaglebone()
if ((spi0_enabled == 1) || uart2_enabled == 1 || ehrpwm0b_enabled == 1) {
if (uart2_enabled == 1) {
strncpy(b->pins[67].name, "UART2_TX", MRAA_PIN_NAME_SIZE);
b->pins[67].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
b->pins[67].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
}
if (spi0_enabled == 1) {
strncpy(b->pins[67].name, "SPI0D0", MRAA_PIN_NAME_SIZE);
b->pins[67].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[67].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
}
if (ehrpwm0b_enabled == 1) {
strncpy(b->pins[67].name, "EHRPWM0B", MRAA_PIN_NAME_SIZE);
b->pins[67].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[67].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
}
} else {
strncpy(b->pins[67].name, "GPIO3", MRAA_PIN_NAME_SIZE);
b->pins[67].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 1 };
b->pins[67].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 1 };
}
b->pins[67].gpio.pinmap = 3;
b->pins[67].gpio.parent_id = 0;
@@ -1177,19 +1177,19 @@ mraa_beaglebone()
if ((spi0_enabled == 1) || uart2_enabled == 1 || ehrpwm0a_enabled == 1) {
if (uart2_enabled == 1) {
strncpy(b->pins[68].name, "UART2_RX", MRAA_PIN_NAME_SIZE);
b->pins[68].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 1 };
b->pins[68].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 1 };
}
if (spi0_enabled == 1) {
strncpy(b->pins[68].name, "SPI0CLK", MRAA_PIN_NAME_SIZE);
b->pins[68].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[68].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
}
if (ehrpwm0a_enabled == 1) {
strncpy(b->pins[68].name, "EHRPWM0A", MRAA_PIN_NAME_SIZE);
b->pins[68].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[68].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
}
} else {
strncpy(b->pins[68].name, "GPIO2", MRAA_PIN_NAME_SIZE);
b->pins[68].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 1 };
b->pins[68].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 1 };
}
b->pins[68].gpio.pinmap = 2;
b->pins[68].gpio.parent_id = 0;
@@ -1201,17 +1201,17 @@ mraa_beaglebone()
// TODO PWM0_SYNCO ?? PWM
strncpy(b->pins[69].name, "GPIO49", MRAA_PIN_NAME_SIZE);
b->pins[69].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[69].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[69].gpio.pinmap = 49;
b->pins[69].gpio.parent_id = 0;
b->pins[69].gpio.mux_total = 0;
if (uart1_enabled == 1) {
strncpy(b->pins[70].name, "UART1_RX", MRAA_PIN_NAME_SIZE);
b->pins[70].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[70].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
} else {
strncpy(b->pins[70].name, "GPIO15", MRAA_PIN_NAME_SIZE);
b->pins[70].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[70].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
}
b->pins[70].gpio.pinmap = 15;
b->pins[70].gpio.parent_id = 0;
@@ -1219,26 +1219,26 @@ mraa_beaglebone()
b->pins[70].uart.mux_total = 0;
strncpy(b->pins[71].name, "GPIO117", MRAA_PIN_NAME_SIZE);
b->pins[71].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[71].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[71].gpio.pinmap = 117;
b->pins[71].gpio.parent_id = 0;
b->pins[71].gpio.mux_total = 0;
if (uart1_enabled == 1) {
strncpy(b->pins[72].name, "UART1_RX", MRAA_PIN_NAME_SIZE);
b->pins[72].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[72].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
} else {
strncpy(b->pins[72].name, "GPIO14", MRAA_PIN_NAME_SIZE);
b->pins[72].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[72].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
}
b->pins[72].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[72].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[72].gpio.pinmap = 14;
b->pins[72].gpio.parent_id = 0;
b->pins[72].gpio.mux_total = 0;
b->pins[72].uart.mux_total = 0;
strncpy(b->pins[73].name, "GPIO115", MRAA_PIN_NAME_SIZE);
b->pins[73].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[73].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[73].gpio.pinmap = 115;
b->pins[73].gpio.parent_id = 0;
b->pins[73].gpio.mux_total = 0;
@@ -1246,14 +1246,14 @@ mraa_beaglebone()
if (emmc_enabled != 1) {
if (spi1_enabled == 1) {
strncpy(b->pins[74].name, "SPI1CS0", MRAA_PIN_NAME_SIZE);
b->pins[74].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[74].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
} else {
strncpy(b->pins[74].name, "GPIO113", MRAA_PIN_NAME_SIZE);
b->pins[74].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[74].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
}
} else {
strncpy(b->pins[74].name, "MCASP0XX", MRAA_PIN_NAME_SIZE);
b->pins[74].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[74].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
}
b->pins[74].gpio.pinmap = 113;
b->pins[74].gpio.parent_id = 0;
@@ -1263,14 +1263,14 @@ mraa_beaglebone()
if (emmc_enabled != 1) {
if (spi1_enabled == 1) {
strncpy(b->pins[75].name, "SPI1D0", MRAA_PIN_NAME_SIZE);
b->pins[75].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[75].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
} else {
strncpy(b->pins[75].name, "GPIO111", MRAA_PIN_NAME_SIZE);
b->pins[75].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[75].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
}
} else {
strncpy(b->pins[75].name, "MMC1_SD", MRAA_PIN_NAME_SIZE);
b->pins[75].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[75].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
b->pins[75].gpio.pinmap = 111;
b->pins[75].gpio.parent_id = 0;
@@ -1280,14 +1280,14 @@ mraa_beaglebone()
if (emmc_enabled != 1) {
if (spi1_enabled == 1) {
strncpy(b->pins[76].name, "SPI1D1", MRAA_PIN_NAME_SIZE);
b->pins[76].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[76].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
} else {
strncpy(b->pins[76].name, "GPIO112", MRAA_PIN_NAME_SIZE);
b->pins[76].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[76].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
}
} else {
strncpy(b->pins[76].name, "MMC2_SD", MRAA_PIN_NAME_SIZE);
b->pins[76].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[76].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
b->pins[76].gpio.pinmap = 112;
b->pins[76].gpio.parent_id = 0;
@@ -1297,14 +1297,14 @@ mraa_beaglebone()
if (emmc_enabled != 1) {
if (spi1_enabled == 1) {
strncpy(b->pins[77].name, "SPI1CLK", MRAA_PIN_NAME_SIZE);
b->pins[77].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[77].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
} else {
strncpy(b->pins[77].name, "GPIO110", MRAA_PIN_NAME_SIZE);
b->pins[77].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[77].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
}
} else {
strncpy(b->pins[77].name, "MMC0_SD", MRAA_PIN_NAME_SIZE);
b->pins[77].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[77].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
b->pins[77].gpio.pinmap = 110;
b->pins[77].gpio.parent_id = 0;
@@ -1313,60 +1313,60 @@ mraa_beaglebone()
strncpy(b->pins[78].name, "VDD_ADC", MRAA_PIN_NAME_SIZE);
b->pins[78].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[78].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// TODO AIN4
strncpy(b->pins[79].name, "AIN4", MRAA_PIN_NAME_SIZE);
b->pins[79].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[79].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
strncpy(b->pins[80].name, "GND_ADC", MRAA_PIN_NAME_SIZE);
b->pins[80].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[80].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// TODO AIN6
strncpy(b->pins[81].name, "AIN6", MRAA_PIN_NAME_SIZE);
b->pins[81].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[81].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
// TODO AIN5
strncpy(b->pins[82].name, "AIN5", MRAA_PIN_NAME_SIZE);
b->pins[82].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[82].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
// TODO AIN2
strncpy(b->pins[83].name, "AIN2", MRAA_PIN_NAME_SIZE);
b->pins[83].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[83].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
// TODO AIN3
strncpy(b->pins[84].name, "AIN3", MRAA_PIN_NAME_SIZE);
b->pins[84].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[84].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
// TODO AIN0
strncpy(b->pins[85].name, "AIN0", MRAA_PIN_NAME_SIZE);
b->pins[85].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[85].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
// TODO AIN1
strncpy(b->pins[86].name, "AIN1", MRAA_PIN_NAME_SIZE);
b->pins[86].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[86].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
strncpy(b->pins[87].name, "GPIO20", MRAA_PIN_NAME_SIZE);
b->pins[87].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[87].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[87].gpio.pinmap = 20;
b->pins[87].gpio.parent_id = 0;
b->pins[87].gpio.mux_total = 0;
strncpy(b->pins[88].name, "GPIO7", MRAA_PIN_NAME_SIZE);
b->pins[88].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[88].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[88].gpio.pinmap = 7;
b->pins[88].gpio.parent_id = 0;
b->pins[88].gpio.mux_total = 0;
// GND
strncpy(b->pins[89].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[89].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[89].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// GND
strncpy(b->pins[90].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[90].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[90].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// GND
strncpy(b->pins[91].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[91].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[91].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// GND
strncpy(b->pins[92].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[92].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[92].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// BUS DEFINITIONS
b->i2c_bus_count = 2;
@@ -1417,7 +1417,7 @@ mraa_beaglebone()
b->gpio_count = 0;
int i;
for (i = 0; i < b->phy_pin_count; i++)
if (b->pins[i].capabilites.gpio)
if (b->pins[i].capabilities.gpio)
b->gpio_count++;
return b;

View File

@@ -292,63 +292,63 @@ mraa_raspberry_pi()
b->adv_func->gpio_mmap_setup = &mraa_raspberry_pi_mmap_setup;
strncpy(b->pins[0].name, "INVALID", MRAA_PIN_NAME_SIZE);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "3V3", MRAA_PIN_NAME_SIZE);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[3].name, "SDA0", MRAA_PIN_NAME_SIZE);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[3].gpio.pinmap = 2;
b->pins[3].gpio.mux_total = 0;
b->pins[3].i2c.pinmap = 0;
b->pins[3].i2c.mux_total = 0;
strncpy(b->pins[4].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[5].name, "SCL0", MRAA_PIN_NAME_SIZE);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[5].gpio.pinmap = 3;
b->pins[5].gpio.mux_total = 0;
b->pins[5].i2c.pinmap = 0;
b->pins[5].i2c.mux_total = 0;
strncpy(b->pins[6].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[7].name, "GPIO4", MRAA_PIN_NAME_SIZE);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 4;
b->pins[7].gpio.mux_total = 0;
strncpy(b->pins[8].name, "UART_TX", MRAA_PIN_NAME_SIZE);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[8].gpio.pinmap = 14;
b->pins[8].gpio.mux_total = 0;
b->pins[8].uart.parent_id = 0;
b->pins[8].uart.mux_total = 0;
strncpy(b->pins[9].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[10].name, "UART_RX", MRAA_PIN_NAME_SIZE);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[10].gpio.pinmap = 15;
b->pins[10].gpio.mux_total = 0;
b->pins[10].uart.parent_id = 0;
b->pins[10].uart.mux_total = 0;
strncpy(b->pins[11].name, "GPIO17", MRAA_PIN_NAME_SIZE);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].gpio.pinmap = 17;
b->pins[11].gpio.mux_total = 0;
strncpy(b->pins[12].name, "GPIO18", MRAA_PIN_NAME_SIZE);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].gpio.pinmap = 18;
b->pins[12].gpio.mux_total = 0;
@@ -359,71 +359,71 @@ mraa_raspberry_pi()
strncpy(b->pins[13].name, "GPIO27", MRAA_PIN_NAME_SIZE);
b->pins[13].gpio.pinmap = 27;
}
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[13].gpio.mux_total = 0;
strncpy(b->pins[14].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[15].name, "GPIO22", MRAA_PIN_NAME_SIZE);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[15].gpio.pinmap = 22;
b->pins[15].gpio.mux_total = 0;
strncpy(b->pins[16].name, "GPIO23", MRAA_PIN_NAME_SIZE);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[16].gpio.pinmap = 23;
b->pins[16].gpio.mux_total = 0;
strncpy(b->pins[17].name, "3V3", MRAA_PIN_NAME_SIZE);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[18].name, "GPIO24", MRAA_PIN_NAME_SIZE);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[18].gpio.pinmap = 24;
b->pins[18].gpio.mux_total = 0;
strncpy(b->pins[19].name, "SPI_MOSI", MRAA_PIN_NAME_SIZE);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[19].gpio.pinmap = 10;
b->pins[19].gpio.mux_total = 0;
b->pins[19].spi.pinmap = 0;
b->pins[19].spi.mux_total = 0;
strncpy(b->pins[20].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[20].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[21].name, "SPI_MISO", MRAA_PIN_NAME_SIZE);
b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[21].gpio.pinmap = 9;
b->pins[21].gpio.mux_total = 0;
b->pins[21].spi.pinmap = 0;
b->pins[21].spi.mux_total = 0;
strncpy(b->pins[22].name, "GPIO25", MRAA_PIN_NAME_SIZE);
b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[22].gpio.pinmap = 25;
b->pins[22].gpio.mux_total = 0;
strncpy(b->pins[23].name, "SPI_CLK", MRAA_PIN_NAME_SIZE);
b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[23].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[23].gpio.pinmap = 11;
b->pins[23].gpio.mux_total = 0;
b->pins[23].spi.pinmap = 0;
b->pins[23].spi.mux_total = 0;
strncpy(b->pins[24].name, "SPI_CS0", MRAA_PIN_NAME_SIZE);
b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[24].gpio.pinmap = 8;
b->pins[24].gpio.mux_total = 0;
b->pins[24].spi.pinmap = 0;
b->pins[24].spi.mux_total = 0;
strncpy(b->pins[25].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[25].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[26].name, "SPI_CS1", MRAA_PIN_NAME_SIZE);
b->pins[26].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[26].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[26].gpio.pinmap = 7;
b->pins[26].gpio.mux_total = 0;
b->pins[26].spi.pinmap = 0;
@@ -432,36 +432,36 @@ mraa_raspberry_pi()
if ((platform_detected == PLATFORM_RASPBERRY_PI_A_REV_2) ||
(platform_detected == PLATFORM_RASPBERRY_PI_B_REV_2)) {
strncpy(b->pins[27].name, "5V", MRAA_PIN_NAME_SIZE);
b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[28].name, "3V3", MRAA_PIN_NAME_SIZE);
b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[29].name, "GPIO8", MRAA_PIN_NAME_SIZE);
b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].gpio.pinmap = 8;
b->pins[29].gpio.mux_total = 0;
strncpy(b->pins[30].name, "GPIO9", MRAA_PIN_NAME_SIZE);
b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[30].gpio.pinmap = 9;
b->pins[30].gpio.mux_total = 0;
strncpy(b->pins[31].name, "GPIO10", MRAA_PIN_NAME_SIZE);
b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].gpio.pinmap = 10;
b->pins[31].gpio.mux_total = 0;
strncpy(b->pins[32].name, "GPIO11", MRAA_PIN_NAME_SIZE);
b->pins[32].gpio.pinmap = 11;
b->pins[32].gpio.mux_total = 0;
b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[33].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
// BUS DEFINITIONS
@@ -493,62 +493,62 @@ mraa_raspberry_pi()
(platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1)) {
strncpy(b->pins[27].name, "ID_SD", MRAA_PIN_NAME_SIZE);
b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[27].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[28].name, "ID_SC", MRAA_PIN_NAME_SIZE);
b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[28].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[29].name, "GPIO05", MRAA_PIN_NAME_SIZE);
b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[29].gpio.pinmap = 5;
b->pins[29].gpio.mux_total = 0;
strncpy(b->pins[30].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[31].name, "GPIO06", MRAA_PIN_NAME_SIZE);
b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[31].gpio.pinmap = 6;
b->pins[31].gpio.mux_total = 0;
strncpy(b->pins[32].name, "GPIO12", MRAA_PIN_NAME_SIZE);
b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[32].gpio.pinmap = 12;
b->pins[32].gpio.mux_total = 0;
strncpy(b->pins[33].name, "GPIO13", MRAA_PIN_NAME_SIZE);
b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[33].gpio.pinmap = 13;
b->pins[33].gpio.mux_total = 0;
strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[34].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[35].name, "GPIO19", MRAA_PIN_NAME_SIZE);
b->pins[35].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[35].gpio.pinmap = 19;
b->pins[35].gpio.mux_total = 0;
strncpy(b->pins[36].name, "GPIO16", MRAA_PIN_NAME_SIZE);
b->pins[36].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[36].gpio.pinmap = 16;
b->pins[36].gpio.mux_total = 0;
strncpy(b->pins[37].name, "GPIO26", MRAA_PIN_NAME_SIZE);
b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[37].gpio.pinmap = 26;
b->pins[37].gpio.mux_total = 0;
strncpy(b->pins[38].name, "GPIO20", MRAA_PIN_NAME_SIZE);
b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[38].gpio.pinmap = 20;
b->pins[38].gpio.mux_total = 0;
strncpy(b->pins[39].name, "GND", MRAA_PIN_NAME_SIZE);
b->pins[39].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[39].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[40].name, "GPIO21", MRAA_PIN_NAME_SIZE);
b->pins[40].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[40].gpio.pinmap = 21;
b->pins[40].gpio.mux_total = 0;
}
@@ -556,7 +556,7 @@ mraa_raspberry_pi()
b->gpio_count = 0;
int i;
for (i = 0; i < b->phy_pin_count; i++) {
if (b->pins[i].capabilites.gpio) {
if (b->pins[i].capabilities.gpio) {
b->gpio_count++;
}
}

View File

@@ -351,6 +351,9 @@ mraa_firmata_aio_read(mraa_aio_context dev)
static mraa_result_t
mraa_firmata_aio_init_internal_replace(mraa_aio_context dev, int aio)
{
// set the channel, since we override internal it's never set
// offset by 14 because it makes total logical sense.
dev->channel = aio + 14;
// firmata considers A0 pin0 as well as actual pin0 :/
firmata_pinMode(firmata_dev, aio, MODE_ANALOG);
// register for updates on that ADC channel
@@ -568,69 +571,69 @@ mraa_firmata_plat_init(const char* uart_dev)
}
strncpy(b->pins[0].name, "IO0", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[0].gpio.pinmap = 0;
strncpy(b->pins[1].name, "IO1", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[1].gpio.pinmap = 1;
strncpy(b->pins[2].name, "IO2", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[2].gpio.pinmap = 2;
strncpy(b->pins[3].name, "IO3", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[3].gpio.pinmap = 3;
strncpy(b->pins[4].name, "IO4", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].gpio.pinmap = 4;
strncpy(b->pins[5].name, "IO5", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].gpio.pinmap = 5;
strncpy(b->pins[6].name, "IO6", 8);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].gpio.pinmap = 6;
strncpy(b->pins[7].name, "IO7", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 7;
strncpy(b->pins[8].name, "IO8", 8);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 8;
strncpy(b->pins[9].name, "IO9", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 9;
strncpy(b->pins[10].name, "IO10", 8);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[10].gpio.pinmap = 10;
strncpy(b->pins[11].name, "IO11", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[11].gpio.pinmap = 11;
strncpy(b->pins[12].name, "IO12", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[12].gpio.pinmap = 12;
strncpy(b->pins[13].name, "IO13", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[13].gpio.pinmap = 13;
strncpy(b->pins[10].name, "A0", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].gpio.pinmap = 14;
b->pins[14].aio.pinmap = 14;
strncpy(b->pins[11].name, "A1", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].gpio.pinmap = 15;
b->pins[15].aio.pinmap = 15;
strncpy(b->pins[12].name, "A2", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].gpio.pinmap = 16;
b->pins[16].aio.pinmap = 16;
strncpy(b->pins[13].name, "A3", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].gpio.pinmap = 17;
b->pins[17].aio.pinmap = 17;
strncpy(b->pins[13].name, "A4", 8);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[18].gpio.pinmap = 18;
b->pins[18].aio.pinmap = 18;
strncpy(b->pins[13].name, "A5", 8);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[19].gpio.pinmap = 19;
b->pins[19].aio.pinmap = 19;

View File

@@ -151,7 +151,7 @@ mraa_gpio_init(int pin)
syslog(LOG_ERR, "gpio: init: pin %i beyond platform pin count (%i)", pin, board->phy_pin_count);
return NULL;
}
if (board->pins[pin].capabilites.gpio != 1) {
if (board->pins[pin].capabilities.gpio != 1) {
syslog(LOG_ERR, "gpio: init: pin %i not capable of gpio", pin);
return NULL;
}
@@ -382,6 +382,10 @@ mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t mode, void (*fptr)(void*),
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, gpio_isr_replace)) {
return dev->advance_func->gpio_isr_replace(dev, mode, fptr, args);
}
// we only allow one isr per mraa_gpio_context
if (dev->thread_id != 0) {
return MRAA_ERROR_NO_RESOURCES;
@@ -417,6 +421,10 @@ mraa_gpio_isr_exit(mraa_gpio_context dev)
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, gpio_isr_exit_replace)) {
return dev->advance_func->gpio_isr_exit_replace(dev);
}
// wasting our time, there is no isr to exit from
if (dev->thread_id == 0 && dev->isr_value_fp == -1) {
return ret;
@@ -610,6 +618,10 @@ mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, gpio_read_dir_replace)) {
return dev->advance_func->gpio_read_dir_replace(dev, dir);
}
snprintf(filepath, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/direction", dev->pin);
fd = open(filepath, O_RDONLY);
if (fd == -1) {

View File

@@ -34,6 +34,9 @@
#include <inttypes.h>
#include <sys/types.h>
#include <sys/errno.h>
#if defined(MSYS)
#define __USE_LINUX_IOCTL_DEFS
#endif
#include <sys/ioctl.h>
#include "linux/i2c-dev.h"
#include <errno.h>
@@ -194,6 +197,11 @@ mraa_i2c_init_raw(unsigned int bus)
mraa_result_t
mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: frequency: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, i2c_set_frequency_replace)) {
return dev->advance_func->i2c_set_frequency_replace(dev, mode);
}
@@ -203,6 +211,11 @@ mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode)
int
mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: read: context is invalid");
return -1;
}
int bytes_read = 0;
if (IS_FUNC_DEFINED(dev, i2c_read_replace)) {
bytes_read = dev->advance_func->i2c_read_replace(dev, data, length);
@@ -220,6 +233,11 @@ mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length)
int
mraa_i2c_read_byte(mraa_i2c_context dev)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: read_byte: context is invalid");
return -1;
}
if (IS_FUNC_DEFINED(dev, i2c_read_byte_replace))
return dev->advance_func->i2c_read_byte_replace(dev);
i2c_smbus_data_t d;
@@ -233,6 +251,11 @@ mraa_i2c_read_byte(mraa_i2c_context dev)
int
mraa_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: read_byte_data: context is invalid");
return -1;
}
if (IS_FUNC_DEFINED(dev, i2c_read_byte_data_replace))
return dev->advance_func->i2c_read_byte_data_replace(dev, command);
i2c_smbus_data_t d;
@@ -246,6 +269,11 @@ mraa_i2c_read_byte_data(mraa_i2c_context dev, uint8_t command)
int
mraa_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: read_word_data: context is invalid");
return -1;
}
if (IS_FUNC_DEFINED(dev, i2c_read_word_data_replace))
return dev->advance_func->i2c_read_word_data_replace(dev, command);
i2c_smbus_data_t d;
@@ -259,6 +287,11 @@ mraa_i2c_read_word_data(mraa_i2c_context dev, uint8_t command)
int
mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: read_bytes_data: context is invalid");
return -1;
}
if (IS_FUNC_DEFINED(dev, i2c_read_bytes_data_replace))
return dev->advance_func->i2c_read_bytes_data_replace(dev, command, data, length);
struct i2c_rdwr_ioctl_data d;
@@ -289,6 +322,11 @@ mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, i
mraa_result_t
mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: write: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, i2c_write_replace))
return dev->advance_func->i2c_write_replace(dev, data, length);
i2c_smbus_data_t d;
@@ -316,6 +354,11 @@ mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length)
mraa_result_t
mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: write_byte: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, i2c_write_byte_replace)) {
return dev->advance_func->i2c_write_byte_replace(dev, data);
} else {
@@ -330,6 +373,11 @@ mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data)
mraa_result_t
mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: write_byte_data: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, i2c_write_byte_data_replace))
return dev->advance_func->i2c_write_byte_data_replace(dev, data, command);
i2c_smbus_data_t d;
@@ -344,6 +392,11 @@ mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t
mraa_result_t
mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: write_word_data: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, i2c_write_word_data_replace))
return dev->advance_func->i2c_write_word_data_replace(dev, data, command);
i2c_smbus_data_t d;
@@ -359,6 +412,7 @@ mraa_result_t
mraa_i2c_address(mraa_i2c_context dev, uint8_t addr)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: address: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
@@ -378,6 +432,15 @@ mraa_i2c_address(mraa_i2c_context dev, uint8_t addr)
mraa_result_t
mraa_i2c_stop(mraa_i2c_context dev)
{
if (dev == NULL) {
syslog(LOG_ERR, "i2c: stop: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
if (IS_FUNC_DEFINED(dev, i2c_stop_replace)) {
return dev->advance_func->i2c_stop_replace(dev);
}
free(dev);
return MRAA_SUCCESS;
}

View File

@@ -27,6 +27,9 @@
#include "dirent.h"
#include <string.h>
#include <poll.h>
#if defined(MSYS)
#define __USE_LINUX_IOCTL_DEFS
#endif
#include <sys/ioctl.h>
#include <sys/stat.h>

716
src/json/jsonplatform.c Normal file
View File

@@ -0,0 +1,716 @@
/*
* Author: Houman Brinjcargorabi <Houman.Brinjcargorabi@intel.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <json-c/json.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "mraa_internal.h"
typedef mraa_result_t (*init_plat_func_t)(json_object*, mraa_board_t*, int);
mraa_result_t
mraa_init_json_platform_get_pin(json_object* jobj, const char* io, const char* key, int index, int* pin)
{
json_object* jobj_temp = NULL;
if (json_object_object_get_ex(jobj, key, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_int)) {
syslog(LOG_ERR, "init_json_platform: %s %s at position: %d is not an int", io, key, index);
return MRAA_ERROR_INVALID_RESOURCE;
}
*pin = (unsigned int) json_object_get_int(jobj_temp);
return MRAA_SUCCESS;
}
syslog(LOG_ERR, "init_json_platform: No %s specified for %s at position: %d", key, io, index);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
mraa_result_t
mraa_init_json_platform_get_index(json_object* jobj, const char* io, const char* key, int index, int* pos, int upper)
{
json_object* jobj_temp = NULL;
if (json_object_object_get_ex(jobj, key, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_int)) {
syslog(LOG_ERR, "init_json_platform: %s index at position: %d not an int", io, index);
return MRAA_ERROR_INVALID_RESOURCE;
}
*pos = (int) json_object_get_int(jobj_temp);
if (*pos < 0 || *pos > upper) {
syslog(LOG_ERR,
"init_json_platform: %s %s at position: %d, gave: %d which was out of range", io,
key, index, *pos);
return MRAA_ERROR_INVALID_RESOURCE;
}
return MRAA_SUCCESS;
}
syslog(LOG_ERR, "init_json_platform: An %s was not found for the %s", key, io);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
mraa_result_t
mraa_init_json_platform_platform(json_object* jobj_platform, mraa_board_t* board, int index)
{
json_object* jobj_temp = NULL;
const char* temp_string = NULL;
int temp_count = 0;
int length = 0;
mraa_result_t ret = MRAA_SUCCESS;
// Set the platform name
if (json_object_object_get_ex(jobj_platform, NAME_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_string)) {
syslog(LOG_ERR, "init_json_platform: Platform name not a string");
return MRAA_ERROR_NO_RESOURCES;
}
temp_string = json_object_get_string(jobj_temp);
if (temp_string == NULL || (length = strlen(temp_string)) == 0) {
syslog(LOG_ERR, "init_json_platform: Empty string provided for \"%s\" key in platform", NAME_KEY);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
board->platform_name = (char*) calloc(length, sizeof(char));
strncpy(board->platform_name, temp_string, length);
} else {
syslog(LOG_ERR, "init_json_platform: No \"%s\" key in platform", NAME_KEY);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
// Get the physical pincount
ret = mraa_init_json_platform_get_pin(jobj_platform, PLATFORM_KEY, PIN_COUNT_KEY, index,
&(board->phy_pin_count));
if (ret != MRAA_SUCCESS) {
return ret;
}
// Setup the pins
board->pins = (mraa_pininfo_t*) calloc(board->phy_pin_count, sizeof(mraa_pininfo_t));
if (board->pins == NULL) {
syslog(LOG_ERR, "init_json_platform: Unable to allocate space for the pins");
return MRAA_ERROR_INVALID_RESOURCE;
}
// set the inital counts to -1 so we know if they don't exist
board->gpio_count = -1;
board->aio_count = -1;
board->uart_dev_count = -1;
board->i2c_bus_count = -1;
board->spi_bus_count = -1;
// Check to see if they've provided a GPIO count
ret = mraa_init_json_platform_get_index(jobj_platform, PLATFORM_KEY, GPIO_COUNT_KEY, index,
&(board->gpio_count), board->phy_pin_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
// Check to see if they've provided a AIO count
ret = mraa_init_json_platform_get_index(jobj_platform, PLATFORM_KEY, AIO_COUNT_KEY, index,
&(board->aio_count), board->phy_pin_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
// Check to see if they've provided a UART count
ret = mraa_init_json_platform_get_index(jobj_platform, PLATFORM_KEY, UART_COUNT_KEY, index,
&(board->uart_dev_count), 6);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
// Check to see if they've provided a I2C count
ret = mraa_init_json_platform_get_index(jobj_platform, PLATFORM_KEY, I2C_COUNT_KEY, index,
&(board->i2c_bus_count), 12);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
// Check to see if they've provided a SPI count
ret = mraa_init_json_platform_get_index(jobj_platform, PLATFORM_KEY, SPI_COUNT_KEY, index,
&(board->spi_bus_count), 12);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
// Set the PWM default numbers
board->pwm_default_period = -1;
board->pwm_max_period = -1;
board->pwm_min_period = -1;
// Setup the PWM rates if they exist
ret = mraa_init_json_platform_get_pin(jobj_platform, PLATFORM_KEY, PWMDEFAULT_KEY, index,
&(board->pwm_default_period));
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
ret = mraa_init_json_platform_get_pin(jobj_platform, PLATFORM_KEY, PWMMAX_KEY, index,
&(board->pwm_max_period));
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
ret = mraa_init_json_platform_get_pin(jobj_platform, PLATFORM_KEY, PWMMIN_KEY, index,
&(board->pwm_min_period));
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
return ret;
}
// A hacky logical xor to ensure the value's have all been set or none should have been set
// Here we infer that IF A != B and B != C then A == C since they're working on binary values
if (((board->pwm_default_period == -1) != (board->pwm_max_period == -1)) ||
((board->pwm_min_period == -1) != (board->pwm_max_period == -1))) {
syslog(LOG_ERR, "init_json_platform: One of more PWM settings missing in the platform"
"configuration");
return MRAA_ERROR_INVALID_RESOURCE;
}
// Set our platform type
board->platform_type = MRAA_JSON_PLATFORM;
board->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
return MRAA_SUCCESS;
}
mraa_result_t
mraa_init_json_platform_io(json_object* jobj_io, mraa_board_t* board, int index)
{
const char* temp_string = NULL;
json_object* jobj_temp = NULL;
int pos = 0;
int invalid = 0;
pos = index;
// set the label for the IO
if (json_object_object_get_ex(jobj_io, LABEL_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_string)) {
syslog(LOG_ERR, "init_json_platform: IO label at position: %d not a string", index);
return MRAA_ERROR_NO_RESOURCES;
}
temp_string = json_object_get_string(jobj_temp);
// set the gpio label
strncpy(board->pins[pos].name, temp_string, 8);
} else {
syslog(LOG_ERR, "init_json_platform: No IO Label");
return MRAA_ERROR_INVALID_RESOURCE;
}
if (json_object_object_get_ex(jobj_io, INVALID_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_boolean)) {
syslog(LOG_ERR, "init_json_platform: Default I2C device key has an incorrect value");
return MRAA_ERROR_INVALID_RESOURCE;
}
invalid = json_object_get_boolean(jobj_temp);
}
if (invalid) {
board->pins[pos].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
} else {
board->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
}
return MRAA_SUCCESS;
}
mraa_result_t
mraa_init_json_platform_gpio(json_object* jobj_gpio, mraa_board_t* board, int index)
{
int pos = 0;
mraa_result_t ret = MRAA_SUCCESS;
// Get the gpio index
ret = mraa_init_json_platform_get_index(jobj_gpio, GPIO_KEY, INDEX_KEY, index, &pos,
board->phy_pin_count - 1);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the gpio sysfs pin;
ret = mraa_init_json_platform_get_pin(jobj_gpio, GPIO_KEY, RAW_PIN_KEY, index,
&(board->pins[pos].gpio.pinmap));
if (ret != MRAA_SUCCESS) {
return ret;
}
board->pins[pos].capabilities.gpio = 1;
return MRAA_SUCCESS;
}
mraa_result_t
mraa_init_json_platform_aio(json_object* jobj_aio, mraa_board_t* board, int index)
{
int pos = 0;
mraa_result_t ret = MRAA_SUCCESS;
// Get the gpio index
ret = mraa_init_json_platform_get_index(jobj_aio, AIO_KEY, INDEX_KEY, index, &pos, board->phy_pin_count - 1);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the gpio sysfs pin;
ret = mraa_init_json_platform_get_pin(jobj_aio, AIO_KEY, RAW_PIN_KEY, index,
&(board->pins[pos].aio.pinmap));
if (ret != MRAA_SUCCESS) {
return ret;
}
board->pins[pos].capabilities.aio = 1;
return MRAA_SUCCESS;
}
mraa_result_t
mraa_init_json_platform_i2c(json_object* jobj_i2c, mraa_board_t* board, int index)
{
int pos = 0;
int pin = 0;
int sysfs_pin = 0;
mraa_result_t ret = MRAA_SUCCESS;
json_object* jobj_temp = NULL;
// Get the I2C bus array index
ret = mraa_init_json_platform_get_index(jobj_i2c, I2C_KEY, INDEX_KEY, index, &pos, board->i2c_bus_count - 1);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the sysfs pin
ret = mraa_init_json_platform_get_pin(jobj_i2c, I2C_KEY, RAW_PIN_KEY, index, &sysfs_pin);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Setup the sda pin
ret = mraa_init_json_platform_get_index(jobj_i2c, I2C_KEY, SDAPIN_KEY, index, &pin,
board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->i2c_bus[pos].sda = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.i2c = 1;
board->pins[pin].i2c.pinmap = sysfs_pin;
board->i2c_bus[pos].sda = pin;
} else {
return ret;
}
// Setup the scl pin
ret = mraa_init_json_platform_get_index(jobj_i2c, I2C_KEY, SCLPIN_KEY, index, &pin,
board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->i2c_bus[pos].scl = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.i2c = 1;
board->pins[pin].i2c.pinmap = sysfs_pin;
board->i2c_bus[pos].scl = pin;
} else {
return ret;
}
board->i2c_bus[pos].bus_id = pos;
// check to see if this i2c is the default one
if (json_object_object_get_ex(jobj_i2c, DEFAULT_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_boolean)) {
syslog(LOG_ERR, "init_json_platform: Default I2C device key has an incorrect value");
return MRAA_ERROR_INVALID_RESOURCE;
}
if (json_object_get_boolean(jobj_temp)) {
board->def_i2c_bus = pos;
}
}
return MRAA_SUCCESS;
}
mraa_result_t
mraa_init_json_platform_pwm(json_object* jobj_pwm, mraa_board_t* board, int index)
{
int pos = 0;
int parent_id = 0;
int sysfs_pin = 0;
mraa_result_t ret = MRAA_SUCCESS;
// Get the index into the physical pin array
ret = mraa_init_json_platform_get_index(jobj_pwm, PWM_KEY, INDEX_KEY, index, &pos, board->phy_pin_count - 1);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the parent id
ret = mraa_init_json_platform_get_pin(jobj_pwm, PWM_KEY, CHIP_ID_KEY, index, &parent_id);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the sysfs pin
ret = mraa_init_json_platform_get_pin(jobj_pwm, PWM_KEY, RAW_PIN_KEY, index, &sysfs_pin);
if (ret != MRAA_SUCCESS) {
return ret;
}
board->pins[pos].capabilities.pwm = 1;
board->pins[pos].pwm.pinmap = sysfs_pin;
board->pins[pos].pwm.parent_id = parent_id;
return ret;
}
mraa_result_t
mraa_init_json_platform_spi(json_object* jobj_spi, mraa_board_t* board, int index)
{
int pos = 0;
int pin = 0;
int parent_id = 0;
json_object* jobj_temp = NULL;
mraa_result_t ret = MRAA_SUCCESS;
// Get the index into the physical pin array
ret = mraa_init_json_platform_get_index(jobj_spi, SPI_KEY, INDEX_KEY, index, &pos, board->spi_bus_count - 1);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the parent id
ret = mraa_init_json_platform_get_pin(jobj_spi, SPI_KEY, CHIP_ID_KEY, index, &parent_id);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Setup the clock pin
ret = mraa_init_json_platform_get_index(jobj_spi, SPI_KEY, CLOCK_KEY, index, &pin, board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->spi_bus[pos].sclk = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.spi = 1;
board->pins[pin].spi.parent_id = parent_id;
board->spi_bus[pos].sclk = pin;
} else {
return ret;
}
// Setup the MISO pin
ret = mraa_init_json_platform_get_index(jobj_spi, SPI_KEY, MISO_KEY, index, &pin, board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->spi_bus[pos].miso = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.spi = 1;
board->pins[pin].spi.parent_id = parent_id;
board->spi_bus[pos].miso = pin;
} else {
return ret;
}
// Setup the MOSI pin
ret = mraa_init_json_platform_get_index(jobj_spi, SPI_KEY, MOSI_KEY, index, &pin, board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->spi_bus[pos].mosi = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.spi = 1;
board->pins[pin].spi.parent_id = parent_id;
board->spi_bus[pos].mosi = pin;
} else {
return ret;
}
// Setup the CS pin
ret = mraa_init_json_platform_get_index(jobj_spi, SPI_KEY, CS_KEY, index, &pin, board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->spi_bus[pos].cs = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.spi = 1;
board->pins[pin].spi.parent_id = parent_id;
board->spi_bus[pos].cs = pin;
} else {
return ret;
}
// check to see if this SPI is the default one
if (json_object_object_get_ex(jobj_spi, DEFAULT_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_boolean)) {
syslog(LOG_ERR, "init_json_platform: Default I2C device key has an incorrect value");
return MRAA_ERROR_INVALID_RESOURCE;
}
if (json_object_get_boolean(jobj_temp)) {
board->def_spi_bus = pos;
}
}
return ret;
}
mraa_result_t
mraa_init_json_platform_uart(json_object* jobj_uart, mraa_board_t* board, int index)
{
json_object* jobj_temp = NULL;
mraa_result_t ret = MRAA_SUCCESS;
int pos = 0;
int pin = 0;
int sysfs_pin = 0;
int parent_id = 0;
int length = 0;
const char* temp_string = NULL;
// Get the index into the uart bus
ret = mraa_init_json_platform_get_index(jobj_uart, UART_KEY, INDEX_KEY, index, &pos,
board->uart_dev_count - 1);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the parent id
ret = mraa_init_json_platform_get_pin(jobj_uart, UART_KEY, CHIP_ID_KEY, index, &parent_id);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Get the sysfs pin
ret = mraa_init_json_platform_get_pin(jobj_uart, UART_KEY, RAW_PIN_KEY, index, &sysfs_pin);
if (ret != MRAA_SUCCESS) {
return ret;
}
// Setup the rx pin
ret = mraa_init_json_platform_get_index(jobj_uart, UART_KEY, RXPIN_KEY, index, &pin,
board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->uart_dev[pos].rx = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.uart = 1;
board->pins[pin].uart.pinmap = sysfs_pin;
board->pins[pin].uart.parent_id = parent_id;
board->uart_dev[pos].rx = pin;
} else {
return ret;
}
// Setup the TX pin
ret = mraa_init_json_platform_get_index(jobj_uart, UART_KEY, TXPIN_KEY, index, &pin,
board->phy_pin_count - 1);
if (ret == MRAA_ERROR_NO_DATA_AVAILABLE) {
board->uart_dev[pos].tx = -1;
} else if (ret == MRAA_SUCCESS) {
board->pins[pin].capabilities.uart = 1;
board->pins[pin].uart.pinmap = sysfs_pin;
board->pins[pin].uart.parent_id = parent_id;
board->uart_dev[pos].tx = pin;
} else {
return ret;
}
// Setup the path
if (json_object_object_get_ex(jobj_uart, UART_PATH_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_string)) {
syslog(LOG_ERR, "init_json_platform: UART Path at index: %d was not a string", index);
return MRAA_ERROR_NO_RESOURCES;
}
temp_string = json_object_get_string(jobj_temp);
if (temp_string == NULL || (length = strlen(temp_string)) == 0) {
syslog(LOG_ERR, "init_json_platform: UART Path at index: %d was empty", index);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
board->uart_dev[pos].device_path = (char*) calloc(length, sizeof(char));
strncpy(board->uart_dev[pos].device_path, temp_string, length);
} else {
syslog(LOG_ERR, "init_json_platform: UART config at index: %d needs a path", index);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
// If this element is supposed to be default set it.
if (json_object_object_get_ex(jobj_uart, DEFAULT_KEY, &jobj_temp)) {
if (!json_object_is_type(jobj_temp, json_type_boolean)) {
syslog(LOG_ERR, "init_json_platform: Default UART device key has an incorrect value");
return MRAA_ERROR_INVALID_RESOURCE;
}
if (json_object_get_boolean(jobj_temp)) {
board->def_uart_dev = pos;
}
}
return MRAA_SUCCESS;
}
mraa_result_t
mraa_init_json_platform_loop(json_object* jobj_platform, const char* obj_key, mraa_board_t* board, init_plat_func_t func)
{
mraa_result_t ret = MRAA_SUCCESS;
int i = 0, array_length = 0;
json_object *jobj_temp = NULL, *jobj_io = NULL;
if (json_object_object_get_ex(jobj_platform, obj_key, &jobj_temp)) {
array_length = json_object_array_length(jobj_temp);
for (i = 0; i < array_length; i++) {
// Get the json object at position i
jobj_io = json_object_array_get_idx(jobj_temp, i);
// Check to see it's the right type
if (!json_object_is_type(jobj_io, json_type_object)) {
syslog(LOG_ERR, "init_json_platform: One of more of the elements in the \"%s\" "
"array where not JSON objects",
obj_key);
return MRAA_ERROR_INVALID_RESOURCE;
}
ret = (*func)(jobj_io, board, i);
if (ret != MRAA_SUCCESS) {
return ret;
}
}
} else {
syslog(LOG_ERR, "init_json_platform: No \"%s\" info found in json file", obj_key);
ret = MRAA_ERROR_NO_DATA_AVAILABLE;
}
return ret;
}
mraa_result_t
mraa_init_json_platform_size_check(json_object* jobj_platform,
const char* obj_key,
mraa_board_t* board,
init_plat_func_t func,
int range)
{
json_object* jobj_temp = NULL;
mraa_result_t ret = MRAA_SUCCESS;
int array_length = 0;
if (json_object_object_get_ex(jobj_platform, obj_key, &jobj_temp)) {
// Make sure the value for the key is an array
if (!json_object_is_type(jobj_temp, json_type_array)) {
syslog(LOG_ERR, "init_json_platform: json key \"%s\" should be an array", obj_key);
return MRAA_ERROR_INVALID_RESOURCE;
}
// make sure we don't have more than our range
array_length = json_object_array_length(jobj_temp);
if (array_length > range) {
syslog(LOG_ERR,
"init_json_platform: The size of the %s array given was %d, max was: %d",
obj_key, array_length, range);
return MRAA_ERROR_INVALID_RESOURCE;
}
ret = mraa_init_json_platform_loop(jobj_platform, obj_key, board, func);
if (ret != MRAA_SUCCESS) {
return ret;
}
return MRAA_SUCCESS;
}
syslog(LOG_NOTICE, "init_json_platform: %s wasn't found in the json file", obj_key);
return MRAA_ERROR_NO_DATA_AVAILABLE;
}
mraa_result_t
mraa_init_json_platform(const char* platform_json)
{
mraa_result_t ret = MRAA_SUCCESS;
char* buffer = NULL;
struct stat st;
int file_lock = 0, array_length = 0, i = 0;
json_object *jobj_platform = NULL, *jobj_temp = NULL;
mraa_board_t* board = NULL;
// Try to lock the file for use
if ((file_lock = open(platform_json, O_RDONLY)) == -1) {
syslog(LOG_ERR, "init_json_platform: Failed to open platform file");
return MRAA_ERROR_INVALID_RESOURCE;
}
if (fstat(file_lock, &st) != 0 || (!S_ISREG(st.st_mode))) {
syslog(LOG_ERR, "init_json_platform: Failed to retrieve information about a file or the "
"file specified is not actually a file");
close(file_lock);
return MRAA_ERROR_INVALID_RESOURCE;
}
buffer = mmap(0, st.st_size, PROT_READ, MAP_SHARED, file_lock, 0);
close(file_lock);
if (buffer == MAP_FAILED) {
syslog(LOG_ERR, "init_json_platform: Failed to read platform file");
return MRAA_ERROR_INVALID_RESOURCE;
}
// Parse the json file
jobj_platform = json_tokener_parse(buffer);
// Allocate some memory for the board information
board = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
if (board == NULL) {
munmap(buffer, st.st_size);
return MRAA_ERROR_INVALID_HANDLE;
}
// Call our helper to go through and init our board for the "Platform" data
ret = mraa_init_json_platform_loop(jobj_platform, PLATFORM_KEY, board, mraa_init_json_platform_platform);
if (ret != MRAA_SUCCESS) {
goto unsuccessful;
}
// Setup the IO's with their labels
ret = mraa_init_json_platform_size_check(jobj_platform, IO_KEY, board,
mraa_init_json_platform_io, board->phy_pin_count);
if (ret != MRAA_SUCCESS) {
goto unsuccessful;
}
// Setup GPIO
ret = mraa_init_json_platform_size_check(jobj_platform, GPIO_KEY, board,
mraa_init_json_platform_gpio, board->phy_pin_count);
if (ret != MRAA_SUCCESS) {
goto unsuccessful;
}
// Setup AIO
ret = mraa_init_json_platform_size_check(jobj_platform, AIO_KEY, board,
mraa_init_json_platform_aio, board->phy_pin_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
goto unsuccessful;
}
// Setup SPI
ret = mraa_init_json_platform_size_check(jobj_platform, SPI_KEY, board,
mraa_init_json_platform_spi, board->spi_bus_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
goto unsuccessful;
}
// Setup I2C
ret = mraa_init_json_platform_size_check(jobj_platform, I2C_KEY, board,
mraa_init_json_platform_i2c, board->i2c_bus_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
goto unsuccessful;
}
// Setup UART
ret = mraa_init_json_platform_size_check(jobj_platform, UART_KEY, board,
mraa_init_json_platform_uart, board->uart_dev_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
for (i = 0; i < board->uart_dev_count; i++) {
if (board->uart_dev[i].device_path != NULL) {
free(plat->uart_dev[i].device_path);
}
}
goto unsuccessful;
}
// Setup PWM
ret = mraa_init_json_platform_size_check(jobj_platform, PWM_KEY, board,
mraa_init_json_platform_pwm, board->phy_pin_count);
if (ret != MRAA_SUCCESS && ret != MRAA_ERROR_NO_DATA_AVAILABLE) {
goto unsuccessful;
}
// Free the old empty platform
free(plat);
// Set the new one in it's place
plat = board;
platform_name = plat->platform_name;
// We made it to the end without anything going wrong, just cleanup
ret = MRAA_SUCCESS;
syslog(LOG_NOTICE, "init_json_platform: Platform %s initialised via json", platform_name);
goto cleanup;
unsuccessful:
free(board->platform_name);
free(board->pins);
free(board->adv_func);
free(board);
cleanup:
json_object_put(jobj_platform);
munmap(buffer, st.st_size);
return ret;
}

3
src/mock/CMakeLists.txt Normal file
View File

@@ -0,0 +1,3 @@
message (INFO " - Adding mock platform")
set (mraa_LIB_PLAT_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO}
${mraa_LIB_MOCK_SRCS_NOAUTO} PARENT_SCOPE)

43
src/mock/mock.c Normal file
View File

@@ -0,0 +1,43 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include "mraa_internal.h"
#include "mock/mock_board.h"
mraa_platform_t
mraa_mock_platform()
{
mraa_platform_t platform_type = MRAA_MOCK_PLATFORM;
plat = mraa_mock_board();
if (plat == NULL) {
syslog(LOG_ERR, "Was not able to initialize mock platform");
return MRAA_ERROR_PLATFORM_NOT_INITIALISED;
}
return platform_type;
}

136
src/mock/mock_board.c Normal file
View File

@@ -0,0 +1,136 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "mock/mock_board.h"
#include "mock/mock_board_gpio.h"
#include "mock/mock_board_aio.h"
#include "mock/mock_board_i2c.h"
#define PLATFORM_NAME "MRAA mock platform"
mraa_board_t*
mraa_mock_board()
{
mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
if (b == NULL) {
return NULL;
}
// General board definitions
b->platform_name = PLATFORM_NAME;
b->phy_pin_count = MRAA_MOCK_PINCOUNT;
b->gpio_count = 1;
b->aio_count = 1;
b->adc_raw = 12;
b->adc_supported = 10;
b->i2c_bus_count = 1;
b->i2c_bus[0].bus_id = 0;
b->i2c_bus[0].sda = 2;
b->i2c_bus[0].scl = 3;
b->def_i2c_bus = b->i2c_bus[0].bus_id;
b->spi_bus_count = 0;
b->pwm_default_period = 0;
b->pwm_max_period = 0;
b->pwm_min_period = 0;
b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * MRAA_MOCK_PINCOUNT);
if (b->pins == NULL) {
goto error;
}
b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
if (b->adv_func == NULL) {
free(b->pins);
goto error;
}
// Replace functions
b->adv_func->gpio_init_internal_replace = &mraa_mock_gpio_init_internal_replace;
b->adv_func->gpio_close_replace = &mraa_mock_gpio_close_replace;
b->adv_func->gpio_dir_replace = &mraa_mock_gpio_dir_replace;
b->adv_func->gpio_read_dir_replace = &mraa_mock_gpio_read_dir_replace;
b->adv_func->gpio_read_replace = &mraa_mock_gpio_read_replace;
b->adv_func->gpio_write_replace = &mraa_mock_gpio_write_replace;
b->adv_func->gpio_edge_mode_replace = &mraa_mock_gpio_edge_mode_replace;
b->adv_func->gpio_isr_replace = &mraa_mock_gpio_isr_replace;
b->adv_func->gpio_isr_exit_replace = &mraa_mock_gpio_isr_exit_replace;
b->adv_func->gpio_mode_replace = &mraa_mock_gpio_mode_replace;
b->adv_func->aio_init_internal_replace = &mraa_mock_aio_init_internal_replace;
b->adv_func->aio_close_replace = &mraa_mock_aio_close_replace;
b->adv_func->aio_read_replace = &mraa_mock_aio_read_replace;
b->adv_func->i2c_init_bus_replace = &mraa_mock_i2c_init_bus_replace;
b->adv_func->i2c_stop_replace = &mraa_mock_i2c_stop_replace;
b->adv_func->i2c_set_frequency_replace = &mraa_mock_i2c_set_frequency_replace;
b->adv_func->i2c_address_replace = &mraa_mock_i2c_address_replace;
b->adv_func->i2c_read_replace = &mraa_mock_i2c_read_replace;
b->adv_func->i2c_read_byte_replace = &mraa_mock_i2c_read_byte_replace;
b->adv_func->i2c_read_byte_data_replace = &mraa_mock_i2c_read_byte_data_replace;
b->adv_func->i2c_read_bytes_data_replace = &mraa_mock_i2c_read_bytes_data_replace;
b->adv_func->i2c_read_word_data_replace = &mraa_mock_i2c_read_word_data_replace;
b->adv_func->i2c_write_replace = &mraa_mock_i2c_write_replace;
b->adv_func->i2c_write_byte_replace = &mraa_mock_i2c_write_byte_replace;
b->adv_func->i2c_write_byte_data_replace = &mraa_mock_i2c_write_byte_data_replace;
b->adv_func->i2c_write_word_data_replace = &mraa_mock_i2c_write_word_data_replace;
// Pin definitions
int pos = 0;
strncpy(b->pins[pos].name, "GPIO0", 8);
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 0;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "ADC0", 8);
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 1, 0 };
b->pins[pos].aio.pinmap = 0;
b->pins[pos].aio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "I2C0SDA", 8);
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].i2c.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
pos++;
strncpy(b->pins[pos].name, "I2C0SCL", 8);
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].i2c.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
pos++;
return b;
error:
syslog(LOG_CRIT, "MRAA mock: Platform failed to initialise");
free(b);
return NULL;
}

52
src/mock/mock_board_aio.c Normal file
View File

@@ -0,0 +1,52 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "mock/mock_board_aio.h"
mraa_result_t
mraa_mock_aio_init_internal_replace(mraa_aio_context dev, int pin)
{
dev->channel = pin;
return MRAA_SUCCESS;
}
mraa_result_t
mraa_mock_aio_close_replace(mraa_aio_context dev)
{
free(dev);
return MRAA_SUCCESS;
}
int
mraa_mock_aio_read_replace(mraa_aio_context dev)
{
// return some random number between 0 and max value, based on the resolution
int max_value = (1 << dev->value_bit) - 1;
srand(time(NULL));
return rand() % max_value;
}

130
src/mock/mock_board_gpio.c Normal file
View File

@@ -0,0 +1,130 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "mock/mock_board_gpio.h"
mraa_result_t
mraa_mock_gpio_init_internal_replace(mraa_gpio_context dev, int pin)
{
dev->value_fp = -1;
dev->isr_value_fp = -1;
dev->isr_thread_terminating = 0;
dev->phy_pin = pin;
// We are always the owner
dev->owner = 1;
#ifndef HAVE_PTHREAD_CANCEL
dev->isr_control_pipe[0] = dev->isr_control_pipe[1] = -1;
#endif
// We start as INPUT and LOW
dev->mock_dir = MRAA_GPIO_IN;
dev->mock_state = 0;
return MRAA_SUCCESS;
}
mraa_result_t
mraa_mock_gpio_close_replace(mraa_gpio_context dev)
{
free(dev);
return MRAA_SUCCESS;
}
mraa_result_t
mraa_mock_gpio_dir_replace(mraa_gpio_context dev, mraa_gpio_dir_t dir)
{
switch (dir) {
case MRAA_GPIO_OUT_HIGH:
dev->mock_dir = MRAA_GPIO_OUT;
return mraa_gpio_write(dev, 1);
case MRAA_GPIO_OUT_LOW:
dev->mock_dir = MRAA_GPIO_OUT;
return mraa_gpio_write(dev, 0);
case MRAA_GPIO_IN:
case MRAA_GPIO_OUT:
dev->mock_dir = dir;
return MRAA_SUCCESS;
default:
syslog(LOG_ERR, "gpio: dir: invalid direction '%d' to set", (int) dir);
return MRAA_ERROR_INVALID_PARAMETER;
}
}
mraa_result_t
mraa_mock_gpio_read_dir_replace(mraa_gpio_context dev, mraa_gpio_dir_t* dir)
{
*dir = dev->mock_dir;
return MRAA_SUCCESS;
}
int
mraa_mock_gpio_read_replace(mraa_gpio_context dev)
{
return dev->mock_state;
}
mraa_result_t
mraa_mock_gpio_write_replace(mraa_gpio_context dev, int value)
{
if ((value < 0) || (value > 1)) {
syslog(LOG_ERR, "gpio: write: incorrect value '%d' passed to write(), must be 0 or 1", value);
return MRAA_ERROR_INVALID_PARAMETER;
}
if (dev->mock_dir == MRAA_GPIO_IN) {
syslog(LOG_ERR, "gpio: write: cannot write to pin set to INPUT");
return MRAA_ERROR_INVALID_RESOURCE;
}
dev->mock_state = value;
return MRAA_SUCCESS;
}
mraa_result_t
mraa_mock_gpio_edge_mode_replace(mraa_gpio_context dev, mraa_gpio_edge_t mode)
{
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
mraa_result_t
mraa_mock_gpio_isr_replace(mraa_gpio_context dev, mraa_gpio_edge_t mode, void (*fptr)(void*), void* args)
{
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
mraa_result_t
mraa_mock_gpio_isr_exit_replace(mraa_gpio_context dev)
{
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}
mraa_result_t
mraa_mock_gpio_mode_replace(mraa_gpio_context dev, mraa_gpio_mode_t mode)
{
return MRAA_ERROR_FEATURE_NOT_IMPLEMENTED;
}

246
src/mock/mock_board_i2c.c Normal file
View File

@@ -0,0 +1,246 @@
/*
* Author: Alex Tereschenko <alext.mkrs@gmail.com>
* Copyright (c) 2016 Alex Tereschenko.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "mock/mock_board.h"
#include "mock/mock_board_gpio.h"
#include "mock/mock_board_aio.h"
#include "mock/mock_board_i2c.h"
mraa_result_t
mraa_mock_i2c_init_bus_replace(mraa_i2c_context dev)
{
dev->mock_dev_addr = MOCK_I2C_DEV_ADDR;
dev->mock_dev_data_len = MOCK_I2C_DEV_DATA_LEN;
dev->mock_dev_data = (uint8_t*) calloc(dev->mock_dev_data_len, sizeof(uint8_t));
if (dev->mock_dev_data == NULL) {
syslog(LOG_CRIT, "i2c%i: init: Failed to allocate memory for mock device context", dev->busnum);
return MRAA_ERROR_NO_RESOURCES;
}
// Set initial values for mock device "data registers"
memset(dev->mock_dev_data, MOCK_I2C_DEV_DATA_INIT_BYTE, dev->mock_dev_data_len);
return MRAA_SUCCESS;
}
mraa_result_t
mraa_mock_i2c_stop_replace(mraa_i2c_context dev)
{
free(dev->mock_dev_data);
free(dev);
return MRAA_SUCCESS;
}
mraa_result_t
mraa_mock_i2c_set_frequency_replace(mraa_i2c_context dev, mraa_i2c_mode_t mode)
{
switch (mode) {
case MRAA_I2C_STD:
case MRAA_I2C_FAST:
case MRAA_I2C_HIGH:
return MRAA_SUCCESS;
break;
default:
syslog(LOG_ERR, "i2c%i: set_frequency: Invalid I2C frequency selected", dev->busnum);
return MRAA_ERROR_INVALID_PARAMETER;
}
}
mraa_result_t
mraa_mock_i2c_address_replace(mraa_i2c_context dev, uint8_t addr)
{
const uint8_t MAX_I2C_ADDR = 0x7F;
if (addr > MAX_I2C_ADDR) {
syslog(LOG_ERR, "i2c%i: address: Slave address 0x%X is bigger than max supported (0x%X)",
dev->busnum, addr, MAX_I2C_ADDR);
return MRAA_ERROR_INVALID_PARAMETER;
}
return MRAA_SUCCESS;
}
int
mraa_mock_i2c_read_replace(mraa_i2c_context dev, uint8_t* data, int length)
{
if (dev->addr == dev->mock_dev_addr) {
// Account for possible mismatch between length and our "register" range
int copy_len = (length <= dev->mock_dev_data_len) ? length : dev->mock_dev_data_len;
memcpy(data, dev->mock_dev_data, copy_len);
return copy_len;
} else {
// Not our mock device
return -1;
}
}
int
mraa_mock_i2c_read_byte_replace(mraa_i2c_context dev)
{
if (dev->addr == dev->mock_dev_addr) {
return dev->mock_dev_data[0];
} else {
// Not our mock device
return -1;
}
}
int
mraa_mock_i2c_read_byte_data_replace(mraa_i2c_context dev, uint8_t command)
{
if (dev->addr == dev->mock_dev_addr) {
if (command < dev->mock_dev_data_len) {
return dev->mock_dev_data[command];
} else {
syslog(LOG_ERR,
"i2c%i: read_byte_data: Command/register number is too big, max is 0x%X",
dev->busnum, dev->mock_dev_data_len - 1);
return -1;
}
} else {
// Not our mock device
return -1;
}
}
int
mraa_mock_i2c_read_bytes_data_replace(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length)
{
if (dev->addr == dev->mock_dev_addr) {
if (command >= dev->mock_dev_data_len) {
syslog(LOG_ERR,
"i2c%i: read_bytes_data: Command/register number is too big, max is 0x%X",
dev->busnum, dev->mock_dev_data_len - 1);
return -1;
}
if (length <= 0) {
syslog(LOG_ERR,
"i2c%i: read_bytes_data: Length to read is invalid (%d), cannot proceed",
dev->busnum, length);
return -1;
}
int i = 0;
// We read requested length, but only up to mock device data length
for (i = command; (i < (command + length)) && (i < dev->mock_dev_data_len); ++i) {
data[i - command] = dev->mock_dev_data[i];
}
return (i - command);
} else {
// Not our mock device
return -1;
}
}
int
mraa_mock_i2c_read_word_data_replace(mraa_i2c_context dev, uint8_t command)
{
if (dev->addr == dev->mock_dev_addr) {
if ((command + 1) < dev->mock_dev_data_len) {
// Let's say the device is big-endian
int result = (dev->mock_dev_data[command] << 8) + dev->mock_dev_data[command + 1];
return result;
} else {
syslog(LOG_ERR,
"i2c%i: read_word_data: Command/register number is too big, max is 0x%X",
dev->busnum, dev->mock_dev_data_len - 2);
return -1;
}
} else {
// Not our mock device
return -1;
}
}
mraa_result_t
mraa_mock_i2c_write_replace(mraa_i2c_context dev, const uint8_t* data, int length)
{
if (dev->addr == dev->mock_dev_addr) {
int copy_len = (length <= dev->mock_dev_data_len) ? length : dev->mock_dev_data_len;
memcpy(dev->mock_dev_data, data, copy_len);
return MRAA_SUCCESS;
} else {
// Not our mock device
return MRAA_ERROR_UNSPECIFIED;
}
}
mraa_result_t
mraa_mock_i2c_write_byte_replace(mraa_i2c_context dev, const uint8_t data)
{
if (dev->addr == dev->mock_dev_addr) {
dev->mock_dev_data[0] = data;
return MRAA_SUCCESS;
} else {
// Not our mock device
return MRAA_ERROR_UNSPECIFIED;
}
}
mraa_result_t
mraa_mock_i2c_write_byte_data_replace(mraa_i2c_context dev, const uint8_t data, const uint8_t command)
{
if (dev->addr == dev->mock_dev_addr) {
if (command < dev->mock_dev_data_len) {
dev->mock_dev_data[command] = data;
return MRAA_SUCCESS;
} else {
syslog(LOG_ERR,
"i2c%i: write_byte_data: Command/register number is too big, max is 0x%X",
dev->busnum, dev->mock_dev_data_len - 1);
return MRAA_ERROR_UNSPECIFIED;
}
} else {
// Not our mock device
return MRAA_ERROR_UNSPECIFIED;
}
}
mraa_result_t
mraa_mock_i2c_write_word_data_replace(mraa_i2c_context dev, const uint16_t data, const uint8_t command)
{
if (dev->addr == dev->mock_dev_addr) {
if ((command + 1) < dev->mock_dev_data_len) {
// Let's say the device is big-endian
dev->mock_dev_data[command] = (data & 0xFF00) >> 8;
dev->mock_dev_data[command + 1] = data & 0x00FF;
return MRAA_SUCCESS;
} else {
syslog(LOG_ERR,
"i2c%i: write_word_data: Command/register number is too big, max is 0x%X",
dev->busnum, dev->mock_dev_data_len - 2);
return MRAA_ERROR_UNSPECIFIED;
}
} else {
// Not our mock device
return MRAA_ERROR_UNSPECIFIED;
}
}

View File

@@ -36,15 +36,15 @@
#include <glob.h>
#include <ftw.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <limits.h>
#if defined(IMRAA)
#include <json-c/json.h>
#include <sys/stat.h>
@@ -61,13 +61,14 @@
#include "spi.h"
#include "uart.h"
#define IIO_DEVICE_WILDCARD "iio:device*"
mraa_board_t* plat = NULL;
mraa_iio_info_t* plat_iio = NULL;
mraa_lang_func_t* lang_func = NULL;
static char* platform_name = NULL;
char* platform_name = NULL;
static char* platform_long_name = NULL;
static int num_i2c_devices = 0;
@@ -101,7 +102,9 @@ imraa_init()
if (plat != NULL) {
return MRAA_SUCCESS;
}
char* env_var;
mraa_result_t ret;
mraa_platform_t platform_type = MRAA_NULL_PLATFORM;
uid_t proc_euid = geteuid();
struct passwd* proc_user = getpwuid(proc_euid);
@@ -115,16 +118,34 @@ imraa_init()
syslog(LOG_NOTICE, "libmraa version %s initialised by user '%s' with EUID %d",
mraa_get_version(), (proc_user != NULL) ? proc_user->pw_name : "<unknown>", proc_euid);
mraa_platform_t platform_type;
// Check to see if the enviroment variable has been set
env_var = getenv(MRAA_JSONPLAT_ENV_VAR);
if (env_var != NULL) {
// We only care about success, the init will write to syslog if things went wrong
switch ((ret = mraa_init_json_platform(env_var))) {
case MRAA_SUCCESS:
platform_type = plat->platform_type;
break;
default:
syslog(LOG_NOTICE, "libmraa was unable to initialise a platform from json");
}
}
// Not an else because if the env var didn't load what we wanted maybe we can still load something
if (platform_type == MRAA_NULL_PLATFORM) {
#if defined(X86PLAT)
// Use runtime x86 platform detection
platform_type = mraa_x86_platform();
// Use runtime x86 platform detection
platform_type = mraa_x86_platform();
#elif defined(ARMPLAT)
// Use runtime ARM platform detection
platform_type = mraa_arm_platform();
// Use runtime ARM platform detection
platform_type = mraa_arm_platform();
#elif defined(MOCKPLAT)
// Use mock platform
platform_type = mraa_mock_platform();
#else
#error mraa_ARCH NOTHING
#endif
}
if (plat != NULL) {
plat->platform_type = platform_type;
@@ -205,6 +226,7 @@ mraa_init()
void
mraa_deinit()
{
int i = 0;
if (plat != NULL) {
if (plat->pins != NULL) {
free(plat->pins);
@@ -216,6 +238,19 @@ mraa_deinit()
}
free(sub_plat);
}
#if defined(JSONPLAT)
if (plat->platform_type == MRAA_JSON_PLATFORM) {
// Free the platform name
free(plat->platform_name);
// Free the UART device path
for (i = 0; i < plat->uart_dev_count; i++) {
if (plat->uart_dev[i].device_path != NULL) {
free(plat->uart_dev[i].device_path);
}
}
}
#endif
free(plat);
}
@@ -545,35 +580,35 @@ mraa_pin_mode_test(int pin, mraa_pinmodes_t mode)
switch (mode) {
case MRAA_PIN_VALID:
if (current_plat->pins[pin].capabilites.valid == 1)
if (current_plat->pins[pin].capabilities.valid == 1)
return 1;
break;
case MRAA_PIN_GPIO:
if (current_plat->pins[pin].capabilites.gpio == 1)
if (current_plat->pins[pin].capabilities.gpio == 1)
return 1;
break;
case MRAA_PIN_PWM:
if (current_plat->pins[pin].capabilites.pwm == 1)
if (current_plat->pins[pin].capabilities.pwm == 1)
return 1;
break;
case MRAA_PIN_FAST_GPIO:
if (current_plat->pins[pin].capabilites.fast_gpio == 1)
if (current_plat->pins[pin].capabilities.fast_gpio == 1)
return 1;
break;
case MRAA_PIN_SPI:
if (current_plat->pins[pin].capabilites.spi == 1)
if (current_plat->pins[pin].capabilities.spi == 1)
return 1;
break;
case MRAA_PIN_I2C:
if (current_plat->pins[pin].capabilites.i2c == 1)
if (current_plat->pins[pin].capabilities.i2c == 1)
return 1;
break;
case MRAA_PIN_AIO:
if (current_plat->pins[pin].capabilites.aio == 1)
if (current_plat->pins[pin].capabilities.aio == 1)
return 1;
break;
case MRAA_PIN_UART:
if (current_plat->pins[pin].capabilites.uart == 1)
if (current_plat->pins[pin].capabilities.uart == 1)
return 1;
break;
default:
@@ -1234,3 +1269,12 @@ mraa_init_io(const char* desc)
syslog(LOG_ERR, "mraa_init_io: Invalid IO type given.");
return NULL;
}
#ifndef JSONPLAT
mraa_result_t
mraa_init_json_platform(const char* desc)
{
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
}
#endif

View File

@@ -233,7 +233,7 @@ mraa_pwm_init(int pin)
syslog(LOG_ERR, "pwm_init: pin %i beyond platform definition", pin);
return NULL;
}
if (board->pins[pin].capabilites.pwm != 1) {
if (board->pins[pin].capabilities.pwm != 1) {
syslog(LOG_ERR, "pwm_init: pin %i not capable of pwm", pin);
return NULL;
}
@@ -249,28 +249,6 @@ mraa_pwm_init(int pin)
return NULL;
}
if (board->pins[pin].capabilites.gpio == 1) {
// This deserves more investigation
mraa_gpio_context mux_i;
mux_i = mraa_gpio_init_raw(board->pins[pin].gpio.pinmap);
if (mux_i == NULL) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_init", pin);
return NULL;
}
if (mraa_gpio_dir(mux_i, MRAA_GPIO_OUT) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_dir", pin);
return NULL;
}
if (mraa_gpio_write(mux_i, 1) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_write", pin);
return NULL;
}
if (mraa_gpio_close(mux_i) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_close", pin);
return NULL;
}
}
if (board->pins[pin].pwm.mux_total > 0) {
if (mraa_setup_mux_mapped(board->pins[pin].pwm) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: Failed to set-up pwm%i multiplexer", pin);

View File

@@ -6,7 +6,7 @@ if (PYTHON2_LIBRARY)
swig_add_module (python2-mraa python mraa2.i ../mraapy.c)
swig_link_libraries (python2-mraa ${PYTHON2_LIBRARIES} mraa)
target_include_directories(${SWIG_MODULE_python2-mraa_REAL_NAME}
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/../.."
@@ -20,7 +20,7 @@ if (PYTHON2_LIBRARY)
add_dependencies (${SWIG_MODULE_python2-mraa_REAL_NAME} common_hpp_doc_i)
add_custom_target (pydoc
pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
python2 /usr/bin/pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with pydoc" VERBATIM
)
@@ -31,7 +31,7 @@ if (PYTHON2_LIBRARY)
COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND}"
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa.so
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/mraa.py
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON2_PACKAGES_PATH})
endif()

View File

@@ -13,12 +13,26 @@ if (PYTHON3_LIBRARY)
"${PYTHON3_INCLUDE_DIR}"
)
if (DOXYGEN_FOUND AND PYTHON3_EXECUTABLE)
foreach (_file ${DOCCLASSES})
add_dependencies (${SWIG_MODULE_python3-mraa_REAL_NAME} ${_file}class_doc_i)
endforeach ()
add_dependencies (${SWIG_MODULE_python3-mraa_REAL_NAME} common_hpp_doc_i)
add_custom_target (pydoc3
python3 /usr/bin/pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with pydoc" VERBATIM
)
endif ()
set_target_properties (${SWIG_MODULE_python3-mraa_REAL_NAME} PROPERTIES
OUTPUT_NAME _mraa
COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND}"
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa.so
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/mraa.py
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON3_PACKAGES_PATH})
endif ()

View File

@@ -25,8 +25,17 @@
#include <stdlib.h>
#include <string.h>
#if defined(MSYS)
#define __USE_LINUX_IOCTL_DEFS
#endif
#include <sys/ioctl.h>
#if defined(MSYS)
// There's no spidev.h on MSYS, so we need to provide our own,
// and only *after* including ioctl.h as that one contains prerequisites.
#include "linux/spi_kernel_headers.h"
#else
#include <linux/spi/spidev.h>
#endif
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

View File

@@ -102,10 +102,12 @@ uint2speed(unsigned int speed)
return B2500000;
case 3000000:
return B3000000;
#if !defined(MSYS)
case 3500000:
return B3500000;
case 4000000:
return B4000000;
#endif
default:
// if we are here, then an unsupported baudrate was selected.
return 0;

View File

@@ -1063,14 +1063,14 @@ mraa_ftdi_ft4222()
// I2c pins (these are virtual, entries are required to configure i2c layer)
// We currently assume that GPIO 0/1 are reserved for i2c operation
strncpy(sub_plat->pins[pinIndex].name, "IGPIO0/SCL0", MRAA_PIN_NAME_SIZE);
sub_plat->pins[pinIndex].capabilites = pinCapsI2cGpio;
sub_plat->pins[pinIndex].capabilities = pinCapsI2cGpio;
sub_plat->pins[pinIndex].gpio.pinmap = pinIndex;
sub_plat->pins[pinIndex].gpio.mux_total = 0;
sub_plat->pins[pinIndex].i2c.mux_total = 0;
sub_plat->i2c_bus[bus].scl = pinIndex;
pinIndex++;
strncpy(sub_plat->pins[pinIndex].name, "IGPIO1/SDA0", MRAA_PIN_NAME_SIZE);
sub_plat->pins[pinIndex].capabilites = pinCapsI2cGpio;
sub_plat->pins[pinIndex].capabilities = pinCapsI2cGpio;
sub_plat->pins[pinIndex].gpio.pinmap = pinIndex;
sub_plat->pins[pinIndex].gpio.mux_total = 0;
sub_plat->pins[pinIndex].i2c.mux_total = 0;
@@ -1079,12 +1079,12 @@ mraa_ftdi_ft4222()
// FTDI4222 gpio
strncpy(sub_plat->pins[pinIndex].name, "INT-GPIO2", MRAA_PIN_NAME_SIZE);
sub_plat->pins[pinIndex].capabilites = pinCapsGpio;
sub_plat->pins[pinIndex].capabilities = pinCapsGpio;
sub_plat->pins[pinIndex].gpio.pinmap = pinIndex;
sub_plat->pins[pinIndex].gpio.mux_total = 0;
pinIndex++;
strncpy(sub_plat->pins[pinIndex].name, "INT-GPIO3", MRAA_PIN_NAME_SIZE);
sub_plat->pins[pinIndex].capabilites = pinCapsGpio;
sub_plat->pins[pinIndex].capabilities = pinCapsGpio;
sub_plat->pins[pinIndex].gpio.pinmap = pinIndex;
sub_plat->pins[pinIndex].gpio.mux_total = 0;
pinIndex++;
@@ -1093,7 +1093,7 @@ mraa_ftdi_ft4222()
int i;
for (i = 0; i < numI2cGpioExpanderPins; ++i) {
snprintf(sub_plat->pins[pinIndex].name, MRAA_PIN_NAME_SIZE, "EXP-GPIO%d", i);
sub_plat->pins[pinIndex].capabilites = pinCapsGpio;
sub_plat->pins[pinIndex].capabilities = pinCapsGpio;
sub_plat->pins[pinIndex].gpio.pinmap = pinIndex;
sub_plat->pins[pinIndex].gpio.mux_total = 0;
pinIndex++;
@@ -1104,11 +1104,11 @@ mraa_ftdi_ft4222()
sub_plat->i2c_bus[bus].bus_id = bus;
sub_plat->pins[pinIndex].i2c.mux_total = 0;
snprintf(sub_plat->pins[pinIndex].name, MRAA_PIN_NAME_SIZE, "SDA%d", bus);
sub_plat->pins[pinIndex].capabilites = pinCapsI2c;
sub_plat->pins[pinIndex].capabilities = pinCapsI2c;
sub_plat->i2c_bus[bus].sda = pinIndex;
pinIndex++;
snprintf(sub_plat->pins[pinIndex].name, MRAA_PIN_NAME_SIZE, "SCL%d", bus);
sub_plat->pins[pinIndex].capabilites = pinCapsI2c;
sub_plat->pins[pinIndex].capabilities = pinCapsI2c;
sub_plat->pins[pinIndex].i2c.mux_total = 0;
sub_plat->i2c_bus[bus].scl = pinIndex;
pinIndex++;

View File

@@ -61,32 +61,32 @@ mraa_intel_cherryhills()
int pos = 0;
//Physical header where these pins are: J3E5
strncpy(b->pins[pos].name, "GSUS6", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 416;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "GSUS8", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 409;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "GSUS7", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 414;
b->pins[pos].gpio.mux_total = 0;
pos++;
//Physical header where these pins are: J3E3
strncpy(b->pins[pos].name, "GSUS0", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 406;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "GSUS1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 410;
b->pins[pos].gpio.mux_total = 0;
pos++;

View File

@@ -64,63 +64,63 @@ mraa_intel_de3815()
}
strncpy(b->pins[0].name, "1.8v", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "GND", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "HDMIcec", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[3].name, "DMICclk", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[4].name, "3.3v", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[5].name, "DMICda", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[6].name, "Key", 8);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[7].name, "SMB-A", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[8].name, "5v", 8);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[9].name, "SCI", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[10].name, "PWM0", 8);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[10].pwm.pinmap = 0;
b->pins[10].pwm.parent_id = 0;
b->pins[10].pwm.mux_total = 0;
strncpy(b->pins[11].name, "PWM1", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 0, 1, 0, 0, 0, 0, 0 };
b->pins[11].pwm.pinmap = 0;
b->pins[11].pwm.parent_id = 1;
b->pins[11].pwm.mux_total = 0;
strncpy(b->pins[12].name, "I2C0SCL", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[12].i2c.pinmap = 1;
b->pins[12].i2c.mux_total = 0;
strncpy(b->pins[13].name, "I2C0SDA", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[13].i2c.pinmap = 1;
b->pins[13].i2c.mux_total = 0;
strncpy(b->pins[14].name, "I2C1SCL", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[14].i2c.pinmap = 1;
b->pins[14].i2c.mux_total = 0;
strncpy(b->pins[15].name, "I2C1SDA", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[15].i2c.pinmap = 1;
b->pins[15].i2c.mux_total = 0;
strncpy(b->pins[16].name, "SMB_CLK", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[17].name, "SMB_SDA", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->i2c_bus_count = 0;
int i2c_num = -1;

View File

@@ -404,7 +404,7 @@ mraa_intel_edison_pwm_init_pre(int pin)
return MRAA_ERROR_INVALID_RESOURCE;
}
if (!plat->pins[pin].capabilites.pwm) {
if (!plat->pins[pin].capabilities.pwm) {
return MRAA_ERROR_INVALID_RESOURCE;
}
@@ -841,7 +841,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
int pos = 0;
strncpy(b->pins[pos].name, "J17-1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 182;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 2;
@@ -850,27 +850,27 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J17-2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-3", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-4", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-5", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 135;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J17-6", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-7", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 27;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
@@ -878,7 +878,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J17-8", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 20;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
@@ -886,7 +886,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J17-9", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 28;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
@@ -894,7 +894,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J17-10", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 111;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
@@ -902,7 +902,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J17-11", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 109;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
@@ -910,25 +910,25 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J17-12", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 115;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
b->pins[pos].spi.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J17-13", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J17-14", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 128;
b->pins[pos].gpio.parent_id = 0;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 , 0};
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 , 0};
b->pins[pos].gpio.pinmap = 13;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 1;
@@ -937,22 +937,22 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 165;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-3", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-4", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-5", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-6", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 19;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 1;
@@ -960,7 +960,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-7", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 12;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 0;
@@ -969,7 +969,7 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-8", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 183;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 3;
@@ -977,18 +977,18 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
b->pins[pos].pwm.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-9", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J18-10", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 110;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
b->pins[pos].spi.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-11", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 114;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].spi.pinmap = 5;
@@ -996,12 +996,12 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-12", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 129;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J18-13", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 130;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -1010,41 +1010,41 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J18-14", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-3", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-4", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 44;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-5", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 46;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-6", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 48;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-7", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J19-8", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 131;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -1053,98 +1053,98 @@ mraa_intel_edison_miniboard(mraa_board_t* b)
pos++;
strncpy(b->pins[pos].name, "J19-9", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 14;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-10", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 40;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-11", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 43;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-12", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 77;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-13", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 82;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J19-14", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 83;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J20-2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J20-3", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "J20-4", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 45;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-5", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 47;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-6", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 49;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-7", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 15;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-8", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 84;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-9", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 42;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-10", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 41;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-11", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 78;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-12", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 79;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-13", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 80;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "J20-14", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 81;
b->pins[pos].gpio.mux_total = 0;
pos++;
@@ -1325,7 +1325,7 @@ mraa_intel_edison_fab_c()
b->pwm_min_period = 1;
strncpy(b->pins[0].name, "IO0", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 130;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 1;
@@ -1337,7 +1337,7 @@ mraa_intel_edison_fab_c()
b->pins[0].uart.mux_total = 0;
strncpy(b->pins[1].name, "IO1", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 131;
b->pins[1].gpio.parent_id = 0;
b->pins[1].gpio.mux_total = 1;
@@ -1349,7 +1349,7 @@ mraa_intel_edison_fab_c()
b->pins[1].uart.mux_total = 0;
strncpy(b->pins[2].name, "IO2", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[2].gpio.pinmap = 128;
b->pins[2].gpio.parent_id = 0;
b->pins[2].gpio.mux_total = 1;
@@ -1358,7 +1358,7 @@ mraa_intel_edison_fab_c()
b->pins[2].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[3].name, "IO3", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[3].gpio.pinmap = 12;
b->pins[3].gpio.parent_id = 0;
b->pins[3].gpio.mux_total = 1;
@@ -1370,7 +1370,7 @@ mraa_intel_edison_fab_c()
b->pins[3].pwm.mux_total = 0;
strncpy(b->pins[4].name, "IO4", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].gpio.pinmap = 129;
b->pins[4].gpio.parent_id = 0;
b->pins[4].gpio.mux_total = 1;
@@ -1379,7 +1379,7 @@ mraa_intel_edison_fab_c()
b->pins[4].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[5].name, "IO5", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].gpio.pinmap = 13;
b->pins[5].gpio.parent_id = 0;
b->pins[5].gpio.mux_total = 1;
@@ -1391,7 +1391,7 @@ mraa_intel_edison_fab_c()
b->pins[5].pwm.mux_total = 0;
strncpy(b->pins[6].name, "IO6", 8);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].gpio.pinmap = 182;
b->pins[6].gpio.parent_id = 0;
b->pins[6].gpio.mux_total = 1;
@@ -1403,7 +1403,7 @@ mraa_intel_edison_fab_c()
b->pins[6].pwm.mux_total = 0;
strncpy(b->pins[7].name, "IO7", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 48;
b->pins[7].gpio.parent_id = 0;
b->pins[7].gpio.mux_total = 1;
@@ -1412,7 +1412,7 @@ mraa_intel_edison_fab_c()
b->pins[7].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[8].name, "IO8", 8);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 49;
b->pins[8].gpio.parent_id = 0;
b->pins[8].gpio.mux_total = 1;
@@ -1421,7 +1421,7 @@ mraa_intel_edison_fab_c()
b->pins[8].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[9].name, "IO9", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 183;
b->pins[9].gpio.parent_id = 0;
b->pins[9].gpio.mux_total = 1;
@@ -1433,7 +1433,7 @@ mraa_intel_edison_fab_c()
b->pins[9].pwm.mux_total = 0;
strncpy(b->pins[10].name, "IO10", 8);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[10].gpio.pinmap = 41;
b->pins[10].gpio.parent_id = 0;
b->pins[10].gpio.mux_total = 3;
@@ -1459,7 +1459,7 @@ mraa_intel_edison_fab_c()
b->pins[10].spi.mux[2].value = 1;
strncpy(b->pins[11].name, "IO11", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[11].gpio.pinmap = 43;
b->pins[11].gpio.parent_id = 0;
b->pins[11].gpio.mux_total = 3;
@@ -1485,7 +1485,7 @@ mraa_intel_edison_fab_c()
b->pins[11].spi.mux[2].value = 1;
strncpy(b->pins[12].name, "IO12", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].gpio.pinmap = 42;
b->pins[12].gpio.parent_id = 0;
b->pins[12].gpio.mux_total = 2;
@@ -1505,7 +1505,7 @@ mraa_intel_edison_fab_c()
b->pins[12].spi.mux[1].value = 1;
strncpy(b->pins[13].name, "IO13", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].gpio.pinmap = 40;
b->pins[13].gpio.parent_id = 0;
b->pins[13].gpio.mux_total = 2;
@@ -1525,7 +1525,7 @@ mraa_intel_edison_fab_c()
b->pins[13].spi.mux[1].value = 1;
strncpy(b->pins[14].name, "A0", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].aio.pinmap = 0;
b->pins[14].aio.mux_total = 2;
b->pins[14].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
@@ -1544,7 +1544,7 @@ mraa_intel_edison_fab_c()
b->pins[14].gpio.mux[1].value = 0;
strncpy(b->pins[15].name, "A1", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].aio.pinmap = 1;
b->pins[15].aio.mux_total = 2;
b->pins[15].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
@@ -1563,7 +1563,7 @@ mraa_intel_edison_fab_c()
b->pins[15].gpio.mux[1].value = 0;
strncpy(b->pins[16].name, "A2", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].aio.pinmap = 2;
b->pins[16].aio.mux_total = 2;
b->pins[16].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
@@ -1582,7 +1582,7 @@ mraa_intel_edison_fab_c()
b->pins[16].gpio.mux[1].value = 0;
strncpy(b->pins[17].name, "A3", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].aio.pinmap = 3;
b->pins[17].aio.mux_total = 2;
b->pins[17].aio.mux[0].pincmd = PINCMD_SET_DIRECTION;
@@ -1601,7 +1601,7 @@ mraa_intel_edison_fab_c()
b->pins[17].gpio.mux[1].value = 0;
strncpy(b->pins[18].name, "A4", 8);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].i2c.pinmap = 1;
b->pins[18].i2c.mux_total = 2;
b->pins[18].i2c.mux[0].pincmd = PINCMD_SET_DIRECTION;
@@ -1628,7 +1628,7 @@ mraa_intel_edison_fab_c()
b->pins[18].gpio.mux[1].value = 0;
strncpy(b->pins[19].name, "A5", 8);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].i2c.pinmap = 1;
b->pins[19].i2c.mux_total = 2;
b->pins[19].i2c.mux[0].pincmd = PINCMD_SET_DIRECTION;

View File

@@ -140,6 +140,34 @@ mraa_intel_galileo_g1_spi_lsbmode_replace(mraa_spi_context dev, mraa_boolean_t l
return MRAA_SUCCESS;
}
mraa_result_t
mraa_intel_galileo_g1_pwm_init_pre(int pin)
{
// Gen1 galileo has no kernel muxing for GPIOs/PWM so ends up with leakage
// on the PWM pins from the GPIO pins if not set to output high
if (plat->pins[pin].capabilities.gpio == 1) {
mraa_gpio_context mux_i;
mux_i = mraa_gpio_init_raw(plat->pins[pin].gpio.pinmap);
if (mux_i == NULL) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_init", pin);
return MRAA_ERROR_INVALID_RESOURCE;
}
if (mraa_gpio_dir(mux_i, MRAA_GPIO_OUT) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_dir", pin);
return MRAA_ERROR_INVALID_RESOURCE;
}
if (mraa_gpio_write(mux_i, 1) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_write", pin);
return MRAA_ERROR_INVALID_RESOURCE;
}
if (mraa_gpio_close(mux_i) != MRAA_SUCCESS) {
syslog(LOG_ERR, "pwm_init: error in gpio->pwm%i transition. gpio_close", pin);
return MRAA_ERROR_INVALID_RESOURCE;
}
}
return MRAA_SUCCESS;
}
mraa_board_t*
mraa_intel_galileo_rev_d()
{
@@ -166,6 +194,7 @@ mraa_intel_galileo_rev_d()
}
b->adv_func->gpio_mmap_setup = &mraa_intel_galileo_g1_mmap_setup;
b->adv_func->spi_lsbmode_replace = &mraa_intel_galileo_g1_spi_lsbmode_replace;
b->adv_func->pwm_init_pre = mraa_intel_galileo_g1_pwm_init_pre;
b->pins = (mraa_pininfo_t*) calloc(MRAA_INTEL_GALILEO_REV_D_PINCOUNT, sizeof(mraa_pininfo_t));
if (b->pins == NULL) {
@@ -175,7 +204,7 @@ mraa_intel_galileo_rev_d()
// GPIO IO0 - IO10
strncpy(b->pins[0].name, "IO0", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 50;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 1;
@@ -190,7 +219,7 @@ mraa_intel_galileo_rev_d()
b->pins[0].uart.mux[0].value = 0;
strncpy(b->pins[1].name, "IO1", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 51;
b->pins[1].gpio.mux_total = 1;
b->pins[1].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -204,7 +233,7 @@ mraa_intel_galileo_rev_d()
b->pins[1].uart.mux[0].value = 0;
strncpy(b->pins[2].name, "IO2", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 0 };
b->pins[2].gpio.pinmap = 32;
b->pins[2].gpio.mux_total = 1;
b->pins[2].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -226,7 +255,7 @@ mraa_intel_galileo_rev_d()
b->pins[2].mmap.bit_pos = 6;
strncpy(b->pins[3].name, "IO3", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0, 0 };
b->pins[3].gpio.pinmap = 18;
b->pins[3].gpio.mux_total = 1;
b->pins[3].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -255,12 +284,12 @@ mraa_intel_galileo_rev_d()
strncpy(b->pins[4].name, "IO4", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].gpio.pinmap = 28;
b->pins[4].gpio.mux_total = 0;
strncpy(b->pins[5].name, "IO5", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[5].gpio.pinmap = 17;
b->pins[5].gpio.mux_total = 0;
b->pins[5].pwm.pinmap = 5;
@@ -269,24 +298,24 @@ mraa_intel_galileo_rev_d()
strncpy(b->pins[6].name, "IO6", 8);
b->pins[6].gpio.pinmap = 24;
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].gpio.mux_total = 0;
b->pins[6].pwm.pinmap = 6;
b->pins[6].pwm.parent_id = 0;
b->pins[6].pwm.mux_total = 0;
strncpy(b->pins[7].name, "IO7", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 27;
b->pins[7].gpio.mux_total = 0;
strncpy(b->pins[8].name, "IO8", 8);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 26;
b->pins[8].gpio.mux_total = 0;
strncpy(b->pins[9].name, "IO9", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 19;
b->pins[9].gpio.mux_total = 0;
b->pins[9].pwm.pinmap = 1;
@@ -294,7 +323,7 @@ mraa_intel_galileo_rev_d()
b->pins[9].pwm.mux_total = 0;
strncpy(b->pins[10].name, "IO10", 8);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[10].gpio.pinmap = 16;
b->pins[10].gpio.mux_total = 1;
b->pins[10].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -313,7 +342,7 @@ mraa_intel_galileo_rev_d()
b->pins[10].spi.mux[0].value = 0;
strncpy(b->pins[11].name, "IO11", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[11].gpio.pinmap = 25;
b->pins[11].gpio.mux_total = 1;
b->pins[11].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -332,7 +361,7 @@ mraa_intel_galileo_rev_d()
b->pins[11].spi.mux[0].value = 0;
strncpy(b->pins[12].name, "IO12", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[12].gpio.pinmap = 38;
b->pins[12].gpio.mux_total = 1;
b->pins[12].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -345,7 +374,7 @@ mraa_intel_galileo_rev_d()
b->pins[12].spi.mux[0].value = 0;
strncpy(b->pins[13].name, "IO13", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].gpio.pinmap = 39;
b->pins[13].gpio.mux_total = 1;
b->pins[13].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -358,7 +387,7 @@ mraa_intel_galileo_rev_d()
b->pins[13].spi.mux[0].value = 0;
strncpy(b->pins[14].name, "A0", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].gpio.pinmap = 44;
b->pins[14].gpio.mux_total = 1;
b->pins[14].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -371,7 +400,7 @@ mraa_intel_galileo_rev_d()
b->pins[14].aio.mux[0].value = 0;
strncpy(b->pins[15].name, "A1", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].gpio.pinmap = 45;
b->pins[15].gpio.mux_total = 1;
b->pins[15].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -384,7 +413,7 @@ mraa_intel_galileo_rev_d()
b->pins[15].aio.mux[0].value = 0;
strncpy(b->pins[16].name, "A2", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].gpio.pinmap = 46;
b->pins[16].gpio.mux_total = 1;
b->pins[16].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -397,7 +426,7 @@ mraa_intel_galileo_rev_d()
b->pins[16].aio.mux[0].value = 0;
strncpy(b->pins[17].name, "A3", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].gpio.pinmap = 47;
b->pins[17].gpio.mux_total = 1;
b->pins[17].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -410,7 +439,7 @@ mraa_intel_galileo_rev_d()
b->pins[17].aio.mux[0].value = 0;
strncpy(b->pins[18].name, "A4", 8);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].gpio.pinmap = 48;
b->pins[18].gpio.mux_total = 2;
b->pins[18].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;
@@ -434,7 +463,7 @@ mraa_intel_galileo_rev_d()
b->pins[18].aio.mux[1].value = 0;
strncpy(b->pins[19].name, "A5", 8);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].gpio.pinmap = 49;
b->pins[19].gpio.mux_total = 2;
b->pins[19].gpio.mux[0].pincmd = PINCMD_SET_OUT_VALUE;

View File

@@ -296,7 +296,7 @@ mraa_intel_galileo_gen2()
}
strncpy(b->pins[0].name, "IO0", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
b->pins[0].gpio.pinmap = 11;
b->pins[0].gpio.parent_id = 0;
b->pins[0].gpio.mux_total = 1;
@@ -329,7 +329,7 @@ mraa_intel_galileo_gen2()
b->pins[0].uart.mux[1].value = 1;
strncpy(b->pins[1].name, "IO1", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 1 };
b->pins[1].gpio.pinmap = 12;
b->pins[1].gpio.parent_id = 0;
b->pins[1].gpio.mux_total = 2;
@@ -371,7 +371,7 @@ mraa_intel_galileo_gen2()
b->pins[1].uart.mux[2].value = 0;
strncpy(b->pins[2].name, "IO2", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 0};
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 1, 0, 0, 0, 0};
b->pins[2].gpio.pinmap = 13;
b->pins[2].gpio.parent_id = 0;
b->pins[2].gpio.mux_total = 2;
@@ -402,7 +402,7 @@ mraa_intel_galileo_gen2()
b->pins[2].mmap.bit_pos = 5;
strncpy(b->pins[3].name, "IO3", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 1, 0, 0, 0, 0 };
b->pins[3].gpio.pinmap = 14;
b->pins[3].gpio.parent_id = 0;
b->pins[3].gpio.mux_total = 3;
@@ -454,7 +454,7 @@ mraa_intel_galileo_gen2()
b->pins[3].mmap.bit_pos = 6;
strncpy(b->pins[4].name, "IO4", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[4].gpio.pinmap = 6;
b->pins[4].gpio.parent_id = 0;
b->pins[4].gpio.mux_total = 1;
@@ -465,7 +465,7 @@ mraa_intel_galileo_gen2()
b->pins[4].gpio.output_enable = 36;
strncpy(b->pins[5].name, "IO5", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 , 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0 , 0 };
b->pins[5].gpio.pinmap = 0;
b->pins[5].gpio.parent_id = 0;
b->pins[5].gpio.mux_total = 2;
@@ -491,7 +491,7 @@ mraa_intel_galileo_gen2()
b->pins[5].pwm.mux[2].value = 0;
strncpy(b->pins[6].name, "IO6", 8);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[6].gpio.pinmap = 1;
b->pins[6].gpio.parent_id = 0;
b->pins[6].gpio.mux_total = 2;
@@ -517,7 +517,7 @@ mraa_intel_galileo_gen2()
b->pins[6].pwm.mux[2].value = 0;
strncpy(b->pins[7].name, "IO7", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[7].gpio.pinmap = 38;
b->pins[7].gpio.parent_id = 0;
b->pins[7].gpio.mux_total = 1;
@@ -527,7 +527,7 @@ mraa_intel_galileo_gen2()
b->pins[7].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
strncpy(b->pins[8].name, "IO8", 8);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[8].gpio.pinmap = 40;
b->pins[8].gpio.parent_id = 0;
b->pins[8].gpio.mux_total = 1;
@@ -537,7 +537,7 @@ mraa_intel_galileo_gen2()
b->pins[8].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
strncpy(b->pins[9].name, "IO9", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[9].gpio.pinmap = 4;
b->pins[9].gpio.parent_id = 0;
b->pins[9].gpio.mux_total = 2;
@@ -563,7 +563,7 @@ mraa_intel_galileo_gen2()
b->pins[9].pwm.mux[2].value = 0;
strncpy(b->pins[10].name, "IO10", 8);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 1, 1, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 1, 1, 0, 0, 0 };
b->pins[10].gpio.pinmap = 10;
b->pins[10].gpio.parent_id = 0;
b->pins[10].gpio.mux_total = 2;
@@ -617,7 +617,7 @@ mraa_intel_galileo_gen2()
b->pins[10].spi.mux[2].value = 0;
strncpy(b->pins[11].name, "IO11", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 1, 0, 0, 0 };
b->pins[11].gpio.pinmap = 5;
b->pins[11].gpio.parent_id = 0;
b->pins[11].gpio.mux_total = 3;
@@ -663,7 +663,7 @@ mraa_intel_galileo_gen2()
b->pins[11].spi.mux[3].value = 0;
strncpy(b->pins[12].name, "IO12", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 1, 1, 0, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 1, 1, 0, 0, 0 };
b->pins[12].gpio.pinmap = 15;
b->pins[12].gpio.parent_id = 0;
b->pins[12].gpio.mux_total = 1;
@@ -696,7 +696,7 @@ mraa_intel_galileo_gen2()
b->pins[12].mmap.bit_pos = 7;
strncpy(b->pins[13].name, "IO13", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[13].gpio.pinmap = 7;
b->pins[13].gpio.parent_id = 0;
b->pins[13].gpio.mux_total = 2;
@@ -722,7 +722,7 @@ mraa_intel_galileo_gen2()
// ANALOG
strncpy(b->pins[14].name, "A0", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[14].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
b->pins[14].aio.pinmap = 0;
b->pins[14].aio.mux_total = 2;
@@ -739,7 +739,7 @@ mraa_intel_galileo_gen2()
b->pins[14].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[15].name, "A1", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[15].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
b->pins[15].aio.pinmap = 1;
b->pins[15].aio.mux_total = 2;
@@ -756,7 +756,7 @@ mraa_intel_galileo_gen2()
b->pins[15].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[16].name, "A2", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[16].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
b->pins[16].aio.pinmap = 2;
b->pins[16].aio.mux_total = 2;
@@ -773,7 +773,7 @@ mraa_intel_galileo_gen2()
b->pins[16].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[17].name, "A3", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 1, 0 };
b->pins[17].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
b->pins[17].aio.pinmap = 3;
b->pins[17].aio.mux_total = 2;
@@ -790,7 +790,7 @@ mraa_intel_galileo_gen2()
b->pins[17].gpio.mux[0].value = MRAA_GPIO_IN;
strncpy(b->pins[18].name, "A4", 8);
b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[18].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
b->pins[18].i2c.pinmap = 1;
b->pins[18].i2c.mux_total = 3;
@@ -827,7 +827,7 @@ mraa_intel_galileo_gen2()
b->pins[18].gpio.mux[2].value = 1;
strncpy(b->pins[19].name, "A5", 8);
b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 1, 0 };
b->pins[19].gpio.complex_cap = (mraa_pin_cap_complex_t){ 1, 0, 0, 1, 1 };
b->pins[19].i2c.pinmap = 1;
b->pins[19].i2c.mux_total = 3;

View File

@@ -66,12 +66,19 @@ mraa_gt_tuchuck_board()
b->i2c_bus[0].bus_id = 0;
b->i2c_bus[0].sda = 11;
b->i2c_bus[0].scl = 13;
b->i2c_bus[1].bus_id = 5;
if (mraa_find_i2c_bus("designware", 5) != 5) {
b->i2c_bus[1].bus_id = 9;
b->i2c_bus[2].bus_id = 10;
} else {
b->i2c_bus[1].bus_id = 5;
b->i2c_bus[2].bus_id = 6;
}
b->i2c_bus[1].sda = 15;
b->i2c_bus[1].scl = 17;
b->i2c_bus[1].bus_id = 6;
b->i2c_bus[1].sda = 19;
b->i2c_bus[1].scl = 21;
b->i2c_bus[2].sda = 19;
b->i2c_bus[2].scl = 21;
b->def_i2c_bus = b->i2c_bus[0].bus_id;
#if 0
@@ -94,48 +101,48 @@ mraa_gt_tuchuck_board()
int pos = 0;
strncpy(b->pins[pos].name, "INVALID", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GPIO", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 446;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP1RX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 421;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "PMICRST", 8);
// disabled as this pin causes a reset
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 366;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP1TX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 422;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "19.2mhz", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 356;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP1FS0", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 417;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "UART0TX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
// not configured as GPIO
//b->pins[pos].gpio.pinmap = 462;
//b->pins[pos].gpio.mux_total = 0;
@@ -145,27 +152,27 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "SPP1FS2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 419;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "PWRGD", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// not configured as GPI0 - does read work?
//b->pins[pos].gpio.pinmap = 365;
//b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP1CLK", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 416;
b->pins[pos].gpio.mux_total = 0;
pos++;
// pin 11
strncpy(b->pins[pos].name, "I2C0SDA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 315;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.mux_total = 0;
@@ -173,13 +180,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S1SDI", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 381;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "I2C0SCL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 316;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.mux_total = 0;
@@ -187,13 +194,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S1SDO", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 382;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "I2C1SDA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 331;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.mux_total = 0;
@@ -201,13 +208,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S1WS", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 380;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "I2C1SCL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 332;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
@@ -215,13 +222,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S1CLK", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 379;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "I2C2SDA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 333;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
@@ -229,13 +236,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S1MCL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 378;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "I2C2SCL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 334;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.mux_total = 0;
@@ -243,7 +250,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "UART1TX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
//b->pins[pos].gpio.pinmap = 472;
//b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -252,14 +259,14 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S4SDO", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// doesn't work so disable
//b->pins[pos].gpio.pinmap = 396;
//b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "UART1RX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 1 };
//b->pins[pos].gpio.pinmap = 471;
//b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -268,14 +275,14 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S4SDI", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// doesnt work
//b->pins[pos].gpio.pinmap = 395;
//b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "PWM0", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 463;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 0;
@@ -284,14 +291,14 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S4BLK", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
// this pin has a voltage of 0.34V in 'low' mode - beware!
b->pins[pos].gpio.pinmap = 397;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "PWM1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 464;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 1;
@@ -300,14 +307,14 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S4WS", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
// not working
//b->pins[pos].gpio.pinmap = 398;
//b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "PWM2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 465;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 2;
@@ -316,13 +323,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S3SDO", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
//b->pins[pos].gpio.pinmap = 400;
//b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "PWM3", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 1, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 466;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].pwm.pinmap = 3;
@@ -331,176 +338,176 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2S3SDI", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
//b->pins[pos].gpio.pinmap = 399;
//b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "1.8V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "I2S4BLK", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 393;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "3.3V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
// second header
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "5V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "5V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "3.3V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "3.3V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "1.8V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "GPIO", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 456;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "1.8V", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "PANEL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 270;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "GND", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "PANEL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 271;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "CAMERA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "PANEL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 272;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "CAMERA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "SPP0FS0", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 411;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "CAMERA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
pos++;
strncpy(b->pins[pos].name, "SPP0FS1", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 412;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPI_DAT", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 385;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP0FS2", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 411;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPICLKB", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 384;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP0FS3", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 410;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPICLKA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 383;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "SPP0TX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 414;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "UART0RX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 467;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -509,13 +516,13 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "SPP0RX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 415;
b->pins[pos].gpio.mux_total = 0;
pos++;
strncpy(b->pins[pos].name, "UART0RT", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 469;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -524,7 +531,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2C1SDA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 317;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
@@ -532,7 +539,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "UART0CT", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 412;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].uart.pinmap = 0;
@@ -541,7 +548,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2C1SCL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 318;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
@@ -549,7 +556,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "UART1TX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 484;
b->pins[pos].uart.pinmap = 0;
b->pins[pos].uart.parent_id = 0;
@@ -557,7 +564,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2C2SDA", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 319;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
@@ -565,7 +572,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "UART1RX", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 483;
b->pins[pos].uart.pinmap = 0;
b->pins[pos].uart.parent_id = 0;
@@ -573,7 +580,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "I2C1SCL", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
b->pins[pos].gpio.pinmap = 320;
b->pins[pos].gpio.mux_total = 0;
b->pins[pos].i2c.pinmap = 0;
@@ -581,7 +588,7 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "UART1RT", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 485;
b->pins[pos].uart.pinmap = 0;
b->pins[pos].uart.parent_id = 0;
@@ -589,12 +596,12 @@ mraa_gt_tuchuck_board()
pos++;
strncpy(b->pins[pos].name, "RTC_CLK", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 367;
pos++;
strncpy(b->pins[pos].name, "UART1CT", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
b->pins[pos].gpio.pinmap = 486;
b->pins[pos].uart.pinmap = 0;
b->pins[pos].uart.parent_id = 0;
@@ -602,38 +609,38 @@ mraa_gt_tuchuck_board()
pos++;
while (pos != 100) {
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
pos++;
}
strncpy(b->pins[pos].name, "LED100", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 337;
pos++;
strncpy(b->pins[pos].name, "LED101", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
// if BIOS is pre-L then this is 338
b->pins[pos].gpio.pinmap = 395;
pos++;
strncpy(b->pins[pos].name, "LED102", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 339;
pos++;
strncpy(b->pins[pos].name, "LED103", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 340;
pos++;
strncpy(b->pins[pos].name, "LEDWIFI", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 438;
pos++;
strncpy(b->pins[pos].name, "LEDBT", 8);
b->pins[pos].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
b->pins[pos].gpio.pinmap = 439;
pos++;

View File

@@ -45,7 +45,7 @@ mraa_set_pininfo(mraa_board_t* board, int mraa_index, char* name, mraa_pincapabi
// adjust mraa_index for ARCH_NR_GPIOS value
mraa_pininfo_t* pin_info = &board->pins[mraa_index];
strncpy(pin_info->name, name, MAX_LENGTH);
pin_info->capabilites = caps;
pin_info->capabilities = caps;
if (caps.gpio) {
pin_info->gpio.pinmap = sysfs_pin | arch_nr_gpios_adjust;
pin_info->gpio.mux_total = 0;

View File

@@ -58,63 +58,63 @@ mraa_intel_nuc5()
}
strncpy(b->pins[0].name, "1.8v", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[1].name, "GND", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[2].name, "HDMIcec", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[3].name, "DMICclk", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[4].name, "3.3v", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[5].name, "DMICda", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[6].name, "Key", 8);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[7].name, "SMB-A", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[8].name, "5v", 8);
b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[9].name, "SCI", 8);
b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[9].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[10].name, "PWM0", 8);
b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[10].pwm.pinmap = 0;
b->pins[10].pwm.parent_id = 0;
b->pins[10].pwm.mux_total = 0;
strncpy(b->pins[11].name, "PWM1", 8);
b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[11].pwm.pinmap = 0;
b->pins[11].pwm.parent_id = 1;
b->pins[11].pwm.mux_total = 0;
strncpy(b->pins[12].name, "I2C0SCL", 8);
b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[12].i2c.pinmap = 1;
b->pins[12].i2c.mux_total = 0;
strncpy(b->pins[13].name, "I2C0SDA", 8);
b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[13].i2c.pinmap = 1;
b->pins[13].i2c.mux_total = 0;
strncpy(b->pins[14].name, "I2C1SCL", 8);
b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[14].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[14].i2c.pinmap = 1;
b->pins[14].i2c.mux_total = 0;
strncpy(b->pins[15].name, "I2C1SDA", 8);
b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[15].i2c.pinmap = 1;
b->pins[15].i2c.mux_total = 0;
strncpy(b->pins[16].name, "SMB_CLK", 8);
b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
strncpy(b->pins[17].name, "SMB_SDA", 8);
b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->pins[17].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
b->i2c_bus_count = 0;
int i2c_num = -1;

View File

@@ -56,42 +56,42 @@ mraa_intel_sofia_3gr()
}
strncpy(b->pins[0].name, "I2C1SCL", 8);
b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[0].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[0].i2c.pinmap = 1;
b->pins[0].i2c.mux_total = 0;
strncpy(b->pins[1].name, "I2C1SDA", 8);
b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[1].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[1].i2c.pinmap = 1;
b->pins[1].i2c.mux_total = 0;
strncpy(b->pins[2].name, "I2C2SCL", 8);
b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[2].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[2].i2c.pinmap = 1;
b->pins[2].i2c.mux_total = 0;
strncpy(b->pins[3].name, "I2C2SDA", 8);
b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[3].i2c.pinmap = 1;
b->pins[3].i2c.mux_total = 0;
strncpy(b->pins[4].name, "I2C3SCL", 8);
b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[4].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[4].i2c.pinmap = 1;
b->pins[4].i2c.mux_total = 0;
strncpy(b->pins[5].name, "I2C3SDA", 8);
b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[5].i2c.pinmap = 1;
b->pins[5].i2c.mux_total = 0;
strncpy(b->pins[6].name, "I2C4SCL", 8);
b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[6].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[6].i2c.pinmap = 1;
b->pins[6].i2c.mux_total = 0;
strncpy(b->pins[7].name, "I2C4SDA", 8);
b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
b->pins[7].i2c.pinmap = 1;
b->pins[7].i2c.mux_total = 0;

View File

@@ -42,7 +42,7 @@ set_pininfo(mraa_board_t* board, int mraa_index, char* name, mraa_pincapabilitie
if (mraa_index < board->phy_pin_count) {
mraa_pininfo_t* pin_info = &board->pins[mraa_index];
strncpy(pin_info->name, name, MAX_LENGTH);
pin_info->capabilites = caps;
pin_info->capabilities = caps;
if (caps.gpio) {
pin_info->gpio.pinmap = sysfs_pin;
pin_info->gpio.mux_total = 0;

View File

@@ -14,12 +14,16 @@ if (BUILDSWIGPYTHON)
elseif (PYTHON3INTERP_FOUND)
set (PYTHON_DEFAULT_PYTHONPATH "${CMAKE_BINARY_DIR}/src/python/python3")
endif ()
add_test (NAME py_general COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
set_tests_properties(py_general PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
if (MOCKPLAT)
add_subdirectory (mock)
else()
add_test (NAME py_general COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
set_tests_properties(py_general PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
add_test (NAME py_platform COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
set_tests_properties(py_platform PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
add_test (NAME py_platform COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
set_tests_properties(py_platform PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
add_test (NAME py_gpio COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
add_test (NAME py_gpio COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
endif()
endif()

45
tests/mock/CMakeLists.txt Normal file
View File

@@ -0,0 +1,45 @@
# Mock platform tests
add_test (NAME py_general COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
add_test (NAME py_platform COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
add_test (NAME py_gpio_basic COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks_basic.py)
add_test (NAME py_gpio_dir COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks_dir.py)
add_test (NAME py_gpio_write_read COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks_write_read.py)
add_test (NAME py_gpio_edge COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks_edge.py)
add_test (NAME py_gpio_isr COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks_isr.py)
add_test (NAME py_gpio_mode COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks_mode.py)
add_test (NAME py_aio COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/aio_checks.py)
add_test (NAME py_i2c_freq COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_freq.py)
add_test (NAME py_i2c_addr COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_addr.py)
add_test (NAME py_i2c_read COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_read.py)
add_test (NAME py_i2c_write COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_write.py)
add_test (NAME py_i2c_read_byte COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_read_byte.py)
add_test (NAME py_i2c_write_byte COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_write_byte.py)
add_test (NAME py_i2c_read_byte_data COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_read_byte_data.py)
add_test (NAME py_i2c_write_byte_data COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_write_byte_data.py)
add_test (NAME py_i2c_read_bytes_data COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_read_bytes_data.py)
add_test (NAME py_i2c_read_word_data COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_read_word_data.py)
add_test (NAME py_i2c_write_word_data COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/i2c_checks_write_word_data.py)
set_tests_properties(py_general
py_platform
py_gpio_basic
py_gpio_dir
py_gpio_write_read
py_gpio_edge
py_gpio_isr
py_gpio_mode
py_aio
py_i2c_freq
py_i2c_addr
py_i2c_read
py_i2c_write
py_i2c_read_byte
py_i2c_write_byte
py_i2c_read_byte_data
py_i2c_write_byte_data
py_i2c_read_bytes_data
py_i2c_read_word_data
py_i2c_write_word_data
PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")

58
tests/mock/aio_checks.py Normal file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
MRAA_AIO_TEST_PIN = 0
PLATFORM_STD_ADC_RES_BITS = 10
PLATFORM_MAX_ADC_RES_BITS = 12
class AioChecks(u.TestCase):
def setUp(self):
self.pin = m.Aio(MRAA_AIO_TEST_PIN)
def tearDown(self):
del self.pin
def test_aio_get_bit(self):
self.assertEqual(self.pin.getBit(), PLATFORM_STD_ADC_RES_BITS, "Wrong ADC resolution reported")
def test_aio_set_bit(self):
self.pin.setBit(PLATFORM_MAX_ADC_RES_BITS)
self.assertEqual(self.pin.getBit(), PLATFORM_MAX_ADC_RES_BITS, "Wrong ADC resolution reported after setBit()")
def test_aio_read(self):
self.assertNotEqual(self.pin.read(), -1, "Error returned when reading ADC value")
def test_aio_read_float_std_res(self):
self.pin.setBit(PLATFORM_STD_ADC_RES_BITS)
self.assertNotEqual(self.pin.readFloat(), -1, "Error returned when reading float ADC value at standard resolution")
def test_aio_read_float_max_res(self):
self.pin.setBit(PLATFORM_MAX_ADC_RES_BITS)
self.assertNotEqual(self.pin.readFloat(), -1, "Error returned when reading float ADC value at maximum resolution")
if __name__ == "__main__":
u.main()

38
tests/mock/general_checks.py Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python
# Author: Costin Constantin <costin.c.constantin@intel.com>
# Copyright (c) 2015 Intel Corporation.
#
# Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
class GeneralChecks(u.TestCase):
def test_mraa_version(self):
version = m.getVersion()
print("Version is: " + version)
self.assertIsNotNone(version)
self.assertNotEqual(version, "", "MRAA version is an empty string")
if __name__ == "__main__":
u.main()

49
tests/mock/gpio_checks_basic.py Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
MRAA_TEST_PIN = 0
class GpioChecksBasic(u.TestCase):
def setUp(self):
self.pin = m.Gpio(MRAA_TEST_PIN)
def tearDown(self):
del self.pin
def test_gpio_state_after_init(self):
# After GPIO init it should be in INPUT and LOW state
self.assertEqual(self.pin.read(), 0, "GPIO is in a wrong state after init")
def test_gpio_dir_after_init(self):
# After GPIO init it should be in INPUT and LOW state
self.assertEqual(self.pin.readDir(), m.DIR_IN, "GPIO has wrong direction after init")
def test_get_pin_num(self):
self.assertEqual(self.pin.getPin(), MRAA_TEST_PIN, "Returned GPIO pin number is incorrect")
if __name__ == '__main__':
u.main()

67
tests/mock/gpio_checks_dir.py Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
MRAA_TEST_PIN = 0
class GpioChecksDir(u.TestCase):
def setUp(self):
self.pin = m.Gpio(MRAA_TEST_PIN)
def tearDown(self):
del self.pin
def test_set_dir_output(self):
direction = m.DIR_OUT
res = self.pin.dir(direction)
self.assertEqual(res, m.SUCCESS, "Setting GPIO to output failed")
self.assertEqual(self.pin.readDir(), direction, "GPIO has incorrect direction after dir(DIR_OUT)")
def test_set_dir_output_HIGH(self):
res = self.pin.dir(m.DIR_OUT_HIGH)
self.assertEqual(res, m.SUCCESS, "Setting GPIO to output HIGH failed")
self.assertEqual(self.pin.readDir(), m.DIR_OUT, "GPIO has incorrect direction after dir(DIR_OUT_HIGH)")
self.assertEqual(self.pin.read(), 1, "GPIO has incorrect state after dir(DIR_OUT_HIGH)")
def test_set_dir_output_LOW(self):
res = self.pin.dir(m.DIR_OUT_LOW)
self.assertEqual(res, m.SUCCESS, "Setting GPIO to output LOW failed")
self.assertEqual(self.pin.readDir(), m.DIR_OUT, "GPIO has incorrect direction after dir(DIR_OUT_LOW)")
self.assertEqual(self.pin.read(), 0, "GPIO has incorrect state after dir(DIR_OUT_LOW)")
def test_set_dir_input(self):
direction = m.DIR_IN
res = self.pin.dir(direction)
self.assertEqual(res, m.SUCCESS, "Setting GPIO to input failed")
self.assertEqual(self.pin.readDir(), direction, "GPIO has incorrect direction after dir(DIR_IN)")
def test_set_dir_invalid(self):
direction = 99
res = self.pin.dir(direction)
self.assertNotEqual(res, m.SUCCESS, "Setting direction to " + str(direction) + " should have failed")
if __name__ == '__main__':
u.main()

54
tests/mock/gpio_checks_edge.py Executable file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
MRAA_TEST_PIN = 0
class GpioChecksEdge(u.TestCase):
def setUp(self):
self.pin = m.Gpio(MRAA_TEST_PIN)
def tearDown(self):
del self.pin
def test_set_edge_mode_NONE(self):
res = self.pin.edge(m.EDGE_NONE)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting edge mode to EDGE_NONE did not return unimplemented")
def test_set_edge_mode_BOTH(self):
res = self.pin.edge(m.EDGE_BOTH)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting edge mode to EDGE_BOTH did not return unimplemented")
def test_set_edge_mode_RISING(self):
res = self.pin.edge(m.EDGE_RISING)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting edge mode to EDGE_RISING did not return unimplemented")
def test_set_edge_mode_FALLING(self):
res = self.pin.edge(m.EDGE_FALLING)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting edge mode to EDGE_FALLING did not return unimplemented")
if __name__ == '__main__':
u.main()

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
MRAA_TEST_PIN = 0
def test_isr():
print("In the ISR")
class GpioChecksIsr(u.TestCase):
def setUp(self):
self.pin = m.Gpio(MRAA_TEST_PIN)
def tearDown(self):
del self.pin
def test_set_isr(self):
self.pin.dir(m.DIR_IN)
res = self.pin.isr(m.EDGE_BOTH, test_isr, None)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Enabling ISR did not return unimplemented")
def test_isr_exit(self):
self.pin.dir(m.DIR_IN)
self.pin.isr(m.EDGE_BOTH, test_isr, None)
res = self.pin.isrExit()
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Calling isrExit() did not return unimplemented")
if __name__ == '__main__':
u.main()

View File

@@ -0,0 +1,54 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
MRAA_TEST_PIN = 0
class GpioChecksMode(u.TestCase):
def setUp(self):
self.pin = m.Gpio(MRAA_TEST_PIN)
def tearDown(self):
del self.pin
def test_set_mode_STRONG(self):
res = self.pin.mode(m.MODE_STRONG)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting GPIO mode to MODE_STRONG did not return unimplemented")
def test_set_mode_PULLUP(self):
res = self.pin.mode(m.MODE_PULLUP)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting GPIO mode to MODE_PULLUP did not return unimplemented")
def test_set_mode_PULLDOWN(self):
res = self.pin.mode(m.MODE_PULLDOWN)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting GPIO mode to MODE_PULLDOWN did not return unimplemented")
def test_set_mode_HIZ(self):
res = self.pin.mode(m.MODE_HIZ)
self.assertEqual(res, m.ERROR_FEATURE_NOT_IMPLEMENTED, "Setting GPIO mode to MODE_HIZ did not return unimplemented")
if __name__ == '__main__':
u.main()

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
MRAA_TEST_PIN = 0
class GpioChecksWriteRead(u.TestCase):
def setUp(self):
self.pin = m.Gpio(MRAA_TEST_PIN)
def tearDown(self):
del self.pin
def test_gpio_as_output_write_HIGH(self):
self.pin.dir(m.DIR_OUT)
res = self.pin.write(1)
self.assertEqual(res, m.SUCCESS, "Setting GPIO to HIGH failed")
res = self.pin.read()
self.assertEqual(res, 1, "GPIO is not HIGH after write(1)")
def test_gpio_as_output_write_LOW(self):
self.pin.dir(m.DIR_OUT)
res = self.pin.write(0)
self.assertEqual(res, m.SUCCESS, "Setting GPIO to LOW failed")
res = self.pin.read()
self.assertEqual(res, 0, "GPIO is not LOW after write(0)")
def test_gpio_as_output_write_invalid(self):
self.pin.dir(m.DIR_OUT)
value = 10
res = self.pin.write(value)
self.assertNotEqual(res, m.SUCCESS, "Writing " + str(value) + " to GPIO should have failed")
res = self.pin.read()
self.assertNotEqual(res, value, "Writing " + str(value) + " to GPIO should not have set it to " + str(value))
def test_gpio_as_input_write_HIGH(self):
self.pin.dir(m.DIR_IN)
res = self.pin.write(1)
self.assertNotEqual(res, m.SUCCESS, "Setting GPIO in INPUT to HIGH should have failed")
def test_gpio_as_input_write_LOW(self):
self.pin.dir(m.DIR_IN)
res = self.pin.write(0)
self.assertNotEqual(res, m.SUCCESS, "Setting GPIO in INPUT to LOW should have failed")
if __name__ == '__main__':
u.main()

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksAddr(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_address(self):
self.assertEqual(self.i2c.address(0x10),
m.SUCCESS,
"Setting address to 0x10 did not return success")
def test_i2c_address_invalid_bigger_than_max(self):
# For standard 7-bit addressing 0x7F is max address
self.assertEqual(self.i2c.address(0xFF),
m.ERROR_INVALID_PARAMETER,
"Setting address to 0xFF did not return INVALID_PARAMETER")
def test_i2c_address_invalid_smaller_than_min(self):
self.assertRaises(OverflowError, self.i2c.address, -100)
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksFreq(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_frequency_STD(self):
self.assertEqual(self.i2c.frequency(m.I2C_STD),
m.SUCCESS,
"Setting frequency to I2C_STD did not return success")
def test_i2c_frequency_FAST(self):
self.assertEqual(self.i2c.frequency(m.I2C_FAST),
m.SUCCESS,
"Setting frequency to I2C_FAST did not return success")
def test_i2c_frequency_HIGH(self):
self.assertEqual(self.i2c.frequency(m.I2C_HIGH),
m.SUCCESS,
"Setting frequency to I2C_HIGH did not return success")
def test_i2c_frequency_invalid_bigger_than_max(self):
self.assertEqual(self.i2c.frequency(100),
m.ERROR_INVALID_PARAMETER,
"Setting frequency to 100 did not return INVALID_PARAMETER")
def test_i2c_frequency_invalid_smaller_than_min(self):
self.assertEqual(self.i2c.frequency(-100),
m.ERROR_INVALID_PARAMETER,
"Setting frequency to -100 did not return INVALID_PARAMETER")
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksRead(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_read_full_reg_range(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
expected_res = bytearray([MRAA_MOCK_I2C_DATA_INIT_BYTE for i in range(MRAA_MOCK_I2C_DATA_LEN)])
res = self.i2c.read(MRAA_MOCK_I2C_DATA_LEN)
self.assertEqual(res, expected_res, "I2C read() of full register range returned unexpected data")
def test_i2c_read_part_reg_range(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
expected_res = bytearray([MRAA_MOCK_I2C_DATA_INIT_BYTE for i in range(MRAA_MOCK_I2C_DATA_LEN - 1)])
res = self.i2c.read(MRAA_MOCK_I2C_DATA_LEN - 1)
self.assertEqual(res, expected_res, "I2C read() of partial register range returned unexpected data")
def test_i2c_read_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
self.assertRaises(IOError, self.i2c.read, MRAA_MOCK_I2C_DATA_LEN)
def test_i2c_read_invalid_len_bigger_than_max(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
self.assertRaises(IOError, self.i2c.read, MRAA_MOCK_I2C_DATA_LEN + 1)
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksReadByte(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_read_byte(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
expected_res = MRAA_MOCK_I2C_DATA_INIT_BYTE
res = self.i2c.readByte()
self.assertEqual(res, expected_res, "I2C readByte() returned unexpected data")
def test_i2c_read_byte_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
self.assertRaises(ValueError, self.i2c.readByte)
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksReadByteData(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_read_byte_data(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
expected_res = MRAA_MOCK_I2C_DATA_INIT_BYTE
res = self.i2c.readReg(MRAA_MOCK_I2C_DATA_LEN - 1)
self.assertEqual(res, expected_res, "I2C readReg() returned unexpected data")
def test_i2c_read_byte_data_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
self.assertRaises(ValueError, self.i2c.readReg, MRAA_MOCK_I2C_DATA_LEN - 1)
def test_i2c_read_byte_data_invalid_reg(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
self.assertRaises(ValueError, self.i2c.readReg, MRAA_MOCK_I2C_DATA_LEN)
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,81 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksReadBytesData(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_read_bytes_data(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
# Generate unique data bytes
data_to_write = bytearray([0xEE+i for i in range(MRAA_MOCK_I2C_DATA_LEN)])
self.i2c.write(data_to_write)
# We expect to read the last two bytes
expected_res = bytearray(data_to_write[-2:])
test_reg_addr = MRAA_MOCK_I2C_DATA_LEN - 2
test_read_len = 2
self.assertEqual(self.i2c.readBytesReg(test_reg_addr, test_read_len),
expected_res,
"I2C readBytesReg() returned unexpected data")
def test_i2c_read_bytes_data_length_bigger_than_max(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
# Generate unique data bytes
data_to_write = bytearray([0xEE+i for i in range(MRAA_MOCK_I2C_DATA_LEN)])
self.i2c.write(data_to_write)
# We expect to read the last two bytes
expected_res = bytearray(data_to_write[-2:])
test_reg_addr = MRAA_MOCK_I2C_DATA_LEN - 2
# Set the read length bigger than our data length
test_read_len = MRAA_MOCK_I2C_DATA_LEN + 2
self.assertEqual(self.i2c.readBytesReg(test_reg_addr, test_read_len),
expected_res,
"I2C readBytesReg() returned unexpected data")
def test_i2c_read_bytes_data_zero_length(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
self.assertRaises(IOError, self.i2c.readBytesReg, 0x0, 0)
def test_i2c_read_bytes_data_negative_length(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
self.assertRaises(ValueError, self.i2c.readBytesReg, 0x0, -1)
def test_i2c_read_bytes_data_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
self.assertRaises(IOError, self.i2c.readBytesReg, 0x0, MRAA_MOCK_I2C_DATA_LEN - 1)
def test_i2c_read_bytes_data_invalid_reg(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
self.assertRaises(IOError, self.i2c.readBytesReg, MRAA_MOCK_I2C_DATA_LEN, MRAA_MOCK_I2C_DATA_LEN - 1)
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,56 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksReadWordData(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_read_word_data(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
high_byte = 0xAA
low_byte = 0xBB
expected_res = (high_byte << 8) + low_byte
self.i2c.writeReg(MRAA_MOCK_I2C_DATA_LEN - 2, high_byte)
self.i2c.writeReg(MRAA_MOCK_I2C_DATA_LEN - 1, low_byte)
res = self.i2c.readWordReg(MRAA_MOCK_I2C_DATA_LEN - 2)
self.assertEqual(res, expected_res, "I2C readWordReg() returned unexpected data")
def test_i2c_read_word_data_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
self.assertRaises(ValueError, self.i2c.readWordReg, MRAA_MOCK_I2C_DATA_LEN - 2)
def test_i2c_read_word_data_invalid_reg(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
self.assertRaises(ValueError, self.i2c.readReg, MRAA_MOCK_I2C_DATA_LEN)
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MRAA_I2C_BUS_NUM = 0
# These are defined in mock_board.c
MRAA_MOCK_I2C_ADDR = 0x33
MRAA_MOCK_I2C_DATA_LEN = 10
MRAA_MOCK_I2C_DATA_INIT_BYTE = 0xAB

View File

@@ -0,0 +1,78 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksWrite(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_write_full_reg_range(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
data_to_write = bytearray([0xEE for i in range(MRAA_MOCK_I2C_DATA_LEN)])
self.assertEqual(self.i2c.write(data_to_write),
m.SUCCESS,
"I2C write() of full register range did not return success")
res = self.i2c.read(MRAA_MOCK_I2C_DATA_LEN)
self.assertEqual(res,
data_to_write,
"I2C read() after write() of full register range returned unexpected data")
def test_i2c_write_part_reg_range(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
data_to_write = bytearray([0xEE for i in range(MRAA_MOCK_I2C_DATA_LEN - 1)])
self.assertEqual(self.i2c.write(data_to_write),
m.SUCCESS,
"I2C write() of partial register range did not return success")
res = self.i2c.read(MRAA_MOCK_I2C_DATA_LEN - 1)
self.assertEqual(res,
data_to_write,
"I2C read() after write() of partial register range returned unexpected data")
def test_i2c_write_len_bigger_than_max(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
data_to_write = bytearray([0xEE for i in range(MRAA_MOCK_I2C_DATA_LEN + 1)])
self.assertEqual(self.i2c.write(data_to_write),
m.SUCCESS,
"I2C write() with length bigger than max did not return success")
res = self.i2c.read(MRAA_MOCK_I2C_DATA_LEN)
self.assertEqual(res,
data_to_write[:-1],
"I2C read() after write() with length bigger than max returned unexpected data")
def test_i2c_write_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
data_to_write = bytearray([0xEE for i in range(MRAA_MOCK_I2C_DATA_LEN)])
self.assertEqual(self.i2c.write(data_to_write),
m.ERROR_UNSPECIFIED,
"I2C write() to invalid address did not return error")
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,54 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksWriteByte(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_write_byte(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
test_byte = 0xEE
self.assertEqual(self.i2c.writeByte(test_byte),
m.SUCCESS,
"I2C writeByte() did not return success")
self.assertEqual(self.i2c.readByte(),
test_byte,
"I2C readByte() after writeByte() returned unexpected data")
def test_i2c_write_byte_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
self.assertEqual(self.i2c.writeByte(0xEE),
m.ERROR_UNSPECIFIED,
"I2C writeByte() to invalid address did not return error")
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,65 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksWriteByteData(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_write_byte_data(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
test_byte = 0xEE
reg = MRAA_MOCK_I2C_DATA_LEN - 1
self.assertEqual(self.i2c.writeReg(reg, test_byte),
m.SUCCESS,
"I2C writeReg() did not return success")
self.assertEqual(self.i2c.readReg(reg),
test_byte,
"I2C readReg() after writeReg() returned unexpected data")
def test_i2c_write_byte_data_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
test_byte = 0xEE
reg = MRAA_MOCK_I2C_DATA_LEN - 1
self.assertEqual(self.i2c.writeReg(reg, test_byte),
m.ERROR_UNSPECIFIED,
"I2C writeReg() to invalid address did not return error")
def test_i2c_write_byte_data_invalid_reg(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
test_byte = 0xEE
reg = MRAA_MOCK_I2C_DATA_LEN
self.assertEqual(self.i2c.writeReg(reg, test_byte),
m.ERROR_UNSPECIFIED,
"I2C writeReg() with invalid register did not return error")
if __name__ == "__main__":
u.main()

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
# Copyright (c) 2016 Alex Tereschenko.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import mraa as m
import unittest as u
from i2c_checks_shared import *
class I2cChecksWriteWordData(u.TestCase):
def setUp(self):
self.i2c = m.I2c(MRAA_I2C_BUS_NUM)
def tearDown(self):
del self.i2c
def test_i2c_write_word_data(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
high_byte = 0xAA
low_byte = 0xBB
test_word = (high_byte << 8) + low_byte
reg = MRAA_MOCK_I2C_DATA_LEN - 2
self.assertEqual(self.i2c.writeWordReg(reg, test_word),
m.SUCCESS,
"I2C writeWordReg() did not return success")
self.assertEqual(self.i2c.readReg(reg),
high_byte,
"I2C readReg() of higher byte after writeWordReg() returned unexpected data")
self.assertEqual(self.i2c.readReg(reg + 1),
low_byte,
"I2C readReg() of lower byte after writeWordReg() returned unexpected data")
def test_i2c_write_word_data_invalid_addr(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR - 1)
test_word = 0xAABB
reg = MRAA_MOCK_I2C_DATA_LEN - 2
self.assertEqual(self.i2c.writeWordReg(reg, test_word),
m.ERROR_UNSPECIFIED,
"I2C writeWordReg() to invalid address did not return error")
def test_i2c_write_word_data_invalid_reg(self):
self.i2c.address(MRAA_MOCK_I2C_ADDR)
test_word = 0xAABB
reg = MRAA_MOCK_I2C_DATA_LEN
self.assertEqual(self.i2c.writeWordReg(reg, test_word),
m.ERROR_UNSPECIFIED,
"I2C writeWordReg() with invalid register did not return error")
if __name__ == "__main__":
u.main()

49
tests/mock/platform_checks.py Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env python
# Author: Costin Constantin <costin.c.constantin@intel.com>
# Copyright (c) 2015 Intel Corporation.
#
# Contributors: Alex Tereschenko <alext.mkrs@gmail.com>
#
# 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.
import mraa as m
import unittest as u
PLATFORM_PINCOUNT = 4
PLATFORM_STD_ADC_RES_BITS = 10
PLATFORM_MAX_ADC_RES_BITS = 12
class PlatformChecks(u.TestCase):
def test_platform_pin_count(self):
self.assertEqual(m.getPinCount(), PLATFORM_PINCOUNT, "Wrong number of pins reported by platform")
def test_adc_std_res(self):
adc_std_res = m.adcSupportedBits()
print("Platform ADC standard resolution is: " + str(adc_std_res) + " bits")
self.assertEqual(adc_std_res, PLATFORM_STD_ADC_RES_BITS, "Wrong ADC standard resolution")
def test_adc_max_res(self):
adc_max_res = m.adcRawBits()
print("Platform ADC max. resolution is: " + str(adc_max_res) + " bits")
self.assertEqual(adc_max_res, PLATFORM_MAX_ADC_RES_BITS, "Wrong ADC max. resolution")
if __name__ == "__main__":
u.main()