06-06-2023 01:18 AM
Hi, All
I am working on the BMI270 driver. In the function of upload_file(), what does the following 2 lines mean?
rslt = bmi2_set_regs(BMI2_INIT_ADDR_0, addr_array, 2, dev);
rslt = bmi2_set_regs(BMI2_INIT_DATA_ADDR, (U8 *)config_data, write_len, dev);
does it mean to set register BMI2_INIT_ADDR_0 with 2 bytes of addr_array? set register of BMI2_INIT_DATA_ADDR with 46 bytes of config_data?
Questions 1:
As index will increment from 0 to 8088 (which is the config_file size) the addr_array will also increased to 8088, but max value BMI270's register address is just 0x7f, will this cause a problem?
Question 2:
after I successfully run the upload_file function, I get internal_staus by
rslt = bmi2_get_internal_status(&load_status, dev);
and found that load_status is 0xff and
sensor_data.acc.x = -1;
sensor_data.acc.y = -1;
sensor_data.acc.z = -1;
what is the problem for this result? Thanks in advance.
Victor
06-06-2023 03:49 PM
Hi victorheca01,
You can refer to the comments for the code in function upload_file().
/* Write the 2 bytes of address in consecutive locations */
rslt = bmi2_set_regs(BMI2_INIT_ADDR_0, addr_array, 2, dev);
/* Burst write configuration file data corresponding to user set length */
rslt = bmi2_set_regs(BMI2_INIT_DATA_ADDR, (uint8_t *)config_data, write_len, dev);
The config file is not written at once, it is segmented and written to the sensor. Please refer to the following code:
/* Write the configuration file */
for (index = 0; (index < config_size) && (rslt == BMI2_OK); index += dev->read_write_len)
{
rslt = upload_file((dev->config_file_ptr + index), index, dev->read_write_len, dev);
}
For loading config file failed, you can strictly compare your code and BMI270 example code https://github.com/boschsensortec/BMI270-Sensor-API/tree/master/bmi270_examples
I also uploaed a example code on STM32 for your reference.