Scan I2C address with COM port output

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
bi18rdbi18rd
Date:
Sat Dec 05 10:31:10 2015 +0000
Commit message:
IIC Scan address;

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 02e1d738d7ad main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Dec 05 10:31:10 2015 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+I2C i2c(I2C_SDA, I2C_SCL);
+
+int addr = 0x00;
+
+int main()
+{
+    bool ack;
+    
+    printf("\nstart\n");
+
+    i2c.frequency(100000);
+
+
+    while(1) {
+        
+//sent data i2c     FIGURE 4-1
+        ack = i2c.write(addr,0x00,1);
+        wait_us(5);
+        
+        if(!ack) printf("I2C found @ %x\n",addr);
+        
+        if(addr>=0xFF) break;
+        addr++;
+    }
+    printf("stop\n\n");
+
+}
\ No newline at end of file
diff -r 000000000000 -r 02e1d738d7ad mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 05 10:31:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file