MediaTek LinkIt™ Smart 7688 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 63
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
import
mraa
i2c = mraa.I2c(
0
)
# Grove - 3-Axis Digital Acceler-16g)
# is a ADXL345 configured to I2C address 0x53.
i2c.address(
0x53
)
# The device ID should be
if
0xE5
== i2c.readReg(
0x00
):
"Grove - 3-Axis Digital Accelerometer found on I2C Bus"
else
:
"Grove - 3-Axis Digital Accelerometer not found"
For more details on I2C API, please see
To drive an I2C device, you need to operate multiple I2C sequences. LinkIt Smart 7688 also
comes with libUPM pre-installed, which is a set of driver repository built upon libmraa.
Please see
for a driver example of Seeed Studio 3-Axis Digital Accelerometer.
•
SPI
SPI (Serial Peripheral Interface) can also be used to control peripheral devices. On LinkIt
Smart 7688 it consists of 4 pins:
SPI_MOSI(P22), SPI_MISO(P23), SPI_CLK(P24),
and
SPI_CS1(P25).
It’s important to note that the SPI device is also used for communicating with the internal
flash storage on the board. Therefore, developers should access the SPI functionality
through SPI modules only and avoid treating these SPI pins as general GPIO. Otherwise,
the flash storage may work incorrectly.
The SPI module in libmraa is initialized by device index, instead of pin number.
import
mraa
spi = mraa.Spi(
0
)
The SPI protocol allows flexible configurations on signal patterns. Depending on your
peripheral, you may need to configure the pattern with APIs like
bitPerWord
and
mode
.
Please see
for API details.
Please see MediaTek Labs’ website for tutorials on how to blink the Wi-Fi LED on LinkIt Smart
7688 using mraa in Python and Node.js.
5.1.4.
LED blink example using mraa in LinkIt Smart 7688 GPIO in Python
This example shows you how to use mraa library in Python to make the Wi-Fi LED on LinkIt Smart
7688 blink.
1)
In LinkIt Smart 7688 SSH system console, create a directory called app and go to that
directory. For example:
mkdir app
cd app