Hi frasics, Could you try the following snippets for read and write? s8 BNO055_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
s32 BNO055_iERROR = 0; // this is the "status" we usually use in our R/W functions
u8 idx;
BNO055_iERROR = I2C_MasterSendStart(dev_addr, I2C_WRITE_XFER_MODE);
// Check for BNO055_iERROR before proceeding
BNO055_iERROR = I2C_MasterWriteByte(reg_addr);
for (idx = 0; (idx < cnt) && (BNO055_iERROR == 0); idx++)
{
BNO055_iERROR = I2C_MasterWriteByte(reg_data[idx]);
}
// Check for BNO055_iERROR before proceeding
BNO055_iERROR = I2C_MasterSendStop();
return (s8)BNO055_iERROR;
}
s8 BNO055_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
s32 BNO055_iERROR = 0; // this is the "status" we usually use in our R/W functions
u8 idx;
BNO055_iERROR = I2C_MasterSendStart(dev_addr, I2C_WRITE_XFER_MODE);
// Check for BNO055_iERROR before proceeding
BNO055_iERROR = I2C_MasterWriteByte(reg_addr);
// Check for BNO055_iERROR before proceeding
BNO055_iERROR = I2C_MasterSendStop();
BNO055_iERROR = I2C_MasterSendStart(dev_addr, I2C_READ_XFER_MODE);
for (idx = 0; (idx < cnt) && (BNO055_iERROR == 0); idx++)
{
reg_data[idx] = I2C_MasterReadByte(I2C_ACK_DATA);
}
// Check for BNO055_iERROR before proceeding
BNO055_iERROR = I2C_MasterSendStop();
return (s8)BNO055_iERROR;
}
... View more