hi3559av100六轴陀螺仪ICM-20689驱动移植

1. copy iam20680.c, iam20680.h, invn_selftest.c and invn_selftest.h into kernel/drivers/misc

2. 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.
      
3. modify Makefile, example is shown below

obj-$(CONFIG_SENSORS_IAM20680)  += iam20680.o invn_selftest.o

4. if dts is using, please enable #define INVN_DTS

5. In iam20680.h, choose the correct macro definition between BUS_TYPE_I2C and BUS_TYPE_SPI according to what interface is in use  

6. In iam20680.h, choose the correct macro definition for Invensense chip part number(IAM20680 or ICM20600) 

7. 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

8. 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>;
        };
    };

9. 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


10. dynamic debug
except error informations are printed, warning and info are selectable to print.
enable CONFIG_DYNAMIC_DEBUG=y during building the kernel
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
————————————————
版权声明:本文为CSDN博主「Ronbin.L」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xclshwd/article/details/88233486

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值