Hello. I realise this is a fairly old post but I'm having exactly the same issue on BMX160 and wonder if you found a solution?
I'm running 4-wire SPI at 8MHz (3.3V). Here is some code to show the issue:
struct bmi160_dev sensor;
sensor.id = 0;
sensor.interface = BMI160_SPI_INTF;
sensor.read = user_spi_read;
sensor.write = user_spi_write;
sensor.delay_ms = user_delay_ms;
//STEP 1: read the chip-id to show we have a connection //
uint8_t read_test=0;
while(read_test!=216)
{bmi160_get_regs(BMI160_CHIP_ID_ADDR, &read_test, 1, &sensor); }
// OUTCOME: gives read_test=0xD8 as expected //
//STEP 2: write and read some data to a random register to show the write function is working //
uint8_t data = 10;
bmi160_set_regs(0x71, &data, 1, &sensor);
bmi160_get_regs(0x71, &read_test, 1, &sensor);
// OUTCOME: gives read_test=10 as expected //
//STEP 3: soft-reset //
data = 0xB6;
bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &data, 1, &sensor);
delay_ms(200); // I tried changing this value up to 3000
bmi160_get_regs(BMI160_PMU_STATUS_ADDR, &read_test, 1, &sensor);
// OUTCOME: gives read_test=0xFF from this point onwards all reads are 0xFF //
//STEP 3: write and read some data exactly the same as before //
data = 10;
bmi160_set_regs(0x71, &data, 1, &sensor);
sensor.delay_ms(1);
bmi160_get_regs(0x71, &read_test, 1, &sensor);
sensor.delay_ms(1);
//OUTCOME: gives read_test=0xFF, not 10 as expected//
//STEP 4: read the chip-id again//
while(read_test!=216)
{bmi160_get_regs(BMI160_CHIP_ID_ADDR, &read_test, 1, &sensor); } // read_test=0xFF ...!!??
//OUTCOME: now stuck in a loop. read_test=0xFF //
For STEP 2 I also tried "bmi160_soft_reset(&sensor)" and "bmi160_init(&sensor)" (which also uses the soft-reset).
These both had the same outcome.
If anyone can see what I am missing it would be a great help.
So I solved this not long after posting. In my 'user_spi_write(...)' the slave select pin was being pulled up straight after writing to the sensor. This worked fine except in the case of the soft-reset as this condition during power-up sends the sensor into I2C mode. An spi_read or rising edge did not bring it back into SPI mode.
The solution was to add a short delay (1ms) to the user_spi_write function before Slave-Select pull-up.