/* Retrieve data stored in FIFO. Can be used in polling mode, but works best when interrupts are used  */
int32_t adxl372_service_fifo_ev(adxl372_dev *dev, adxl372_xyz_accel_data *fifo_data, uint16_t *fifo_entries)
/* Retrieve data stored in FIFO. Can be used in polling mode, but works best when interrupts are used  */
int32_t adxl372_service_fifo_ev(adxl372_dev *dev, adxl372_xyz_accel_data *fifo_data, uint16_t *fifo_entries)
{
	uint8_t status1, status2;
	int32_t ret;
	ret = adxl372_get_status(dev, &status1, &status2, fifo_entries);
	if (ret)
		return -1;
	if (ADXL372_STATUS_1_FIFO_OVR(status1)) {
		printf("FIFO overrun\n");
		return -1;
	}
	if (dev->fifo_config.fifo_mode != ADXL372_FIFO_BYPASSED) {
		if ((ADXL372_STATUS_1_FIFO_RDY(status1)) ||
		    (ADXL372_STATUS_1_FIFO_FULL(status1))) {
			*fifo_entries -= 3;
			ret = adxl372_get_fifo_xyz_data(dev, fifo_data,
							*fifo_entries);
		}
	}
	return ret;
}