Detect I2C devices

Revision:
2:85afa5129e56
Parent:
1:2651ad0f52c0
--- a/main.cpp	Mon Apr 23 09:31:48 2018 +0000
+++ b/main.cpp	Fri Dec 04 11:02:11 2020 +0900
@@ -1,40 +1,39 @@
 #include "mbed.h"
 
 DigitalOut led1(LED1);
-Serial pc(USBTX, USBRX);
 I2C i2c(D14, D15);
 
 // main() runs in its own thread in the OS
 int main() {
     char buf[10];
     buf[0] = 0;
-    pc.printf("     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\n");
+    printf("     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\n");
     for (int adrs = 0; adrs < 0x80; adrs += 16) {
-        pc.printf("%02x: ", adrs);
+        printf("%02x: ", adrs);
         for (int i = 0; i < 16; i++) {
             i2c.write(((adrs + i) << 1), buf, 1);
             int ret = i2c.read(((adrs + i) << 1), buf, 2);
             if ((adrs+i) == 0 || (adrs+i) == 1 || (adrs+i) == 2) {
-                pc.printf("   ");
+                printf("   ");
                 continue;
             }
             if ((adrs+i) >= 0x78) {
-                pc.printf("\n");
+                printf("\n");
                 break;
             }
             if (ret == 1) {
-                pc.printf("-- ");
+                printf("-- ");
             }
             if (ret == 0) {
-                pc.printf("%02x ", (adrs + i) << 1);
+                printf("%02x ", (adrs + i) << 1);
             }
         }
-        pc.printf("\n");
+        printf("\n");
     }
         
     while (true) {
         led1 = !led1;
-        wait(0.5);
+        thread_sleep_for(0.5);
     }
 }