Hi Galazar,
Loop code is not necessary, it is just a reference code in the sensor API. You can only execute the code to read the Chip ID once. Because before reading the Chip ID, the following code has already been run to enable the SPI interface. BMI160 has been in use for many years and has not experienced any issues with reading Chip ID. We suggest that you use a logic analyzer to capture the hardware communication waveform of SPI, and analyze the SPI timing to check if there is an issue with the SPI command sent by the host or if the BMI160 is not responding. /* Dummy read of 0x7F register to enable SPI Interface * if SPI is used */ if ((rslt == BMI160_OK) && (dev->intf == BMI160_SPI_INTF)) { rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev); }
Additionally, BMI160 has been discontinued and is not recommended for use in new designs. You can use BMI323, BMI270 or BHI260AP, BHI360, etc. in your new design according your application.
... View more