Hi,
Forgive my lack of expert knowledge on this subject. I am working on interfacing the FRDM-STBC-AGM01 (FXOS8700CQ and FXAS21002). Due to this setup type with beaglebone I am unable to get any of the toolbars to work. I am trying to get started by reading the WHO_AM_I and writing to CTRL_REG1 on the board using i2c. The program only prints zero value for both cases. Can an expert suggest what I am doing wrong?
int main(void)
{
char rxBuffer[32];
char txBuffer[32];
int gyroAddress = 0x20;
int xlAddress = 0x1E;
int tenBitAddress = 0;
int opResult = 0;
int i2cHandle = open("/dev/i2c-1", O_RDWR);
opResult = ioctl(i2cHandle, I2C_TENBIT, tenBitAddress);
opResult = ioctl(i2cHandle, I2C_SLAVE, gyroAddress);
memset(rxBuffer, 0, sizeof(rxBuffer));
memset(txBuffer, 0, sizeof(txBuffer));
//
txBuffer[0] = 0x0C;
opResult = write(i2cHandle, txBuffer, 1);
if (opResult != 1) printf("No ACK bit!\n");
opResult = read(i2cHandle, rxBuffer, 1);
printf("Part ID: %d\n", (int)rxBuffer[0]);
opResult = ioctl(i2cHandle, I2C_SLAVE, xlAddress);
txBuffer[0] = 0x0D;
opResult = write(i2cHandle, txBuffer, 1);
if (opResult != 1) printf("No ACK bit!\n");
opResult = read(i2cHandle, rxBuffer, 1);
printf("Part ID: %d\n", (int)rxBuffer[0]);
}
I can read values from the sensor using i2cget/dump commands. Program seems simple but still does not function. Any hints?
Thank you.