summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-04-05 15:08:03 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-04-05 15:08:03 +0100
commitf7025d4317adde917d0cc0de2d119c1843b5559a (patch)
treeb3d9f63c85de55910224330e4eabc0bb58287cc2
gpiotest: initial version of testing script
Checking test conditions is still missing, but basic features are tested. Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
-rw-r--r--gpiotest/HACKING13
-rw-r--r--gpiotest/reader.ino31
-rw-r--r--gpiotest/writer.py27
3 files changed, 71 insertions, 0 deletions
diff --git a/gpiotest/HACKING b/gpiotest/HACKING
new file mode 100644
index 0000000..e2741a6
--- /dev/null
+++ b/gpiotest/HACKING
@@ -0,0 +1,13 @@
+1. Sensor board
+In order to build arduino part following packages need to be installed:
+ - arduino
+ - arduino-mk
+ - build-essential
+
+Flashing to arduino on Sensor mezzanine:
+export MONITOR_PORT=/dev/tty96B0
+ln -s /usr/share/arduino/Arduino.mk Makefile
+make upload reset_stty
+
+2. base board
+libmraa needs to be installed with python bindings
diff --git a/gpiotest/reader.ino b/gpiotest/reader.ino
new file mode 100644
index 0000000..fea9ed6
--- /dev/null
+++ b/gpiotest/reader.ino
@@ -0,0 +1,31 @@
+/* This is Arduino program that reads from
+ * digital pin 4 and writes the same value
+ * to digital pin 5. On 96boards sensors mezzanine
+ * these two are linked to single groove connector
+ */
+
+int inPin = 4;
+int outPin = 5;
+int oldVal = 0;
+int newVal = 0;
+
+void setup()
+{
+ pinMode(inPin, INPUT);
+ pinMode(outPin, OUTPUT);
+ digitalWrite(outPin, LOW);
+ Serial.begin(9600);
+ Serial.println("GPIO listen start");
+}
+
+void loop()
+{
+ newVal = digitalRead(inPin);
+ if (newVal != oldVal)
+ {
+ oldVal = newVal;
+ Serial.print("GPIO state changed to: ");
+ Serial.println(newVal);
+ digitalWrite(outPin, newVal);
+ }
+}
diff --git a/gpiotest/writer.py b/gpiotest/writer.py
new file mode 100644
index 0000000..102c4a1
--- /dev/null
+++ b/gpiotest/writer.py
@@ -0,0 +1,27 @@
+"""
+This is a simple GPIO manipulation program. It works together
+with Sensor board mezzanine and arduino program. The program writes
+value 1 (HIGH) to GPIO_A which should be connected to arduino
+digital pin 4. Than it reads value from GPIO_B which should be connected
+to arduino digital pin 5.
+"""
+
+import mraa
+from time import sleep
+
+print (mraa.getVersion())
+# GPIO_A on 96boards
+output = mraa.Gpio(23)
+output.dir(mraa.DIR_OUT)
+
+# GPIO_B on 96boards
+input = mraa.Gpio(24)
+input.dir(mraa.DIR_IN)
+
+print "Initial input value: %s" % input.read()
+# ToDo: check the value and report test result
+output.write(1)
+sleep(10)
+print "Final input value: %s" % input.read()
+# ToDo: check the value and report test result
+output.write(0)