This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrfx_TWI to access Bosch BNO055... low-level ops needed

I'm using nRF52832 and intend to interface 3 I2C slave devices; the first is the BNO055 IMU.

I've integrated the Bosch "driver" code into my SES project, but I find that their "low-level" code

(that would actually use the I2C) is just "stubs".  The key methods that need to be implemented

are: 

BNO055_I2C_bus_write and BNO055_I2C_bus_read.

My intent was to plug in "TWI" operations to accomplish this; I've gone 'round and 'round with

all of the "TWI legacy" stuff like "nrf_drv_twi_xxx" vs "nrfx_twi_xxx" and believe that the "nrfx..."

(under "..\modules", not "..\components" (which seems "deprecated") is probably the way to go.

But I'm kinda stuck here.   Some questions:

  a) is this the right way to proceed?

  b) has anyone already done this? ("nrfx TWI" to BNO055)

  c) If I'm using nRF52832 as "master", I'm thinking that I don't need any of the "TWIS" mechanism,

   as I'm only talking to external "slave" devices, not trying to use the '52 "as" a slave, correct?

  d) will H/W TWI deal with async responses from multiple I2C slaves "concurrently" (I'm unclear

on how "arbitration" might work in this scenario), or must I resort to synchronous, sequential "polling"

style of device access?

Thanks so much for any direction & suggestions!

Jim

Parents
  • Hi,

    It sounds like you got most of it correct.

    a) Yes. I understand your confusion though. Issues related to mixed legacy and nrfx drivers is a common topic on devzone these days. If you are starting a new project now I suggest that you use the nrfx drivers. In my experience, the TWI master driver documentation is applicable for the nrx drivers, just substitute all occurrences of nrf_drv_twi with nrfx_twim. You can read more about nrfx here

    b) I couldn't find any finished libraries or anything, but at least you are not the first to first to ask about BNO055 here on devzone.

    c) That is correct. 

    d) If the nRF52 is the only master on the bus (which it usually is), you don't need to worry about that. It is the master that is responsible for initiating all communications, and the slaves should never start "talking" unless spoken to. I see that the BNO055 has an interrupt pin that it can use to notify the master that new data is available, but the way it usually works is that the interrupt pin trigger an interrupt in the master, and then the master decides when to read the data. 

    Here is some good documentation on the I2C protocol: https://www.i2c-bus.org/

Reply
  • Hi,

    It sounds like you got most of it correct.

    a) Yes. I understand your confusion though. Issues related to mixed legacy and nrfx drivers is a common topic on devzone these days. If you are starting a new project now I suggest that you use the nrfx drivers. In my experience, the TWI master driver documentation is applicable for the nrx drivers, just substitute all occurrences of nrf_drv_twi with nrfx_twim. You can read more about nrfx here

    b) I couldn't find any finished libraries or anything, but at least you are not the first to first to ask about BNO055 here on devzone.

    c) That is correct. 

    d) If the nRF52 is the only master on the bus (which it usually is), you don't need to worry about that. It is the master that is responsible for initiating all communications, and the slaves should never start "talking" unless spoken to. I see that the BNO055 has an interrupt pin that it can use to notify the master that new data is available, but the way it usually works is that the interrupt pin trigger an interrupt in the master, and then the master decides when to read the data. 

    Here is some good documentation on the I2C protocol: https://www.i2c-bus.org/

Children
No Data
Related