Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    bmi2.c v/s bmi270.c in BMI270_API

    bmi2.c v/s bmi270.c in BMI270_API

    punitjain8695
    Member

    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:

    bmi2_get_gyro_cross_sense
    bmi2_sec_init

    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

    Minhwan
    Community Moderator
    Community Moderator

    Hello punitjain8695, 

     

    From your issue, I believe that you are using our bmi270 github api from https://github.com/BoschSensortec/BMI270-Sensor-API. 

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

    https://github.com/BoschSensortec/BMI270-Sensor-API/blob/master/examples/bmi2_ois/ois_accel_gyro/ois...

    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. 

    Thanks, 

    Hi,

    The said file works using the common.c file in the adjoining directory named common (https://github.com/BoschSensortec/BMI270-Sensor-API/tree/master/examples/bmi2_ois/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.

     

    Thanks

    Punit

     

    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 

    https://github.com/BoschSensortec/BMI270-Sensor-API/tree/master/examples/bmi270

    and https://github.com/BoschSensortec/BMI270-Sensor-API

    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);
    }

    Thanks, 

    Hi,

    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?

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist