### Get Accelerometer and Gyroscope Data via OIS Interface Source: https://github.com/boschsensortec/bmi270_sensorapi/blob/master/OIS_README.md This snippet demonstrates how to enable sensors, configure OIS range, and read accelerometer and gyroscope data through the OIS interface. It includes steps for initializing the BMI2 sensor, enabling desired sensors, setting OIS range, and then reading OIS data. ```c int8_t rslt; /* Array to enable sensor through host interface */ uint8_t sens_list[2] = {BMI2_ACCEL, BMI2_GYRO}; /* Array to enable sensor through OIS interface */ uint8_t sens_sel[2] = {BMI2_OIS_ACCEL, BMI2_OIS_GYRO}; /* Initialize the configuration structure */ struct bmi2_sens_config sens_cfg = {0}; /* Initialize BMI2 */ rslt = bmi2_init(&dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Enable accelerometer and gyroscope through host interface */ rslt = bmi2_sensor_enable(sens_list, 2, &dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Setting of OIS Range is done through host interface */ /* Select the gyroscope sensor for OIS Range configuration */ sens_cfg.type = BMI2_GYRO; /* Get gyroscope configuration */ rslt = bmi2_get_sensor_config(&sens_cfg, 1, &dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Set the desired OIS Range */ sens_cfg.cfg.gyr.ois_range = BMI2_GYR_OIS_2000; /* Set gyroscope configuration for default values */ rslt = bmi2_set_sensor_config(&sens_cfg, 1, &dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Enable OIS through host interface */ rslt = bmi2_set_ois_interface(BMI2_ENABLE, &dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Disable Advance Power Save Mode through host interface */ rslt = bmi2_set_adv_power_save(BMI2_DISABLE, &dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Get configurations for OIS through OIS interface for default values */ rslt = bmi2_ois_get_config(&ois_dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } /* Enable accelerometer and gyroscope for reading OIS data */ ois_dev.acc_en = BMI2_ENABLE; ois_dev.gyr_en = BMI2_ENABLE; /* Set configurations for OIS through OIS interface */ rslt = bmi2_ois_set_config(&ois_dev); if (rslt == BMI2_OK) { /* Get OIS accelerometer and gyroscope data through OIS interface */ rslt = bmi2_ois_read_data(sens_sel, 2, &ois_dev); if (rslt == BMI2_OK) { /* Print accelerometer data */ printf("OIS Accel x-axis = %d\t", ois_dev.acc_data.x); printf("OIS Accel y-axis= %d\t", ois_dev.acc_data.y); printf("OIS Accel z-axis = %d\r\n", ois_dev.acc_data.z); /* Print gyroscope data */ printf("OIS Gyro x-axis = %d\t", ois_dev.gyr_data.x); printf("OIS Gyro y-axis= %d\t", ois_dev.gyr_data.y); printf("OIS Gyro z-axis = %d\r\n", ois_dev.gyr_data.z); } } if (rslt != BMI2_OK) { printf("Error code: %d\n", rslt); return; } /* Enable Advance Power Save Mode through host interface */ rslt = bmi2_set_adv_power_save(BMI2_ENABLE, &dev); if (rslt != BMI2_OK) { printf("Error: %d\n", rslt); return; } ``` -------------------------------- ### Include OIS and Variant Headers Source: https://github.com/boschsensortec/bmi270_sensorapi/blob/master/OIS_README.md Include the bmi2_ois.h header for OIS API calls and a variant header for initialization and BMI2 API calls. ```c #include "bmi261.h" #include "bmi2_ois.h" ``` -------------------------------- ### Configure SPI for OIS Interface Source: https://github.com/boschsensortec/bmi270_sensorapi/blob/master/OIS_README.md Initializes the bmi2_ois_dev structure for SPI communication. Ensure that the interface pointer, read/write functions, delay, and sensor enable flags are correctly set. ```c int8_t rslt = 0; struct bmi2_ois_dev ois_dev = { .intf_ptr = intf_ptr will contain the chip selection info of SPI CS pin, .ois_read = user_spi_reg_read, .ois_write = user_spi_reg_write, .ois_delay_us = user_delay_us }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.