Util used to scan for I2C devices
Fork of PRES11_I2C_Detect by
I2C program used to scan the I2C bus for connected devices
Import program
00001 #include "mbed.h" 00002 00003 //SDA , SCL 00004 I2C i2cBus(I2C_SDA, I2C_SCL); 00005 00006 int main() 00007 { 00008 i2cBus.frequency(100000); 00009 00010 printf("\r\n Scanning for I2C devices (addresses in hex)\r\n "); 00011 printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n"); 00012 for (int i = 0; i < 128; i += 16) { 00013 printf("%02x: ", i); 00014 for(int j = 0; j < 16; j++) { 00015 // Skip unwanted addresses 00016 if (i+j < 0x3 || i+j > 0x77) { 00017 printf(" "); 00018 continue; 00019 } 00020 00021 if (!i2cBus.write(i+j<<1, NULL, 0)) 00022 printf("%02x ", i+j); 00023 else 00024 printf("-- "); 00025 00026 } 00027 printf("\r\n"); 00028 } 00029 } 00030
Revisions of mbed.bld
Revision | Date | Message | Actions |
---|---|---|---|
0:9e51d4453b53 | 2015-11-09 | First comit | File Diff Annotate |