test program to power up two MAX11410 ADCs and check the inputs of ADC1. Uses MAX11410 library.
Fork of I2C_scanner by
Diff: main.cpp
- Revision:
- 0:4f78cdfc99de
- Child:
- 1:1cdd12a4efb2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 03 21:51:26 2009 +0000 @@ -0,0 +1,25 @@ +// 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); +}