/* This API reads the length of FIFO data available in the sensor in the units of bytes.  */
uint16_t bma4_get_fifo_length(uint16_t *fifo_length, struct bma4_dev *dev)
/* This API reads the length of FIFO data available in the sensor in the units of bytes.  */
uint16_t bma4_get_fifo_length(uint16_t *fifo_length, struct bma4_dev *dev)
{
    uint16_t rslt = 0;
    uint8_t index = 0;
    uint8_t data[BMA4_FIFO_DATA_LENGTH] = {0, 0};
    if (dev == NULL) {
        rslt |= BMA4_E_NULL_PTR;
    } else {
        rslt |= bma4_read_regs(BMA4_FIFO_LENGTH_0_ADDR, data, BMA4_FIFO_DATA_LENGTH, dev);
        if (rslt == BMA4_OK) {
            index = BMA4_FIFO_LENGTH_MSB_BYTE;
            data[index] = BMA4_GET_BITS_POS_0(data[index], BMA4_FIFO_BYTE_COUNTER_MSB);
            *fifo_length = ((data[index] << 8) | data[index - 1]);
        }
    }
    return rslt;
}