User manual

MediaTek LinkIt™ Smart 7688 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 61
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.
Then, call pin.write(0) to set the pin state to LOW or call pin.write(1) to set the pin
state to
HIGH. To make the Wi-Fi LED blink periodically, set pin 44 (WLED_N) to GPIO mode
and execute the following code:
import mraa
import time
# Refer to the pinout digram for the GPIO number to silk print mapping
# in this example the number 44 maps to Wi-Fi LED.
pin = mraa.Gpio(44)
pin.dir(mraa.DIR_OUT)
while True:
pin.write(1)
time.sleep(1)
pin.write(0)
time.sleep(1)
Theres another GPIO mode which is INPUT. It takes the digital signal input from the pin
and interprets it into 1 and 0. This example will continuously print out the value received
from
P10 on the board. You can short 3V3 and P10 to observe the change in values.
import mraa
import time
# Refer to the pinout digram for the GPIO number to silk print mapping
# in this example the number 2 maps to P10 on LinkIt Smart 7688 board
pin = mraa.Gpio(2)
pin.dir(mraa.DIR_IN)
while True:
print "P10 state:", pin.read()
time.sleep(0.3)
Finally, an interrupt service routine can be installed to the pin and invoked when the
values of the input pin P10 (GPIO2) has changed. Call
isr API with the trigger type you
want to register and the function to be called. Note that the function runs in a different
thread.
import mraa
import time
def callback(userdata):
print "interrupt triggered with userdata=", userdata
pin = mraa.Gpio(2)
pin.dir(mraa.DIR_IN)
pin.isr(mraa.EDGE_BOTH, callback, None)