用于esp32的micropython BMI160六轴陀螺仪驱动。用法如下 from machine import Pin, I2C, PWM from BMI160 import BMI160_I2C from time import sleep_ms i2c = I2C(sda=Pin(32), scl=Pin(33)) bmi160 = BMI160_I2C(i2c) k_angle = 180 angle_x = 0 angle_y = 0 angle_garget = 0 while True: data = bmi160.getMotion6() angle_x = data[3] / 32768 * k_angle print(angle_x) sleep_ms(1000 // 25)
2022-09-16 11:00:56 13KB BMI160
1
全志R58的官方开发板加载bmi160驱动的步骤3B.txt 开发板:全志R58的官方开发板R58_PER3_LPDDR3_32X1_V1_1.pdf(板载加速度传感器bma250) 目标:外挂bmi160模块可以检测到加速度和角速度(acc+gyr/加速度传感器+陀螺仪) BSP:r58_20160823.tar.gz(2016/8/22从全志的git服务器拿下来的系统) 显示:HDMI输出1080p分辨率的LCD显示器。 计划步骤: 1、打通开发板上的bma250(证明开发板硬件是好的。全志官方的BSP也是好的。) 2、将驱动程序bma250.c中的bma250全部替换为bmi160,验证是可以加入新的gsensor的(陀螺仪类似)。 3、借用bma250.c这个驱动程序,初始化的部分修改为初始化bmi160,调通BMI160的gsensor部分。 4、完善全志/博世提供的bmi160的驱动程序,调通BMI160的gsensor部分。 (陀螺仪部分鱼刺类似,陀螺仪部分借用l3gd20.c来验证bmi160的gyr部分) 下面进行第三步:借用bma250.c这个驱动程序,初始化的部分修改为初始化bmi160,调通BMI160的gsensor部分。 为了方便观察,直接注释掉除了bma250之外的全部的gsensor: Z:\home\wwt\only_bma250_r58\android\device\softwinner\common\hardware-common\libhardware\libsensors\aw_sensors\sensorDetect.cpp struct sensor_extend_t gsensorList[] = { { { "bma250", LSG_BMA250, }, { "Bosch 3-axis Accelerometer", "Bosch Sensortec", 1, 0, SENSOR_TYPE_ACCELEROMETER, 4.0f*9.81f, (4.0f*9.81f)/1024.0f, 0.2f, 0,0,0, { }, }, }, }; Z:\home\wwt\only_bma250_r58\android\device\softwinner\octopus-perf\configs\gsensor.cfg ;Direction parameter adjustment, including the x, y, z axis, and xy interchange four variables, ;the name of the module used for identification, and drive registered name consistent ;-------------------------- ;name:bma250 ;-------------------------- gsensor_name = bma250 gsensor_direct_x = false gsensor_direct_y = true gsensor_direct_z = true gsensor_xy_revert = true Z:\home\wwt\only_bma250_r58\android\device\softwinner\octopus-perf\BoardConfig.mk #gsensor & Gyr sensor SW_BOARD_USES_SENSORS_TYPE = aw_sensors 注意:lunch的f1选项在HAL层中使用的ST的9轴(ACC+GYR+MAG)传感器。 #gsensor & Gyr sensor SW_BOARD_USES_SENSORS_TYPE = lsm9ds0 Z:\home\wwt\only_bma250_r58\android\device\softwinner\octopus-perf\init.sun8i.rc on boot # use automatic detecttion insmod ctp & gsensor driver #insmod /system/vendor/modules/sw-device.ko insmod /system/vendor/modules/bma250.ko Z:\home\wwt\only_bma250_r58\android\device\softwinner\octopus-perf\octopus_perf.mk (已经默认配置了。lunch选择f1必须要修改,否则adb shell不能用!) # usb PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.usb.config=mtp,adb \ ro.udisk.lable=octopus \ ro.adb.secure=0 Z:\home\wwt\only_bma250_r58\lichee\linux-3.4\drivers\hwmon\bma250.c Z:\home\wwt\only_bma250_r58\lichee\linux-3.4\drivers\hwmon\bmi160.h Z:\home\wwt\only_bma250_r58\lichee\linux-3.4\drivers\hwmon\bmi160_driver.h (请做相应的修改) Z:\home\wwt\only_bma250_r58\lichee\linux-3.4\drivers\input\sw-device.c /*gsensor info*/ static struct sw_device_info gsensors[] = { { "bma250", 0, {0x18, 0x19, 0x08, 0x38}, 0x00, {0x02,0x03,0xf9,0xf8}, 0}, }; Z:\home\wwt\only_bma250_r58\lichee\tools\pack\chips\sun8iw6p1\configs\perf3_v1_0\sys_config.fex ;-------------------------------------------------------------------------------- ; G sensor configuration ; gs_twi_id --- TWI ID for controlling Gsensor (0: TWI0, 1: TWI1, 2: TWI2) ;-------------------------------------------------------------------------------- [gsensor_para] gsensor_used = 1 gsensor_twi_id = 1 gsensor_twi_addr = 0x68 ;gsensor_int1 = port:PG11<6><1> ;gsensor_int2 = ;-------------------------------------------------------------------------------- ; G sensor automatic detection configuration ;gsensor_detect_used --- Whether startup automatic inspection function. 1:used,0:unused ;Module name postposition 1 said detection, 0 means no detection. ;-------------------------------------------------------------------------------- [gsensor_list_para] gsensor_det_used = 1 bma250 = 1 使用全志的原生系统,lichee和android的编译选项都是perf3: android使用ENG模式编译,方便调试之用。 wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 4. sun8iw6p1 Choice: 4 All available platforms: 0. android Choice: 0 All available kernel: 0. linux-3.4 Choice: 0 All available boards: 5. perf3_v1_0 wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/lichee$ ./build.sh wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/lichee$ cd ../android/ wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/android$ source build/envsetup.sh including device/softwinner/kylin-p1/vendorsetup.sh including device/softwinner/octopus-n1/vendorsetup.sh including device/softwinner/octopus-f1/vendorsetup.sh including device/softwinner/common/vendorsetup.sh including device/softwinner/astar-y3/vendorsetup.sh including device/softwinner/octopus-perf/vendorsetup.sh including device/lge/mako/vendorsetup.sh including device/lge/hammerhead/vendorsetup.sh including device/samsung/manta/vendorsetup.sh including device/generic/x86/vendorsetup.sh including device/generic/mips/vendorsetup.sh including device/generic/armv7-a-neon/vendorsetup.sh including device/asus/tilapia/vendorsetup.sh including device/asus/deb/vendorsetup.sh including device/asus/grouper/vendorsetup.sh including device/asus/flo/vendorsetup.sh including sdk/bash_completion/adb.bash wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/android$ lunch You're building on Linux Lunch menu... pick a combo: 13. octopus_perf-eng Which would you like? [aosp_arm-eng] 13 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.4.4 TARGET_PRODUCT=octopus_perf TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon TARGET_CPU_VARIANT=cortex-a7 HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=KTU84Q OUT_DIR=out ============================================ wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/android$ extract-bsp /home/wwt/r58_bma250/android/device/softwinner/octopus-perf/bImage copied! /home/wwt/r58_bma250/android/device/softwinner/octopus-perf/modules copied! wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/android$ make -j8 wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/android$ pack BuildImg 0 Dragon execute image.cfg SUCCESS ! ----------image is at---------- /home/wwt/r58_bma250/lichee/tools/pack/sun8iw6p1_android_perf3_v1_0_uart0.img pack finish wenyuanbo@cm-System-Product-Name:/home/wwt/r58_bma250/android$ 使用PhoenixSuit将sun8iw6p1_android_perf3_v1_0_uart0.img这个固件刷机之后,可以看见显示器满屏幕了。 设置菜单里面的WIFI/BT等等选项的打开部分按钮缺失(感觉是拉伸的)。 使用360手机助手(安装之后是竖屏)截图,发现HDMI显示的分辨率只有819x1280。 由于使用perf3的ENG模式编译的系统,adb shell默认可以连接,360手机助手直接连接android。 Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>adb shell root@octopus-perf:/ # 在串口打印中可以看到命令:input keyevent 82可以直接解锁系统。 shell@octopus-perf:/ # input keyevent 82 设置→显示→休眠→无操作30分钟后(f1编译选项有永久) 设置→安全→屏幕锁定→无 设置→辅助功能→自动旋转屏幕(去掉选中即可就改为横屏了) su之后使用getevent -p有发现bma250这个加速度传感器生成的input4设备: shell@octopus-perf:/ $ su shell@octopus-perf:/ # getevnet -p sh: getevnet: not found 127|shell@octopus-perf:/ # getevent -p add device 1: /dev/input/event5 name: "l3gd20_gyr" events: ABS (0003): 0000 : value 0, min -32768, max 32768, fuzz 0, flat 0, resolution 0 0001 : value 0, min -32768, max 32768, fuzz 0, flat 0, resolution 0 0002 : value 0, min -32768, max 32768, fuzz 0, flat 0, resolution 0 input props: could not get driver version for /dev/input/js1, Invalid argument add device 2: /dev/input/event4 name: "bma250" events: ABS (0003): 0000 : value 0, min -19613100, max 19613100, fuzz 0, flat 0, resolution 0 0001 : value 0, min -19613100, max 19613100, fuzz 0, flat 0, resolution 0 0002 : value 0, min -19613100, max 19613100, fuzz 0, flat 0, resolution 0 0028 : value 0, min 0, max 0, fuzz 0, flat 0, resolution 0 input props: could not get driver version for /dev/input/js0, Invalid argument could not get driver version for /dev/input/mouse0, Not a typewriter add device 3: /dev/input/event3 name: "PixArt USB Optical Mouse" events: KEY (0001): 0110 0111 0112 0113 0114 0115 0116 0117 REL (0002): 0000 0001 0008 MSC (0004): 0004 input props: add device 4: /dev/input/event0 name: "axp81x-supplyer" events: KEY (0001): 0074 input props: add device 5: /dev/input/event2 name: "sunxi-ths" events: ABS (0003): 0028 : value 0, min -50, max 180, fuzz 0, flat 0, resolution 0 input props: add device 6: /dev/input/event1 name: "sunxi-keyboard" events: KEY (0001): 001c 0066 0072 0073 008b input props: could not get driver version for /dev/input/mice, Not a typewriter shell@octopus-perf:/ # (查看bma250的驱动模块是否加载)lsmod(有加载) shell@octopus-perf:/ # lsmod cdc_ether 3163 0 - Live 0x00000000 rtl8150 9023 0 - Live 0x00000000 mcs7830 5644 0 - Live 0x00000000 qf9700 5904 0 - Live 0x00000000 asix 13590 0 - Live 0x00000000 usbnet 14128 4 cdc_ether,mcs7830,qf9700,asix, Live 0x00000000 bcm_btlpm 7658 0 - Live 0x00000000 l3gd20_gyr 13018 0 - Live 0x00000000 ft5x_ts 61962 0 - Live 0x00000000 bma250 8122 0 - Live 0x00000000 sunxi_schw 13015 0 - Live 0x00000000 (O) vfe_v4l2 785679 0 - Live 0x00000000 gc2035 12400 0 - Live 0x00000000 ov5640 27225 0 - Live 0x00000000 vfe_subdev 4695 3 vfe_v4l2,gc2035,ov5640, Live 0x00000000 vfe_os 4113 2 vfe_v4l2,vfe_subdev, Live 0x00000000 cci 22800 3 vfe_v4l2,gc2035,ov5640, Live 0x00000000 videobuf_dma_contig 4165 1 vfe_v4l2, Live 0x00000000 videobuf_core 16528 2 vfe_v4l2,videobuf_dma_contig, Live 0x00000000 pvrsrvkm 279643 33 - Live 0x00000000 (O) hdmi 38647 0 - Live 0x00000000 disp 1023342 6 hdmi, Live 0x00000000 sunxi_tr 9348 1 disp, Live 0x00000000 nand 299879 0 - Live 0x00000000 (O) shell@octopus-perf:/ # 查找bma250.ko是否编译进系统(有编译,sw_device.ko不能识别bma250.ko): shell@octopus-perf:/ # cd /system/vendor/modules/ shell@octopus-perf:/system/vendor/modules # shell@octopus-perf:/system/vendor/modules # ll l3gd* -rw-r--r-- root root 160453 2016-09-07 16:50 l3gd20_gyr.ko shell@octopus-perf:/system/vendor/modules # ll bm* -rw-r--r-- root root 139998 2016-09-07 16:50 bma250.ko -rw-r--r-- root root 252117 2016-09-07 16:50 bmg160_gyr.ko shell@octopus-perf:/system/vendor/modules # 但是getevent没有检测到bma250的上报事件: shell@octopus-perf:/system/vendor/modules # getevent add device 1: /dev/input/event5 name: "l3gd20_gyr" could not get driver version for /dev/input/js1, Invalid argument add device 2: /dev/input/event4 name: "bma250" could not get driver version for /dev/input/js0, Invalid argument could not get driver version for /dev/input/mouse0, Not a typewriter add device 3: /dev/input/event3 name: "PixArt USB Optical Mouse" add device 4: /dev/input/event0 name: "axp81x-supplyer" add device 5: /dev/input/event2 name: "sunxi-ths" add device 6: /dev/input/event1 name: "sunxi-keyboard" could not get driver version for /dev/input/mice, Not a typewriter 挪动鼠标的上报事件: /dev/input/event3: 0002 0001 00000001 /dev/input/event3: 0000 0000 00000000 查看bma250的I2C驱动是否成功挂载(成功挂载。) 1-0018,1表示I2C1,从0开始,第二条总线。18为十六进制的0x18,bma250的I2C从机地址向右移动一位之后的值。 cshell@octopus-perf:/system/vendor/modules # cd /sys/class/i2c-adapter/i2c-1 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # ll drwxr-xr-x root root 1970-01-02 08:22 1-0040 drwxr-xr-x root root 1970-01-02 08:22 1-0041 drwxr-xr-x root root 1970-01-02 08:22 1-0042 drwxr-xr-x root root 1970-01-02 08:22 1-0043 drwxr-xr-x root root 1970-01-02 08:22 1-0044 drwxr-xr-x root root 1970-01-02 08:22 1-0046 drwxr-xr-x root root 1970-01-02 08:22 1-0068 --w------- root root 4096 1970-01-02 08:22 delete_device lrwxrwxrwx root root 1970-01-02 08:22 device -> ../../twi.1 -r--r--r-- root root 4096 1970-01-02 08:22 name --w------- root root 4096 1970-01-02 08:22 new_device drwxr-xr-x root root 1970-01-02 08:22 power lrwxrwxrwx root root 1970-01-02 08:22 subsystem -> ../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 08:22 uevent shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # cd 1-0068 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0068 # ll lrwxrwxrwx root root 1970-01-02 08:22 driver -> ../../../../../bus/i2c/drivers/bma250 -r--r--r-- root root 4096 1970-01-02 08:22 modalias -r--r--r-- root root 4096 1970-01-02 08:22 name drwxr-xr-x root root 1970-01-02 08:22 power lrwxrwxrwx root root 1970-01-02 08:22 subsystem -> ../../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 08:22 uevent shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0068 # cat name bma250 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0068 # shell@octopus-perf:/system/vendor/modules # cd /sys/class/i2c-adapter/i2c-1 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # ll drwxr-xr-x root root 1970-01-02 10:30 1-0040 drwxr-xr-x root root 1970-01-02 10:30 1-0041 drwxr-xr-x root root 1970-01-02 10:30 1-0042 drwxr-xr-x root root 1970-01-02 10:30 1-0043 drwxr-xr-x root root 1970-01-02 10:30 1-0044 drwxr-xr-x root root 1970-01-02 10:30 1-0046 drwxr-xr-x root root 1970-01-02 10:30 1-0068 drwxr-xr-x root root 1970-01-02 10:23 1-0070 --w------- root root 4096 1970-01-02 10:30 delete_device lrwxrwxrwx root root 1970-01-02 10:30 device -> ../../twi.1 -r--r--r-- root root 4096 1970-01-02 10:30 name --w------- root root 4096 1970-01-02 10:30 new_device drwxr-xr-x root root 1970-01-02 10:30 power lrwxrwxrwx root root 1970-01-02 10:30 subsystem -> ../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 10:30 uevent shell@octopus-perf:/sys/class/i2c-adapter/i2c-1 # cd 1-0070 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # ll lrwxrwxrwx root root 1970-01-02 10:30 driver -> ../../../../../bus/i2c/drivers/l3gd20_gyr -rw-rw-rw- root root 4096 1970-01-02 10:30 enable_device -rw-rw-rw- root root 4096 1970-01-02 10:30 enable_polling -rw-rw-rw- root root 4096 1970-01-02 10:30 fifo_mode -rw-rw-rw- root root 4096 1970-01-02 10:30 fifo_samples drwxr-xr-x root root 1970-01-02 10:23 input -r--r--r-- root root 4096 1970-01-02 10:30 modalias -r--r--r-- root root 4096 1970-01-02 10:30 name -rw-rw-rw- root root 4096 1970-01-02 10:30 pollrate_ms drwxr-xr-x root root 1970-01-02 10:30 power -rw-rw-rw- root root 4096 1970-01-02 10:30 range --w------- root root 4096 1970-01-02 10:30 reg_addr -rw------- root root 4096 1970-01-02 10:30 reg_value lrwxrwxrwx root root 1970-01-02 10:30 subsystem -> ../../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 10:30 uevent shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # cat name l3gd20_gyr shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # cat en enable_device enable_polling shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # cat enable_device 0 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # cd input/ shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070/input # ll drwxr-xr-x root root 1970-01-02 10:23 input5 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070/input # cd .. shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # cat range 2000 shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0070 # 查看bma250的input4事件: shell@octopus-perf:/sys/class/i2c-adapter/i2c-1/1-0018 # cd /sys/class/input/input4 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # ll -rw-rw-r-- root root 4096 1970-01-02 16:34 bandwidth drwxr-xr-x root root 1970-01-02 16:34 capabilities -rw-rw-r-- root root 4096 1970-01-02 16:34 delay -rw-rw-r-- root root 4096 1970-01-02 16:34 enable drwxr-xr-x root root 1970-01-02 16:27 event4 drwxr-xr-x root root 1970-01-02 16:34 id drwxr-xr-x root root 1970-01-02 16:27 js0 -r--r--r-- root root 4096 1970-01-02 16:34 modalias -rw-rw-r-- root root 4096 1970-01-02 16:34 mode -r--r--r-- root root 4096 1970-01-02 16:34 name -r--r--r-- root root 4096 1970-01-02 16:34 phys drwxr-xr-x root root 1970-01-02 16:34 power -r--r--r-- root root 4096 1970-01-02 16:34 properties -rw-rw-r-- root root 4096 1970-01-02 16:34 range lrwxrwxrwx root root 1970-01-02 16:34 subsystem -> ../../../../class/input -rw-r--r-- root root 4096 1970-01-02 16:34 uevent -r--r--r-- root root 4096 1970-01-02 16:34 uniq -r--r--r-- root root 4096 1970-01-02 16:34 value shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat enable 0 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat value 0 0 0 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cd ../input5 shell@octopus-perf:/sys/class/input/input5 # ll drwxr-xr-x root root 1970-01-02 10:32 capabilities lrwxrwxrwx root root 1970-01-02 10:32 device -> ../../../1-0070 drwxr-xr-x root root 1970-01-02 10:32 event5 drwxr-xr-x root root 1970-01-02 10:32 id drwxr-xr-x root root 1970-01-02 10:32 js1 -r--r--r-- root root 4096 1970-01-02 10:32 max -r--r--r-- root root 4096 1970-01-02 10:32 min -r--r--r-- root root 4096 1970-01-02 10:32 modalias -r--r--r-- root root 4096 1970-01-02 10:23 name -r--r--r-- root root 4096 1970-01-02 10:32 phys -rw-r--r-- root root 4096 1970-01-02 10:32 poll drwxr-xr-x root root 1970-01-02 10:32 power -r--r--r-- root root 4096 1970-01-02 10:32 properties lrwxrwxrwx root root 1970-01-02 10:32 subsystem -> ../../../../../../../class/input -rw-r--r-- root root 4096 1970-01-02 10:32 uevent -r--r--r-- root root 4096 1970-01-02 10:32 uniq shell@octopus-perf:/sys/class/input/input5 # cat name l3gd20_gyr 使能enable为0,值value当然也是0。 两种方式打开使能enable。 第一种方法:命令行输入:ehco 1 > enable shell@octopus-perf:/sys/class/input/input4 # cat enable 0 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # echo 1 > enable shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat enable 1 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat value 28 0 251 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat value 23 -2 250 shell@octopus-perf:/sys/class/input/input4 # cat value 15 6 253 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # 关闭使能enable: shell@octopus-perf:/sys/class/input/input4 # cat enable 1 shell@octopus-perf:/sys/class/input/input4 # echo 0 > enable shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat enable 0 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # cat value 26 -11 244 shell@octopus-perf:/sys/class/input/input4 # cat value 26 -11 244 shell@octopus-perf:/sys/class/input/input4 # cat value 26 -11 244 这个value的值(26 -11 244)是gsensor的最后一次上报的值,没有从驱动中被清除。 android的HAL/Android对于完全相同的gsensor的值,会被过滤掉。 由于gsensor的精度等等原因,两次的gsensor采样的值肯定不同。 虚拟gsensor的时候要注意!!!! 第二种方法: 设置→辅助功能→自动旋转屏幕(选中) shell@octopus-perf:/sys/class/input/input5 # getevent add device 1: /dev/input/event5 name: "l3gd20_gyr" could not get driver version for /dev/input/js1, Invalid argument add device 2: /dev/input/event4 name: "bma250" could not get driver version for /dev/input/js0, Invalid argument could not get driver version for /dev/input/mouse0, Not a typewriter add device 3: /dev/input/event3 name: "PixArt USB Optical Mouse" add device 4: /dev/input/event0 name: "axp81x-supplyer" add device 5: /dev/input/event2 name: "sunxi-ths" add device 6: /dev/input/event1 name: "sunxi-keyboard" could not get driver version for /dev/input/mice, Not a typewriter /dev/input/event5: 0003 0000 ffffffe0 /dev/input/event5: 0003 0001 00000008 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 0000002c /dev/input/event5: 0003 0001 00000001 /dev/input/event5: 0003 0002 fffffff5 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 ffffffe6 /dev/input/event5: 0003 0001 00000003 /dev/input/event5: 0003 0002 fffffff0 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0000 ffffffd2 /dev/input/event4: 0003 0002 00000126 /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 ffffffe8 /dev/input/event5: 0003 0001 00000000 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 00000011 /dev/input/event5: 0003 0001 0000000a /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 ffffffe2 /dev/input/event5: 0003 0001 00000002 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffe /dev/input/event5: 0003 0001 00000000 /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0001 00000005 /dev/input/event4: 0003 0002 0000010d /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 00000002 /dev/input/event5: 0003 0001 00000008 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 ffffffea /dev/input/event5: 0003 0001 00000001 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 00000003 /dev/input/event5: 0003 0001 00000007 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0000 ffffffd1 /dev/input/event4: 0003 0002 0000010b /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff7 /dev/input/event5: 0003 0001 00000004 /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff5 /dev/input/event5: 0003 0001 00000003 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffd /dev/input/event5: 0003 0001 00000006 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 ffffffef /dev/input/event5: 0003 0001 00000003 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0001 00000004 /dev/input/event4: 0003 0002 00000110 /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff7 /dev/input/event5: 0003 0001 00000005 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffe /dev/input/event5: 0003 0001 00000004 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffc /dev/input/event5: 0003 0001 00000006 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0000 ffffffd2 /dev/input/event4: 0003 0002 00000111 /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 ffffffef /dev/input/event5: 0003 0001 00000005 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff9 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffa /dev/input/event5: 0003 0001 00000003 /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffb /dev/input/event5: 0003 0001 00000005 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0000 ffffffd1 /dev/input/event4: 0003 0002 0000010c /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff6 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff4 /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffb /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0000 ffffffd2 /dev/input/event4: 0003 0002 0000010f /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff7 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffd /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff7 /dev/input/event5: 0003 0001 00000003 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff8 /dev/input/event5: 0003 0001 00000005 /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0001 00000003 /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff6 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff9 /dev/input/event5: 0003 0001 00000004 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0000 ffffffd1 /dev/input/event4: 0003 0001 00000004 /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff4 /dev/input/event5: 0003 0001 00000005 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffc /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff9 /dev/input/event5: 0003 0001 00000004 /dev/input/event5: 0003 0002 fffffff3 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffff5 /dev/input/event5: 0003 0001 00000005 /dev/input/event5: 0003 0002 fffffff2 /dev/input/event5: 0000 0000 00000000 /dev/input/event4: 0003 0002 00000110 /dev/input/event4: 0000 0000 00000000 /dev/input/event5: 0003 0000 fffffffb /dev/input/event5: 0003 0001 00000004 /dev/input/event5: 0003 0002 fffffff4 /dev/input/event5: 0000 0000 00000000 gsensor的上报格式: shell@octopus-perf:/sys/class/input/input4 # cat enable 0 shell@octopus-perf:/sys/class/input/input4 # echo 1 > enable shell@octopus-perf:/sys/class/input/input4 # cat value 24 2 256 shell@octopus-perf:/sys/class/input/input4 # cat value 22 8 231 shell@octopus-perf:/sys/class/input/input4 # cat value 27 -3 253 shell@octopus-perf:/sys/class/input/input4 # shell@octopus-perf:/sys/class/input/input4 # getevent add device 1: /dev/input/event4 name: "bma250" could not get driver version for /dev/input/js0, Invalid argument could not get driver version for /dev/input/mouse0, Not a typewriter add device 2: /dev/input/event3 name: "PixArt USB Optical Mouse" add device 3: /dev/input/event0 name: "axp81x-supplyer" add device 4: /dev/input/event2 name: "sunxi-ths" add device 5: /dev/input/event1 name: "sunxi-keyboard" could not get driver version for /dev/input/mice, Not a typewriter /dev/input/event4: 0003 0000 00000015 /dev/input/event4: 0003 0002 00000109 /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 00000021 /dev/input/event4: 0003 0001 fffffffa /dev/input/event4: 0003 0002 000000f9 /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 00000018 /dev/input/event4: 0003 0001 ffffffff /dev/input/event4: 0003 0002 000000fd /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 00000017 /dev/input/event4: 0003 0001 00000008 /dev/input/event4: 0003 0002 000000f8 /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 00000018 /dev/input/event4: 0003 0001 fffffffe /dev/input/event4: 0003 0002 000000f6 /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 0000001c /dev/input/event4: 0003 0001 fffffffa /dev/input/event4: 0003 0002 00000100 /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 0000001f /dev/input/event4: 0003 0001 00000000 /dev/input/event4: 0003 0002 000000fa /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 00000015 /dev/input/event4: 0003 0001 ffffffff 解释: /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0003 0000 00000021 /dev/input/event4: 0003 0001 fffffffa /dev/input/event4: 0003 0002 000000f9 /dev/input/event4: 0000 0000 00000000 上报数据前后的分隔符: /dev/input/event4: 0000 0000 00000000 gsensor的X/Y/Z数据: /dev/input/event4: 0003 0000 00000021 /dev/input/event4: 0003 0001 fffffffa /dev/input/event4: 0003 0002 000000f9 其中:0003应该是格式。 0000/0001/0002表示X/Y/Z。 00000021/fffffffa/000000f9为十六进制的X/Y/Z的值。 十进制为:33/(-5)/249 和value:(27 -3 253)很接近。 通过360手机助手安装:使用gSensor加速度传感器.apk shell@octopus-perf:/sys/class/input/input4 # cat value 23 2 256 shell@octopus-perf:/sys/class/input/input4 # cat value 26 -2 248 shell@octopus-perf:/sys/class/input/input4 # cat value 14 4 255 shell@octopus-perf:/sys/class/input/input4 # 虽然强制加载bma250.ko成功,并且使能了bma250,且获得了加速度分量。 android层也可以检测到加速度的值。 初步的总体感觉:bmi160的用加速度传感器这个APK测试的时候,抖动不如bma250明显(静态漂移)! 灵敏度都差不多。 驱动程序的I2C读取函数调用了博世提供的不完整的驱动中处理函数。 看似有点多次一举,并且还有很多x数字的bma250.c的文件,只是让大家知道做出来的艰辛。 !!!!Gyroscope Rotate1.1 com.gyro_2检测陀螺仪好用.apk 陀螺仪也可以看到在旋转了。
2022-07-23 20:33:28 12MB android
1
BMI160使用说明 原版The BMI160 is a small, low-power, low-noise 16 bit Inertial Measurement Unit designed for use in mobile applications such as augmented reality or indoor navigation which require highly accurate, real-time sensor data. In full operation mode, with both the accelerometer and gyroscope enabled, the current consumption is typically 925 μA, enabling always-on applications in battery driven devices. It is available in a compact 14-pin 2.5 × 3.0 × 0.8 mm3 LGA package.
2022-07-17 11:28:48 219KB BMI160 加速度 陀螺仪
1
从官网下载的BMI160的Datasheet和Driver Code,它是一款IMU包含了accelerometer和gyroscope,移植参考的博客地址:https://blog.csdn.net/ZHONGCAI0901/article/details/110491101
2022-05-09 20:37:47 6.31MB accelerometer gyroscope imu bmi160
1
3.0 人力资源模块事实表说明  人力资源主题事实表 20 组 织 单 元 表 职 位 基 本 信 息 表 职 称 表 离 职 信 息 表 学 历 学 位 表 工 资 类 别 表 员 工 基 本 信 息 表 工 资 数 据 表 工 资 职 员 表 员 工 任 职 信 息 表 职 等 表
2022-02-16 22:10:10 516KB 说明书
1
博世BMI160六轴传感器陀螺仪的数据手册 中文版英文版
2021-12-21 15:40:45 27.34MB 数据手册 中文版 英文版 BMI160
1
官方下载的BMI160的datasheet是加密版的,没法复制,对于英语不是很好的同学看起来太费劲,而且查单子只能手敲,所以上传了此破解版,可以复制里面的内容
2021-10-24 10:53:39 2.61MB BMI160 DataSheet 非加密
1
BM160中文数据手册,官方下载,质量保证,方便开发
BM160中文数据手册,官方下载,质量保证,方便开发
BMI160测试程序
2021-08-18 18:12:32 25KB BMI160
1