2016-02-15 19:44:42 +02:00
|
|
|
/*
|
|
|
|
|
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
|
|
|
|
* Copyright (c) 2016 Intel Corporation.
|
|
|
|
|
*
|
2019-05-09 09:47:11 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2016-02-15 19:44:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import mraa.*;
|
|
|
|
|
|
|
|
|
|
public class FTDITest {
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
|
String board = mraa.getPlatformName();
|
|
|
|
|
String version = mraa.getVersion();
|
|
|
|
|
|
|
|
|
|
System.out.println(String.format("Version: %s", version));
|
|
|
|
|
System.out.println(String.format("Running on %s", board));
|
|
|
|
|
|
|
|
|
|
if (mraa.hasSubPlatform()) {
|
|
|
|
|
System.out.println("Subplatform detected");
|
|
|
|
|
|
|
|
|
|
/* Print when button is pressed */
|
|
|
|
|
Gpio button = new Gpio(515);
|
|
|
|
|
button.dir(Dir.DIR_IN);
|
|
|
|
|
button.isr(Edge.EDGE_FALLING, new Runnable() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
System.out.println("Button pressed");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Blink FTDI board LED */
|
|
|
|
|
Gpio led = new Gpio(514);
|
|
|
|
|
led.dir(Dir.DIR_OUT);
|
2017-06-05 18:22:29 +02:00
|
|
|
for (int i = 100; i > 0; --i) {
|
|
|
|
|
led.write(i % 2);
|
2016-02-15 19:44:42 +02:00
|
|
|
Thread.sleep(500);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("Subplatform not detected");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|