-
copy iam20680.c, iam20680.h, invn_selftest.c and invn_selftest.h into kernel/drivers/misc
-
modify Kconfig, example is shown below
config SENSORS_IAM20680
tristate "INV_MPU Accelerometer and Gyroscope support"
default n
depends on I2C
help
If you say yes here you get support for InvenSense's
Accelerometer and Gyroscope sensor.
- modify Makefile, example is shown below
obj-$(CONFIG_SENSORS_IAM20680) += iam20680.o invn_selftest.o
-
if dts is using, please enable
#define INVN_DTS
-
In iam20680.h, choose the correct macro definition between BUS_TYPE_I2C and BUS_TYPE_SPI according to what interface is in use
-
In iam20680.h, choose the correct macro definition for Invensense chip part number(IAM20680 or ICM20600)
-
If using INT signal, please assign proper interrupt pin in dts or board config file, for example, using gpio_to_irq() function to get correct pin number
-
example of dts is attached with the package
/* I2C device */
i2c@f9968000 {
// status = "disabled";
/* Invensense */
mpu6515_acc@68 {
compatible = "inven,iam20680";
reg = <0x68>;
interrupt-parent = <&msmgpio>;
interrupts = <73 0x2>;
inven,vdd_ana-supply = <&pm8941_l17>; //platform related
inven,vcc_i2c-supply = <&pm8941_lvs1>; //platform related
inven,gpio_int1 = <&msmgpio 73 0x00>; //platform related
axis_map_x = <1>; //define for matrix
axis_map_y = <0>; //matrix = {0, -1, 0, -1, 0, 0, 0, 0, -1}
axis_map_z = <2>;
negate_x = <1>;
negate_y = <1>;
negate_z = <1>;
};
};
- there are 3 devices created,
/sys/class/misc/invn_dev
sensor_dump //cat to get sensor register data
sensor_enable //echo 1 or 0 to enable or disable iam20680
sensor_imu_enable //echo 1 or 0 to enable or disable ima20680 imu mode
sensor_matrix //cat to get matrix for placement
sensor_mode //echo 0, 1, 2, 3 for timer mode, FIFO mode, IMU DRI mode and test mode
sensor_name //cat to get sensor name
sensor_odr //echo 100 for 100Hz ODR, max ODR is 100Hz
sensor_selftest //cat to get selfter result in test mode, 3 means success
sensor_temp //cat to get temperature, 245 means 24.5C
/sys/class/input/input0
accel_bias //echo or cat sensor bias value
accel_bw //echo 44 for 44Hz BW
accel_delay //echo 10 for 10ms delay
accel_enable //echo 1 or 0 to enable or disable event output
accel_fsr //echo 2 for 2G, 4 for 4G
accel_raw //cat to get sensor data from register
accel_value //cat to get sensor data after remving bias
/sys/class/input/input1
gyro_bias
gyro_bw
gyro_delay
gyro_enable
gyro_fsr
gyro_raw
gyro_value
- dynamic debug
except error informations are printed, warning and info are selectable to print.
enable CONFIG_DYNAMIC_DEBUG=y during building the kernel
除打印错误信息外,可选择打印警告和信息。
在构建内核期间启用 CONFIG_DYNAMIC_DEBUG=y
cat /sys/kernel/debug/dynamic_debug/control to get dynamic debug info
echo -n "file iam20680.c +p" > /sys/kernel/debug/dynamic_debug/control to enable all log
or
echo -n "file iam20680.c line 1863 +p" > /sys/kernel/debug/dynamic_debug/control to enable one log
or
echo -n "file iam20680.c line 1863 -p" > /sys/kernel/debug/dynamic_debug/control to disable one log