Thanks for the reply. Here is my code snippet: the init code logic about BMA425 void bma425_init(void)
{
struct bma4_accel_config accel_conf;
/* Modify the accel handle parameters */
accel.dev_addr = BMA4_I2C_ADDR_PRIMARY;
accel.interface = BMA4_I2C_INTERFACE;
accel.bus_read = i2c_read_register;
accel.bus_write = i2c_write_register;
accel.delay = delay_x_ms;
accel.read_write_len = 8;
/* Assign the desired settings for fifo */
fifo_frame.data = fifo_buff;
fifo_frame.length = BMA_MAX_BRUST_RD;
accel.fifo = &fifo_frame;
/* Set up BMA425 device address */
i2c_set_dev_addr(BMA4_I2C_ADDR_PRIMARY);
/* Initialize the instance */
rslt |= bma423_init(&accel);
/* Enable the accelerometer */
rslt |= bma4_set_accel_enable(BMA4_MANUAL_ENABLE, &accel);
/* Assign the desired settings */
accel_conf.odr = BMA4_OUTPUT_DATA_RATE_6_25HZ;
accel_conf.range = BMA4_ACCEL_RANGE_2G;
accel_conf.bandwidth = BMA4_ACCEL_OSR4_AVG1;
accel_conf.perf_mode = BMA4_CIC_AVG_MODE;
/* Set the configuration */
rslt |= bma4_set_accel_config(&accel_conf, &accel);
delay_x_ms(1);
/* Disable the advanced power save mode to configure the FIFO buffer */
rslt |= bma4_set_advance_power_save(BMA4_ENABLE, &accel);
/* Configure the FIFO buffer */
rslt |= bma4_set_fifo_config((BMA4_FIFO_ACCEL|BMA4_FIFO_HEADER), BMA4_ENABLE, &accel);
if (rslt != BMA4_OK) {
MY_DBG("BMA425 init failed.\n\r");
} else {
MY_DBG("BMA425 init OK.\n\r");
}
} In timer handler service we issue the FIFO read out: #define FRAME_SIZE (7) /*< in header mode: 1B header + 6B accel */
#define FIFO_WATERMARK_DEPTH ((ACCEL_HZ * FRAME_SIZE+1))
void handle_bma425_accel_fifo(void)
{
uint16_t n_instances;
int16_t n_expected;
uint16_t fifo_len;
bma4_set_advance_power_save(BMA4_DISABLE, &accel);
bma4_get_fifo_length(&fifo_len, &accel);
MY_DBG("FIFO len %d.\n\r", fifo_len);
if (fifo_len < FIFO_WATERMARK_DEPTH) {
MY_DBG("Read FIFO too fast [%d].\n\r", fifo_len);
return;
}
/* Consume 10 seconds accel data in Fifo */
n_expected =62;
do {
n_instances = n_expected;
/* Read data from the sensor FIFO buffer */
bma4_read_fifo_data(&accel);
bma4_extract_accel(&sens_data[62 - n_expected], &n_instances, &accel);
n_expected -= n_instances;
} while (n_expected > 0);
if(n_expected==0) {
bma4_set_advance_power_save(BMA4_ENABLE, &accel);
// handle ACC data
}
} when set as 400K, I2C bus timing is here: in standard mode, we see 10s fifo data handle is ~ 50ms but we set as fast mode, 120ms is observed. BR, Alex
... View more