07-07-2020 07:56 AM
Hi everyone,
I have a question regarding the switching in Power Modes. What can I understand is that there are two ways to change power mode:
EITHER
sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
rslt = bmi160_set_sens_conf(&sensor);
OR
sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
rslt = bmi160_set_power_mode(&sensor);
Which function should I use in order to change properly power mode? Should I should both functions? Should I use both functions but in a particular order?
Please advice
Thanks in advance
Nick
Solved! Go to Solution.
07-07-2020 08:11 AM
Hello,
From API code as bellow, two function are different. So you could follow example code to make configuration.
/*!
* @brief This API configures the power mode, range and bandwidth
* of sensor.
*/
int8_t bmi160_set_sens_conf(struct bmi160_dev *dev)
{
int8_t rslt = BMI160_OK;
/* Null-pointer check */
if ((dev == NULL) || (dev->delay_ms == NULL))
{
rslt = BMI160_E_NULL_PTR;
}
else
{
rslt = set_accel_conf(dev);
if (rslt == BMI160_OK)
{
rslt = set_gyro_conf(dev);
if (rslt == BMI160_OK)
{
/* write power mode for accel and gyro */
rslt = bmi160_set_power_mode(dev);
if (rslt == BMI160_OK)
{
rslt = check_invalid_settg(dev);
}
}
}
}
return rslt;
}
/*!
* @brief This API sets the power mode of the sensor.
*/
int8_t bmi160_set_power_mode(struct bmi160_dev *dev)
{
int8_t rslt = 0;
/* Null-pointer check */
if ((dev == NULL) || (dev->delay_ms == NULL))
{
rslt = BMI160_E_NULL_PTR;
}
else
{
rslt = set_accel_pwr(dev);
if (rslt == BMI160_OK)
{
rslt = set_gyro_pwr(dev);
}
}
return rslt;
}
07-07-2020 08:55 AM
Thank you for your reply fish
Actually the bmi160_set_sens_conf() includes the bmi160_set_power_mode()..
So I could use either the bmi160_set_sens_conf() or the bmi160_set_power_mode() to switch power mode right? It is identical isn't it?
07-08-2020 01:07 AM
Yes, they are identical if you put correct power mode value into configure data group already.