Access to the GPIOs
The MRAA library is a low level skeleton for "communication" on linux devices. It can be found here:
https://iotdk.intel.com/docs/master/mraa/
That is, "communication" as in GPIO, SPI, I2C, AIO (i.e. analog IO), PWM and UART (i.e. serial. Look there for examples and the "API" documentation.
Note that the "Mraa Hello" example on the home page does not compile as the functions are found in common.h and not mraa.h. You need to '#include "mraa/common.h"' in the source code! Here is my version:
#include "mraa.h"
#include "mraa/common.h"
int main(int argc, char** argv)
{
const char* board_name = mraa_get_platform_name();
fprintf(stdout, "hello mraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
mraa_deinit();
return MRAA_SUCCESS;
}
Getting the pre-compiled library for the cross-compiler
The mraa library and include files are not in the toolchain but they are in the SDK. Look in:
- OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/lib
and
- OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include
The libraries are:
- libmraa.so
- libmraa.so.0
- libmraa.so.0.8.0
Note that libmraa.so and libmraa.so.0 are symbolic links to libmraa.so.0.8.0 .
The includes are:
- mraa.h
- mraa/aio.h
- mraa/common.h
- mraa/gpio.h
- mraa/i2c.h
- mraa/pwm.h
- mraa/spi.h
- mraa/types.h
- mraa/uart.h
I have added an archive to the files download area of this project for the mraa library for your convenience.
An Example Run (Mraa hello)
alanx@alanx ~/LinkIt-cc/mraa_hello $ make
/home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-uclibc-gcc -I. -I /home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -I /home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include -o mraa_hello.run mraa_hello.c -L. -L/home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -L/home/alanx/LinkIt-cc/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib -lmraa -pthread -ldl
alanx@alanx ~/LinkIt-cc/mraa_hello $ scp mraa_hello.run root@mylinkit.local:~/Code/mraa_hello
root@mylinkit.local's password:
mraa_hello.run 100% 7562 7.4KB/s 00:00
alanx@alanx ~/LinkIt-cc/mraa_hello $ ssh root@mylinkit.local
root@mylinkit.local's password:
BusyBox v1.23.2 (2015-11-18 16:34:33 CET) built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
CHAOS CALMER (15.05+linkit, r47501)
-----------------------------------------------------
* 1 1/2 oz Gin Shake with a glassful
* 1/4 oz Triple Sec of broken ice and pour
* 3/4 oz Lime Juice unstrained into a goblet.
* 1 1/2 oz Orange Juice
* 1 tsp. Grenadine Syrup
-----------------------------------------------------
root@mylinkit:~# cd Code/mraa_hello
root@mylinkit:~/Code/mraa_hello# ls -lah
drwxr-xr-x 2 root root 4.0K Oct 27 12:10 .
drwxr-xr-x 6 root root 4.0K Oct 29 01:52 ..
-rwxr-xr-x 1 root root 7.4K Oct 29 02:56 mraa_hello.run
root@mylinkit:~/Code/mraa_hello# ./mraa_hello.run
hello mraa
Version: v0.8.0
Running on LinkIt Smart 7688
root@mylinkit:~/Code/mraa_hello# exit
Connection to mylinkit.local closed.
alanx@alanx ~/LinkIt-cc/mraa_hello $
AlanX
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.