Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of i2c_detect by
main.cpp
00001 #include "mbed.h" 00002 00003 //SDA , SCL 00004 //I2C i2cBus(I2C_SDA, I2C_SCL); 00005 I2C i2cBus(p9, p10); 00006 00007 int main() 00008 { 00009 i2cBus.frequency(100000); 00010 00011 printf("\r\n Scanning for I2C devices (addresses in hex)\r\n "); 00012 printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n"); 00013 for (int i = 0; i < 128; i += 16) { 00014 printf("%02x: ", i); 00015 for(int j = 0; j < 16; j++) { 00016 // Skip unwanted addresses 00017 if (i+j < 0x3 || i+j > 0x77) { 00018 printf(" "); 00019 continue; 00020 } 00021 00022 if (!i2cBus.write(i+j<<1, NULL, 0)) 00023 printf("%02x ", i+j); 00024 else 00025 printf("-- "); 00026 00027 } 00028 printf("\r\n"); 00029 } 00030 } 00031
Generated on Sat Jul 23 2022 10:28:25 by
