03-13-2019 08:49 PM
Hello, I am an engineering student at the University of the Fraser Valley and was directed to get into contact with you about accessing the BNO055 data. We are using the Adafruit breakout board with the bno055, and are using a Cypress microcontroller to try and access the data. We are having trouble understanding how to program the read and write functions, and have been trying for over a month with no success. I have read through the bno055.c and bno055_support.c files many times, as well as the datasheet, but we are still stuck. Any help you can provide would be greatly appreciated. Thank you, Fraser Forbes
Solved! Go to Solution.
03-13-2019 10:19 PM
1. which interface you are configured for BNO055? UART or I2C or HID over I2C? it can be done by PS0 and PS1 pin status during power on the sensor.
2. if you select I2C interface for BNO055, then normal I2C read / write function should be good enough to build up the communication between host and BNO055 chip.
03-17-2019 06:21 PM
Thank you for your help and sorry for the late reply!
We are using I2C. Our problem has been making the read and write fuctions since they seem to have have very specific protocols that I don't believe we are noticing.
Here are the read/write functions from the support file that I am trying get functioning:
s8 BNO055_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
cnt = 1;
s32 BNO055_iERROR = 0; // this is the "status" we usually use in our R/W functions
u8 array[I2C_BUFFER_LEN];
u8 stringpos =0;
array[0] = reg_addr;
for (stringpos = 0; stringpos<cnt; stringpos++)
{
array[stringpos+BNO055_I2C_BUS_WRITE_ARRAY_INDEX] = *(reg_data+stringpos);
}
BNO055_iERROR = I2C_MasterSendStart(dev_addr, I2C_WRITE_XFER_MODE);
BNO055_iERROR = I2C_MasterWriteByte(array[1]);
BNO055_iERROR = I2C_MasterWriteByte(*reg_data);
BNO055_iERROR = I2C_MasterSendStop();
return (s8)BNO055_iERROR;
}
s8 BNO055_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
dev_addr = dev_addr;
s32 BNO055_iERROR = BNO055_INIT_VALUE; // the s32 error var is = 0 (bno055_init_value=0)
u8 array[I2C_BUFFER_LEN]; // buffer_len = 8
u8 stringpos = 0;
array[0] = reg_addr; //set 0 of array to reg_addr
BNO055_iERROR = I2C_MasterSendStart(dev_addr, I2C_WRITE_XFER_MODE);
BNO055_iERROR = I2C_MasterWriteByte(array[1]);
BNO055_iERROR = I2C_MasterSendStop();
for (stringpos = 0; stringpos < cnt; stringpos++) // counts through the entire reg_addr
{
BNO055_iERROR = I2C_MasterSendStart(dev_addr, I2C_READ_XFER_MODE);
array[stringpos] = I2C_MasterReadByte(I2C_ACK_DATA);// saves each byte to a different array pos
*(reg_data + stringpos)=array[stringpos];
}
array[stringpos+1] = I2C_MasterReadByte(I2C_NAK_DATA);
*(reg_data + stringpos)= array[stringpos];
u8 comp =0;
for(comp = 0;comp<cnt; comp++)
{
BNO055_iERROR =
}
BNO055_iERROR = I2C_MasterSendStop();
return (s8) BNO055_iERROR;
}
void BNO055_delay_msek(u32 msek)
{
CyDelay(msek);
}
03-18-2019 10:33 AM
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; }