Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    bmi2.c v/s bmi270.c in BMI270_API

    bmi2.c v/s bmi270.c in BMI270_API


    I'm interfacing the BMI270 shuttle board with TI's TM4C1294NCPDT based evaluation board. It's a 32-bit arm-based microcontroller.

    I'm trying to use BMI270_API.

    I've read the value at register address 0x00. it is 0x24. This was done using the bmi2_ois.c file, using the function:

    int8_t bmi2_ois_get_regs(uint8_t ois_reg_addr, uint8_t *ois_reg_data, uint16_t data_len, struct bmi2_ois_dev *ois_dev)

    Now, I was going ahead with initializing the sensor so that I can get to my target of reading acceleration and gyro values. For this, I understand (as of now), that I have to use the function defined in bmi270.c:

    int8_t bmi270_init(struct bmi2_dev *dev)


    This requires two variations, first is, the dev structure is different, which I have defined separately. and another, inclusion of the bmi270.c file during the compilation.

    This throws error of declaration being incompatible for

    static int8_t null_ptr_check(const struct bmi2_ois_dev *ois_dev);  in bmi2_ois.c

    and static int8_t null_ptr_check(const struct bmi2_dev *dev); in bmi270.c

    which is obvious since both of these work on different dev structures of different kinds.

    I then tried the following:

    I removed the bmi2_ois.c from the compilation includes which results in the errors for unresolved symbols for these:


    Again, I tried to include bmi270.c and bmi2.c, which results in multiple definitions of several functions.

    Am I doing something incorrectly? What is the proper procedure to do this?


    11 REPLIES 11

    Community Moderator
    Community Moderator

    Hello punitjain8695, 


    From your issue, I believe that you are using our bmi270 github api from 

    And you want to use OIS, so you might use our OIS example

    If so, could you share the rslt value after you call each function? 

    If there is not 0, it means that there is some error. 

    Then, we can check why it happens. 



    The said file works using the common.c file in the adjoining directory named common (

    This common.c file works using coines.c file which is, as I understand, something not related to the BMI270 sensor. I couldn't find the definitions for the functions used in the common.c file anywhere.

    I can use the sensor as only SPI as well. (I do not understand the difference between the SPI and OIS interfaces). I do not need the OIS. So, if it is straightforward using the SPI mode (using bmi2.c and bmi270.c), please let me know.

    The way I see it, the several files have common functions defined, and some are interdependent.

    For example, bmi2.c and bmi270.c both are interdependent as well as having overlapping function definitions.

    The readme file doesn't contain what is mentioned in the OIS readme file.





    Hello punitjain8695, 


    Okay, let's clear. 

    If you don't need OIS and you just want to use BMI270 accel gyro using SPI, please ignore ois part. 

    You just need to check


    Regarding common.c, if you are using our Dev kit, but your own device, you need to remove coines part and put your own interface function. The purpose of common.c is making interface abstraction layer. 

    Therefore, you should change your SPI write read function  like below. 

    * SPI read function map to COINES platform
    BMI2_INTF_RETURN_TYPE bmi2_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
    uint8_t dev_addr = *(uint8_t*)intf_ptr;

    return your_own_read_spi(dev_addr, reg_addr, reg_data, (uint16_t)len);



    I have a few more doubts.

    Does this mean, that I could only use bmi270.c and that is all? because it doesn't look like so, as there are two functions missing in it.

    However, I can manually copy-paste them from bmi2.c to bmi270.c.

    These functions are:

    bmi2_get_gyro_cross_sense, and bmi2_sec_init.

    And does this also mean that the common.c is just an example? I have defined the hardware abstraction layer functions for the TIVA and spi in a separate file and am able to link them to the dev structure as required in bmi270.c. But, in order to read or write any register, I need the reg read functions which are in bmi2.c

    Can't the documentation include what the overall hierarchy of the various abstractions is?