bmi2_ois.c
/*!
 * @brief This API reads accelerometer/gyroscope data through OIS interface.
 */
@brief This API reads accelerometer/gyroscope data through OIS interface.
@brief This API reads accelerometer / gyroscope data through OIS interface .
int8_t bmi2_ois_read_data(const uint8_t *sens_sel,
                          uint8_t n_sens,
                          struct bmi2_ois_dev *ois_dev,
                          int16_t gyr_cross_sens_zx)
{
    int8_t rslt;
    uint8_t loop = 0;
    uint8_t reg_addr = 0;
    rslt = null_ptr_check(ois_dev);
    if ((rslt == BMI2_OIS_OK) && (sens_sel != NULL))
    {
        for (loop = 0; loop < n_sens; loop++)
        {
            switch (sens_sel[loop])
            {
                case BMI2_OIS_ACCEL:
                    reg_addr = BMI2_OIS_ACC_X_LSB_ADDR;
                    rslt = get_ois_acc_gyr_data(&ois_dev->acc_data, reg_addr, ois_dev, 0);
                    break;
                case BMI2_OIS_GYRO:
                    reg_addr = BMI2_OIS_GYR_X_LSB_ADDR;
                    rslt = get_ois_acc_gyr_data(&ois_dev->gyr_data, reg_addr, ois_dev, gyr_cross_sens_zx);
                    break;
                default:
                    rslt = BMI2_OIS_E_INVALID_SENSOR;
                    break;
            }
            if (rslt != BMI2_OIS_OK)
            {
                break;
            }
        }
    }
    else
    {
        rslt = BMI2_OIS_E_NULL_PTR;
    }
    return rslt;
}
int8_t bmi2_ois_read_data ( const uint8_t * sens_sel , uint8_t n_sens , struct bmi2_ois_dev * ois_dev , int16_t gyr_cross_sens_zx ) { int8_t rslt ; uint8_t loop = 0 ; uint8_t reg_addr = 0 ; rslt = null_ptr_check ( ois_dev ) ; if ( ( rslt == BMI2_OIS_OK ) && ( sens_sel != NULL ) ) { for ( loop = 0 ; loop < n_sens ; loop ++ ) { switch ( sens_sel [ loop ] ) { case BMI2_OIS_ACCEL : reg_addr = BMI2_OIS_ACC_X_LSB_ADDR ; rslt = get_ois_acc_gyr_data ( & ois_dev -> acc_data , reg_addr , ois_dev , 0 ) ; break ; case BMI2_OIS_GYRO : reg_addr = BMI2_OIS_GYR_X_LSB_ADDR ; rslt = get_ois_acc_gyr_data ( & ois_dev -> gyr_data , reg_addr , ois_dev , gyr_cross_sens_zx ) ; break ; default : rslt = BMI2_OIS_E_INVALID_SENSOR ; break ; } if ( rslt != BMI2_OIS_OK ) { break ; } } } else { rslt = BMI2_OIS_E_NULL_PTR ; } return rslt ; }
@brief This API reads accelerometer/gyroscope data through OIS interface.
@brief This API reads accelerometer / gyroscope data through OIS interface .
/* Variable to define error */ /* Variable to define loop */ /* Variable to update register address */ /* Null-pointer check */ /* Update OIS accelerometer address */ /* Get OIS accelerometer data */ /* Update OIS gyroscope address */ /* Get OIS gyroscope data */ /* Return error if any of the get sensor data fails */