MediaTek LinkIt™ Smart 7688 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 60
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.
5.1.1.
Installing MRAA
Libmraa is already installed in the system image of LinkIt Smart 7688, so you don't need to install
it again. However if you want to update the library, or want to port or upgrade the library, please
refer to
for more information.
To use libmraa in Python, you need to import it. In the below example, libmraa is imported and
the output is the build version of the mraa:
import mraa
print (mraa.getVersion())
For a list of libmraa APIs, please see
5.1.2.
Basic concepts of libmraa
The majority of hardware modules such as GPIO, UART, SPI, and PWM are represented as objects
created by mraa's factory function. These modules are initialized on certain pins that are
identified by pin numbers. The pin numbers in the libmraa on LinkIt Smart 7688 are identical to the
GPIO number in the data sheet and in the Linux GPIO subsystem.
The following example creates GPIO object on GPIO 2, which maps to P10 of LinkIt Smart 7688 and
it’s the IS2_WS pin in data sheet, as shown in Table 16. Refer to the Pin-out diagram of LinkIt Smart
7688 and LinkIt Smart 7688 Duo respectively to see the mapping between the silk print on the
board and the GPIO number. This number also applies to Linux: /sys/class/gpio/2 which maps to
exactly the same P10 pin on the LinkIt Smart 7688 board.
GPIO
Pin mapping
LinkIt Smart 7688
P10
Datasheet
IS2_WS
Table 16 LinkIt Smart 7688 GPIO Pin Mapping
import
mraa
pin = mraa.Gpio(
2
)
# Initialize GPIO2 (P10 on LinkIt Smart 7688 board)
5.1.3.
Libmraa Main Functions
This section introduces major modules of libmraa to give you ideas on how to work with GPIOs and
other interfaces that is available on LinkIt Smart 7688.
•
GPIO and Interrupts
To control GPIO pins, initialize the pin as GPIO pin and set its
mode
. The simplest operation
mode is OUTPUT - set the pin to HIGH or LOW to enable and disable external switches or
to form signal patterns.
import
mraa
pin = mraa.Gpio(
2
)
# Initialize GPIO2 (P10 on LinkIt Smart 7688 board)
pin.
dir
(mraa.DIR_OUT)
# set as OUTPUT pin