If we look the picture below we can see that the last sample retrieved from the FIFO is not read completely. I have investigated and see that for the function bma400_get_regs the number of dummy byte is added to the actual number of byte we want to read: int8_t bma400_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint8_t len, const struct bma400_dev *dev)
{
int8_t rslt;
uint16_t index;
uint16_t temp_len = len + dev->dummy_byte;
uint8_t temp_buff[temp_len];
...
/* Read the data from the reg_addr */
rslt = dev->read(dev->dev_id, reg_addr, temp_buff, temp_len);
...
} but this is not done into the function read_fifo: static int8_t read_fifo(const struct bma400_fifo_data *fifo, const struct bma400_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
uint8_t fifo_addr = BMA400_FIFO_DATA_ADDR;
...
rslt = dev->read(dev->dev_id, fifo_addr, fifo->data, fifo->length);
...
}
int8_t bma400_get_fifo_data(struct bma400_fifo_data *fifo, const struct bma400_dev *dev)
{
int8_t rslt;
uint8_t data;
uint16_t fifo_byte_cnt = 0;
uint16_t user_fifo_len = 0;
...
/* Reading the FIFO length */
rslt = get_fifo_length(&fifo_byte_cnt, dev);
if (rslt == BMA400_OK)
{
...
user_fifo_len = fifo->length;
if (fifo->length > fifo_byte_cnt)
{
/* Handling case where user requests
* more data than available in FIFO
*/
fifo->length = fifo_byte_cnt;
}
...
rslt = read_fifo(fifo, dev);
}
...
} by adding the number of dummy bytes into fifo_byte_cnt the problem was fixed. This issue is present on the commit: https://github.com/BoschSensortec/BMA400-API/commit/f87f5ec1b91db7a9f7fb55e777d2a3d8ab99d7db
... View more