I came across a strange problem with I2C init (ChibiOS-ver21.11.3). Basically, I have to start the I2C device twice, with a stop in between, to make any contact with my magnetometer:
Code: Select all
i2cStart(&I2CD1, &i2c1cfg);
chThdSleepMilliseconds(100);
// If I don't execute the below lines...
i2cStop(&I2CD1);
i2cStart(&I2CD1, &i2c1cfg);
chThdSleepMilliseconds(100);
// ... the following I2C transmit hangs forever
i2cMasterTransmit(dev, HMC5883L_I2C_ADDR, ®, 1, in, n);
It seems that if I do stop and re-start I2CD1, everything works fine.
Is there something I am doing wrong?
m