Hi everyone,
I want to truning bmi160 from normal mode to suspend mode for reduce current and set suspend mode to normal mode when i need to capture data.
Now I can set bmi160 in to normal mode and get data, but when i alway get BMI160_E_COM_FAIL(-2) when set normal mode to suspend mode.Any suggestion to solve this problem?
static void Spi_sensor_init( void ) {
/* You may assign a chip select identifier to be handled later */
s_spi_bmi160_sensor.id = 0 ;
s_spi_bmi160_sensor.interface = BMI160_SPI_INTF ;
s_spi_bmi160_sensor.read = Spi_read_transfer ;
s_spi_bmi160_sensor.write = Spi_write_transfer ;
s_spi_bmi160_sensor.delay_ms = Spi_delay_ms ;
int8_t rslt = BMI160_OK ;
rslt = bmi160_init( &s_spi_bmi160_sensor ) ;
if ( rslt == 0 ) {
SEGGER_RTT_printf( 0,"Get bmi160 data success ! \n", rslt ) ;
} // if
else
SEGGER_RTT_printf( 0,"Error : Get bmi160 data fail ! \n", rslt ) ;
/* After the above function call, accel_cfg and gyro_cfg parameters in the device
structure are set with default values, found in the datasheet of the sensor */
rslt = BMI160_OK ;
/* Select the Output data rate, range of accelerometer sensor */
s_spi_bmi160_sensor.accel_cfg.odr = BMI160_ACCEL_ODR_100HZ ;
s_spi_bmi160_sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G ;
s_spi_bmi160_sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4 ;
/* Select the power mode of accelerometer sensor */
s_spi_bmi160_sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE ;
/* Select the Output data rate, range of Gyroscope sensor */
s_spi_bmi160_sensor.gyro_cfg.odr = BMI160_GYRO_ODR_100HZ ;
s_spi_bmi160_sensor.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS ;
s_spi_bmi160_sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE ;
/* Select the power mode of Gyroscope sensor */
s_spi_bmi160_sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE ;
/* Set the sensor configuration */
rslt = bmi160_set_sens_conf( &s_spi_bmi160_sensor ) ;
/* Select the power mode */
s_spi_bmi160_sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE ;
s_spi_bmi160_sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE ;
/* Set the Power mode */
rslt = bmi160_set_power_mode( &s_spi_bmi160_sensor ) ;
nrf_delay_ms( 10 ) ; // delay_10ms
} // Spi_sensor_Sensor_init()
static void Spi_sensor_poweroff( void ) {
int8_t rslt = BMI160_OK ;
s_spi_bmi160_sensor.accel_cfg.power = BMI160_ACCEL_SUSPEND_MODE ;
s_spi_bmi160_sensor.gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE ;
rslt = bmi160_set_power_mode( &s_spi_bmi160_sensor ) ;
SEGGER_RTT_printf(0,"bmi160_set_power_mode rslt = %d\n", rslt);
}