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 MAX11410-test by
main.cpp
- Committer:
- simon
- Date:
- 2009-09-03
- Revision:
- 0:4f78cdfc99de
- Child:
- 1:1cdd12a4efb2
File content as of revision 0:4f78cdfc99de:
// I2CU - Search for devices on an I2C bus
// Copyright (c) 2009, sford
// Released under the MIT License: http://mbed.org/license/mit
//
// Goes through each device address, seeing if it gets a response
// - for every device if finds, it prints the 8-bit address
// - if the program hangs, the bus isn't working (check pull-ups etc)
// - if it doesn't find your device, check power/bus wiring etc
#include "mbed.h"
I2C i2c(p9, p10); // sda, scl
int main() {
printf("I2CU! Searching for I2C devices...\n");
int count = 0;
for (int address=0; address<256; address+=2) {
if (!i2c.write(address, NULL, 0)) { // 0 returned is ok
printf(" - I2C device found at address 0x%02X\n", address);
count++;
}
}
printf("%d devices found\n", count);
}
