nrf5340dk SPI communication with BMI270 gyroscope

Hello, I am trying to communicate with a Bosch BMI 270 device(datasheet) using the nrf5340dk. I originally tried to use I2C since there was an example file available for this but I didn't manage to get it working and I'm supposed to use SPI anyways. I macgyvered something together from the bmi270 file in the zephyr/sensor folder and an example I found for SPI communication with the nrf5340dk.

Overlay file:

For I2C you're supposed to use the 0x68 register but I couldn't find one for SPI in the datasheet so I just used the same(probably wrong)

Project config:

Where it gets stuck in main.c(device_get_binding returns NULL, same with I2C):

To configure the BMI270 into SPI you were supposed to have a rising edge on CSB after startup so I used a button.

I am completely new to the nrf5340 and nordic products. My only previous experience is with Arduino and mbed so this feels like a pretty big jump in terms of complexity. I use macOS and v1.9.1 nrf sdk. 

  • Hello,

    For I2C you're supposed to use the 0x68 register but I couldn't find one for SPI in the datasheet so I just used the same(probably wrong)

    Yes, that is wrong. Since SPI is using the master-slave principle, you have to add the slave number counting from 0, instead of the physical I2C bus address.

    Referring to the ADXL362 sample, and especially the containing .overlay file as a reference.

    Please be aware that the nRF5340 application core has i2c1 enabled by default. Due to memory instantiation, you have to disable i2c1 if you would like to run spi1. You can check the status and its dependencies in ../<build_folder>/zephyr/zephyr.dts after performing a successful build.

    Regards,

    Markus

Related