i2c scan peripheriques

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
johnylafleur
Date:
Tue Mar 31 14:28:20 2015 +0000
Commit message:
i2c scan peripheriques

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 b4f549ac73a6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 31 14:28:20 2015 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+ 
+I2C i2c(PB_9, PB_8);
+Serial debug(SERIAL_TX, SERIAL_RX);
+ 
+char data [255];
+int i;
+int main()
+
+{
+    debug.format(8,Serial::None,1); 
+debug.baud(115200); 
+    debug.printf("started.. \n");
+    // Scan for I2C devices that reply with ack
+    for (i=0; i<=254; i=i+2) {
+        if (i2c.read(i, &data[0], 1) ==0) 
+        {
+            debug.printf("I2C device detected at address=%2.2X\n\r", i);
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r b4f549ac73a6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 31 14:28:20 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file