test program to power up two MAX11410 ADCs and check the inputs of ADC1. Uses MAX11410 library.

Dependencies:   MAX11410 mbed

Committer:
smartsystemdesign
Date:
Mon Oct 10 21:28:26 2016 +0000
Revision:
1:1cdd12a4efb2
Parent:
0:4f78cdfc99de
Child:
2:39ba9beabf3c
Bitshifted address to the right to print appropriate address.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:4f78cdfc99de 1 // I2CU - Search for devices on an I2C bus
simon 0:4f78cdfc99de 2 // Copyright (c) 2009, sford
simon 0:4f78cdfc99de 3 // Released under the MIT License: http://mbed.org/license/mit
simon 0:4f78cdfc99de 4 //
simon 0:4f78cdfc99de 5 // Goes through each device address, seeing if it gets a response
simon 0:4f78cdfc99de 6 // - for every device if finds, it prints the 8-bit address
simon 0:4f78cdfc99de 7 // - if the program hangs, the bus isn't working (check pull-ups etc)
simon 0:4f78cdfc99de 8 // - if it doesn't find your device, check power/bus wiring etc
simon 0:4f78cdfc99de 9
simon 0:4f78cdfc99de 10 #include "mbed.h"
simon 0:4f78cdfc99de 11
smartsystemdesign 1:1cdd12a4efb2 12 I2C i2c(I2C_SDA, I2C_SCL); // sda, scl
simon 0:4f78cdfc99de 13
simon 0:4f78cdfc99de 14 int main() {
simon 0:4f78cdfc99de 15 printf("I2CU! Searching for I2C devices...\n");
simon 0:4f78cdfc99de 16
simon 0:4f78cdfc99de 17 int count = 0;
simon 0:4f78cdfc99de 18 for (int address=0; address<256; address+=2) {
simon 0:4f78cdfc99de 19 if (!i2c.write(address, NULL, 0)) { // 0 returned is ok
smartsystemdesign 1:1cdd12a4efb2 20 printf(" - I2C device found at address 0x%02X\n", address >> 1);
simon 0:4f78cdfc99de 21 count++;
simon 0:4f78cdfc99de 22 }
simon 0:4f78cdfc99de 23 }
simon 0:4f78cdfc99de 24 printf("%d devices found\n", count);
simon 0:4f78cdfc99de 25 }