Dan Allen
/
MAX11410_test
test program to power up two MAX11410 ADCs and check the inputs of ADC1. Uses MAX11410 library.
main.cpp
- Committer:
- smartsystemdesign
- Date:
- 2016-11-18
- Revision:
- 4:c194858fe0c6
- Parent:
- 3:42120705a9bd
- Child:
- 5:d7b803aa9079
File content as of revision 4:c194858fe0c6:
// 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 // // - Note: if you plug / unplug devices try cycling power #include "mbed.h" I2C i2c(I2C_SDA, I2C_SCL); // sda, scl Ticker repeatTicker; void repeat() { printf("I2CU! Searching for I2C devices...\n"); int count = 0; for (int address=0; address<256; address+=2) { bool temp = i2c.write(address, NULL, 0); // 0 if successful, otherwise non-zero if (!temp && (address >> 1) != 0) { // not interested in address 0 printf(" - I2C device found at address 0x%02X (7 bit - Arduino) or 0x%02X (8 bit - mbed)\n", address >> 1, address); count++; } } printf("%d device(s) found\n", count); } int main() { repeatTicker.attach(&repeat, 2.0); }