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 PRES11_I2C_Detect by
Revision 0:9e51d4453b53, committed 2015-11-09
- Comitter:
- rlanghbv
- Date:
- Mon Nov 09 13:21:03 2015 +0000
- Child:
- 1:624dc0072a11
- Commit message:
- First comit
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 09 13:21:03 2015 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" + +//SDA , SCL +I2C i2cBus(PB_9, PB_8); + +int main() +{ + i2cBus.frequency(100000); + + printf("\r\n Scanning for I2C devices (addresses in hex)\r\n "); + printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n"); + for (int i = 0; i < 128; i += 16) { + printf("%02x: ", i); + for(int j = 0; j < 16; j++) { + // Skip unwanted addresses + if (i+j < 0x3 || i+j > 0x77) { + printf(" "); + continue; + } + + if (!i2cBus.write(i+j<<1, NULL, 0)) + printf("%02x ", i+j); + else + printf("-- "); + + } + printf("\r\n"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Nov 09 13:21:03 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file