linux-stable/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h
Jean-Baptiste Maneyrol ffc9648a52 iio: imu: inv_mpu6050: fix data polling interface
When reading data with the polling interface, we need to wait
at 1 sampling period to have a sample.
For gyroscope and magnetometer, we need to wait for 2 periods
before having a correct sample.

Not suitable for stable or backporting.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:38 +00:00

39 lines
931 B
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 TDK-InvenSense, Inc.
*/
#ifndef INV_MPU_MAGN_H_
#define INV_MPU_MAGN_H_
#include <linux/kernel.h>
#include "inv_mpu_iio.h"
/* Magnetometer maximum frequency */
#define INV_MPU_MAGN_FREQ_HZ_MAX 50
int inv_mpu_magn_probe(struct inv_mpu6050_state *st);
/**
* inv_mpu_magn_get_scale() - get magnetometer scale value
* @st: driver internal state
*
* Returns IIO data format.
*/
static inline int inv_mpu_magn_get_scale(const struct inv_mpu6050_state *st,
const struct iio_chan_spec *chan,
int *val, int *val2)
{
*val = 0;
*val2 = st->magn_raw_to_gauss[chan->address];
return IIO_VAL_INT_PLUS_MICRO;
}
int inv_mpu_magn_set_rate(const struct inv_mpu6050_state *st, int fifo_rate);
int inv_mpu_magn_set_orient(struct inv_mpu6050_state *st);
int inv_mpu_magn_read(struct inv_mpu6050_state *st, int axis, int *val);
#endif /* INV_MPU_MAGN_H_ */