Testprogramm für BERTL 2014, der BULME Graz/Gösting. Die Taster vom I2C Expander werden direkt auf die LED's des Expander geschalten

Dependencies:   mbed

Fork of BERTL14_I2C_TEST by Wolfgang Raimann

Files at this revision

API Documentation at this revision

Comitter:
bulme_rai
Date:
Wed May 07 10:02:43 2014 +0000
Commit message:
Testprogramm f?r BERTL 2014, der BULME Graz/G?sting.; Die Taster vom I2C Expander werden direkt auf die LED's des Expander geschalten

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7def09334278 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 07 10:02:43 2014 +0000
@@ -0,0 +1,43 @@
+/***********************************
+name:   BERTL14_I2C_TEST
+author: Wolfgang Raimann
+email:  rai@bulme.at
+description:
+    Die Taster vom I2C Expander werden direkt auf die LED's des Expander geschalten
+***********************************/
+
+#include "mbed.h"
+
+const int PCA9555_ADR = 0x40;
+#define I2C_WRITE   0
+#define I2C_READ    1
+
+I2C i2c(p28, p27);
+
+
+int main() {
+    char btn = 0;
+    // Config PCA9555 I0 as output    
+    i2c.start();
+    i2c.write(PCA9555_ADR + I2C_WRITE);
+    i2c.write(0x06);
+    i2c.write(0x00);
+    i2c.stop();    
+    
+    while(1) {
+        // Einlesen der Taster
+        i2c.start();
+        i2c.write(PCA9555_ADR + I2C_WRITE);
+        i2c.write(0x01);
+        i2c.start();
+        i2c.write(PCA9555_ADR + I2C_READ);
+        btn = i2c.read(0);
+        i2c.stop();
+        // Schreiben auf die LED's
+        i2c.start();
+        i2c.write(PCA9555_ADR + I2C_WRITE);
+        i2c.write(0x02);
+        i2c.write(~btn);
+        i2c.stop();
+    }
+}
diff -r 000000000000 -r 7def09334278 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 07 10:02:43 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file