I had tried modifying the bmi270.c file, commented out the functions whose definitions were clashing with the ones in bmi2.c. The compilation went fine, but then bmi270_init gave a result of 0xfd, which is -3. According to bmi2_defs.h, it corresponds to BMI2_E_DEV_NOT_FOUND. I checked further, it is due to chip_id mismatch. I am not initializing the intf_ptr present in the bmi2_dev structure? Are these related? I tried to understand your codes, the files you're using for bmi270.c and bmi2.c are different from the ones in the AP. I see that you've removed all functions except the bmi270_init from the bmi270.c file. and you've defined many more functions in the bmi2.c, which are not there in the API's bmi2.c file. I think I'm on a completely incorrect track right now. Using an API shouldn't have been this difficult. Is there some method I can do this the way it is supposed to be done? Edit: I tried to debug why the bmi_init function was returning -3 as rslt. turns out, in the function int8_t bmi2_sec_init(struct bmi2_dev *dev) in bmi2.c, there is: /* Read chip-id of the BMI2 sensor */
rslt = bmi2_get_regs(BMI2_CHIP_ID_ADDR, &chip_id, 1, dev);
if (rslt == BMI2_OK)
{
/* Validate chip-id */
if (chip_id == dev->chip_id)
{
// ...
}
else
{
/* Storing the chip-id value read from
* the register to identify the sensor
*/
dev->chip_id = chip_id;
rslt = BMI2_E_DEV_NOT_FOUND;
}
} The issue is, when it reads the chip ID here, it reads it as 0x00. I have a hunch that the dummy byte configuration is not correct. Initially, when I was reading the chip ID using bmi_get_regs(), it required me to handle the extra SPI dummy byte in my reg read code. which shouldn't be the case if the mode is SPI.(the API has the appropriate code to handle that additional byte, if it's configured as SPI.) I think, initially, it is going ahead with dummy byte = 0, and then somewhere down the line, it is being reconfigured as 1. so, when it reads the first byte from the received buffer, it is the dummy byte, which is 0x00. I'm unsure how to solve this issue.
... View more