i2c, scan
Nucleo I2C Doesn't work if rtos library present in project. Example:
main.cpp
- Committer:
- Dzhafarkhanov
- Date:
- 2016-02-04
- Revision:
- 0:f971dfcdb7ad
File content as of revision 0:f971dfcdb7ad:
#include "mbed.h"
#define D_SDA I2C_SDA
#define D_SCL I2C_SCL
I2C i2c(D_SDA, D_SCL);
Serial pc(SERIAL_TX, SERIAL_RX);
char data [255];
int i;
int main()
{
pc.printf("started.. \n");
// Scan for I2C devices that reply with ack
for (i=0; i<=254; i=i+2) {
if (i2c.read(i, &data[0], 1) ==0)
{
pc.printf("I2C device detected at address=%2.2X\n\r", i);
}
}
}