I2C_2 bus scanner for STM32L476RG.

Dependencies:   mbed

Revision:
6:02a058f2ec6f
Parent:
5:a4fddd74263c
Child:
7:5962e77516ac
--- a/main.cpp	Mon Mar 21 04:09:15 2016 +0000
+++ b/main.cpp	Mon Mar 21 04:17:13 2016 +0000
@@ -1,10 +1,9 @@
 /* Scan I2C bus on specified pins and prints out
-* the all address where a active responder
-* is found. 
+* the all address where an active device responds.
 *
 * By Joe Elsworth CTO of A2WH
 * Free use for all but no warranty, no promises.
-* Don't forget 3K pullup sda,scl 
+* Don't forget 3K pull-up resistors on sda,scl 
 * 
 * I tested this by soldering in a I2C chip known to respond at
 * address dec=120 hex=70 and the utility got the ack as expected.
@@ -13,7 +12,6 @@
 
 #include "mbed.h"
 
-
 Serial pc(USBTX, USBRX);
 
  #define D_SDA                  PB_7 
@@ -26,8 +24,8 @@
 DigitalOut myled(LED1);
  
 int ack;   
+int address;  
 void scanI2C() {
-  int address;  
   for(address=1;address<127;address++) {    
     ack = i2c.write(address, "11", 1);
     if (ack == 0) {