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.
Dependencies: BLE_API i2c-serial-conflict nRF51822
Fork of capstone_i2c by
Diff: main.cpp
- Revision:
- 2:2082f0f50590
- Parent:
- 1:e2ba28405dd5
- Child:
- 3:3d08e2045bde
--- a/main.cpp Mon Apr 10 02:19:13 2017 +0000
+++ b/main.cpp Mon Apr 10 22:10:08 2017 +0000
@@ -203,6 +203,21 @@
Wire.begin(SCL, SDA, TWI_FREQUENCY_100K);
pc.printf("IIC Demo Start \r\n");
+ int nDevices = 0;
+ for (int i = 0; i < 128; i++) {
+ uint8_t i2caddr = (i << 1);
+ Wire.beginTransmission(i2caddr);
+ int error = Wire.endTransmission();
+ if(error == 0) {
+ pc.printf("I2C device found at 0x%x\n", i);
+ nDevices++;
+ }
+ }
+ if (nDevices == 0){
+ pc.printf("No I2C devices found\n");
+ } else
+ pc.printf("done\n");
+
uint8_t* whoami = new uint8_t[1];
AT24C512_ReadBytes(REG_WHOAMI, whoami, 1, ADDR_ONE);
pc.printf("Whoami: %d\r\n", whoami[1]);
