It looks like a combination condition to trigger this case:
1. in your interrupt handler funcion, you will always call bmi160_get_fifo_data whatever interrupt received.
2. in the funciton bmi160_get_fifo_data, the API will call get_fifo_byte_counter to get the available FIFO bytes to read
3. if dev->fifo->Length is bigger than avaiable bytes to read, then Length will be given a small value.
4. Then you will read FIFO by dev->fifo->Length
5. In case, the bytes available is bigger than dev->fifo->Length. it will still keep the value.
6. when you high-g interrupt happened, you also call bmi160_get_fifo_data. Then only 4 frames available that time. Then original your dev->fifo->Length is bigger than this value. it will be reset as 4 frames bytes.
7. later on, for fifo water marker interrupt, even you have big bytes available, you will still read 4 frames because dev->fifo->Length will not be given a bigger value
8. then you keep read 4 frames afterwards.
BTW, you only enable accel data into FIFO, so each frame should be 6 bytes (without header).
... View more