Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMX160 read and write function

    st105883
    New Poster

    BMX160 read and write function

    Hi all,

    as part of my masters thesis I need to connect the Bosch Bmx160 Shuttle board to an Infineon Aurix Triboard MC so I can read accel and gyro data. However, I have a few questions about the initialization of the sensor.
    1. The first question is if i have to set the sensor Id to "0" or to "BMI160_CHIP_ID" ( which is 0xD8 in my case)?
    2. What do I have to write in the Read and Write Function? Do I have to write the two functions myself or is this the interface with my MC that I just have to put in? If I have to write the function myself, what does it look like?

    Please sorry if the questions sound too stupid, but I am quite new with the programming language as well as with sensors and MCs. I am just trying to understand how all this works.🙈

    Thank you and best regards

     

     

     

    "int8_t user_spi_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len);"
     "int8_t user_spi_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len);"
    
    
    sensor.id = 0;
    sensor.interface = BMI160_SPI_INTF;
    sensor.read = user_spi_read;
    sensor.write = user_spi_write;
    sensor.delay_ms = user_delay_ms;

     

     

     

     

    1 REPLY 1
    Minhwan
    Community Moderator

    Re: BMX160 read and write function

    Hello st105883,

     

    First of all, my comment is based on our official code. 

    https://github.com/BoschSensortec/BMI160_driver

     

    1. The first question is if i have to set the sensor Id to "0" or to "BMI160_CHIP_ID" ( which is 0xD8 in my case)?

    - If you are using SPI and only one slave, it is okay to put 0 value, but I'd like to recommend to put the GPIO value for BMX160 chip select pin in Infineon device. 
    2. What do I have to write in the Read and Write Function? Do I have to write the two functions myself or is this the interface with my MC that I just have to put in? If I have to write the function myself, what does it look like?

    Simply say, you have to write your own SPI write or read function in bmi160_read_spi and bmi160_write_spi for communication between MCU and BMX160. I attached an example code.

     

    Thanks,  

    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