Pull-Request to fix asymmetric bmi08a_get_meas_conf() and bmi08a_set_meas_conf()

Hi,

I opened up a pull-request https://github.com/boschsensortec/BMI08x_SensorAPI/pull/23

Function bmi08a_get_meas_conf() handles getting ODR, bandwidth and range:

> /*!
>  * @brief This API reads the accel config value i.e. odr, band width and range from the sensor,
>  * store it in the bmi08_dev structure instance passed by the user.
>  *
>  */

while bmi08a_set_meas_conf() only does ODR and bandwidth without range:

> /*!
>  * @brief This API sets the output data rate and bandwidth
>  * of accel sensor.
>  */

To fix the asymmetry, I added acceleration range setting to bmi08a_set_meas_conf(). I tried to stick to the API's coding style. Please review and merge.

If you don't like this, e.g. to not break other code, one might alternatively consider a new function that only handles setting range, which needs to be handled anyway and is not part of the API:

/*!
 * @brief This API sets the acceleration range
 * of accel sensor.
 */
int8_t bmi08a_set_range_conf(struct bmi08_dev *dev){

int8_t rslt;
uint8_t range;
is_range_invalid = FALSE;
rslt = dev_null_ptr_check(dev);
/* Proceed if null check is fine */
    if (rslt == BMI08_OK)
    {
       range = dev->accel_cfg.range;
       if(range > BMI088_ACCEL_RANGE_24G)
       {
            /* Updating the status */
            is_range_invalid = TRUE;
        }
       if (!is_range_invalid)
       {
          rslt = bmi08a_get_set_regs(BMI08_REG_ACCEL_RANGE, &range, BMI08_REG_ACCEL_RANGE_LENGTH, dev, SET_FUNC);
          if (rslt == BMI08_OK)
          {
             /* Delay required to set accel configurations */
             dev->delay_us(BMI08_SET_ACCEL_CONF_DELAY * 1000, dev->intf_ptr_accel);
          }
       }
       else
       {
           /* Invalid configuration present in RANGE */
           rslt = BMI08_E_INVALID_CONFIG;
       }
   }
return rslt;
}

3 replies