我是靠谱客的博主 勤劳人生,最近开发中收集的这篇文章主要介绍MTK 9.0平台调试 gsensor,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

MTK 9.0平台调试gsensor ----型号为:stk8baxx
1 查看原理图可以知道stk8baxx重力传感器 使用i2c1通道进行通讯,由于该重力传感器是不使用中断模式的进行触发的,所以不需要配置中断引脚。由此可以配置stk8baxx重力传感器的dts

在这里插入图片描述

dts文件配置如下:
dts文件路径为:kernel-4.4archarmbootdtsaiot8362am3_bsp.dts

&gsensor_mtk{
	status = "okay";
};
&i2c1 {
	clock-div = <2>;
	pinctrl-names = "default";
	pinctrl-0 = <&i2c1_pins_a>;
	status = "okay";
	clock-frequency = <400000>;


	stk8baxx@18{
		compatible = "mediatek,stk8baxx";
		reg = <0x18>;
		i2c_num	= <1>;
		i2c_addr = <0x18 0 0 0>;
		direction = <0>;
		power_id = <0xffff>;
		power_vol = <0>;
		firlen = <0>;
		is_batch_supported = <0>;
		status = "okay";
	};

}

kernel-4.4archarmbootdtsmt8167.dtsi

		gsensor_mtk:gsensor@0 {
			compatible = "mediatek,gsensor";

		};

2 配置aiot8362am3_bsp_defconfig和aiot8362am3_bsp_debug_defconfig文件以及配置相关的Makefile和Kconfig

2.1 配置aiot8362am3_bsp_defconfig和aiot8362am3_bsp_debug_defconfig文件
文件路径为:
kernel-4.4archarmconfigsaiot8362am3_bsp_debug_defconfig
和kernel4.4archarmconfigsaiot8362am3_bsp_defconfig

#g-sensor
CONFIG_CUSTOM_KERNEL_ACCELEROMETER=y

CONFIG_MTK_STK8BAXX=y

2.2 配置相关的Makefile和Kconfig

kernel-4.4driversmiscmediateksensors-1.0accelerometerKconfig

source "drivers/misc/mediatek/sensors-1.0/accelerometer/stk8baxx/Kconfig"

kernel-4.4driversmiscmediateksensors-1.0accelerometerMakefile

obj-$(CONFIG_MTK_STK8BAXX) += stk8baxx/

kernel-4.4driversmiscmediateksensors-1.0accelerometerstk8baxxKconfig

config MTK_STK8BAXX
	bool "MTK_STK8BAXX for MediaTek package"
	default n
	help
	  The STK8BA50 is a highly integrated,
	  low power internal measurement unit
	  that provides precise acceleration
	  measurement.
	  this config will turn on accelerometer feature.

kernel-4.4driversmiscmediateksensors-1.0accelerometerstk8baxxMakefile

ccflags-y += -I$(srctree)/drivers/misc/mediatek/sensors-1.0/accelerometer/inc
ccflags-y += -I$(srctree)/drivers/misc/mediatek/sensors-1.0/hwmon/include

obj-y	:=  stk8baxx.o

devicemediateksampleaiot8362am3_bspProjectConfig.mk


CUSTOM_KERNEL_ACCELEROMETER = yes

3 把 stk8baxx.c放进去编译查看log发现 stk8baxx.cstk8baxx重力传感器i2c是能够通讯成功的,同时相关节点也产生了,由此可以验证stk8baxx重力传感器移植成功, log如下:

[    0.402790] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_init 3463  start-----
[    0.408960] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_init 3463  start-----
[    1.326177] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3158 client->addr = 0x18 start-----
[    1.327289] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3167 client->addr = 0x18 start-----
[    1.328381] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3179 client->addr = 0x18 start-----
[    1.329477] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3184 client->addr = 0x18 start-----
[    1.330584] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3196 client->addr = 0x18 start-----
[    1.331809] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3201 client->addr = 0x18 start-----
[    1.333044] <3>.(3)[1:swapper/0]dsy:-------stk_polling_mode_setup 2501 start-----
[    1.333972] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3215 client->addr = 0x18 start no INTERRUPT_MODE -----
[    1.335267] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3220 client->addr = 0x18 start-----
[    1.336365] <3>.(3)[1:swapper/0]dsy:-------stk_reg_init 2539 start-----
[    1.341175] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3226 client->addr = 0x18 start-----
[    1.342303] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3241 client->addr = 0x18 start-----
[    1.343672] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3263 client->addr = 0x18 start-----
[    1.344779] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3273 client->addr = 0x18 start-----
[    1.345878] <3>.(3)[1:swapper/0]BOOTPROF:      1345.877694:probe: probe=i2c_device_probe drv=stk8baxx(c0e43b70)    19.696616ms
[   23.837242] <3>.(3)[454:nvram_daemon]dsy:-------stk_factory_set_cali 3052 start-----
[   23.838215] <3>.(3)[454:nvram_daemon]dsy:-------stk_factory_set_cali 3071 start-----
[   23.839177] <3>.(3)[454:nvram_daemon]dsy:-------stk_writeCalibration 2966 start-----
[   23.840146] <3>.(3)[454:nvram_daemon]dsy:-------stk_readCalibration 2942 start-----
[   23.847060] <3>.(3)[454:nvram_daemon]dsy:-------stk_readCalibration 2951 start-----
[   23.848021] <3>.(3)[454:nvram_daemon]dsy:-------stk_writeCalibration 2972 start-----
[   23.848984] <3>.(3)[454:nvram_daemon]dsy:-------stk_writeCalibration 2984 start-----
[   51.778288] <2>.(2)[160:kworker/2:1]dsy:-------stk_read_accel_rawdata 961 start-----
[   51.779761] <2>.(2)[160:kworker/2:1]dsy:-------stk_low_pass_fir 882 start-----
[   51.844305] <2>.(2)[160:kworker/2:1]dsy:-------stk_read_accel_rawdata 961 start-----
[   51.846374] <2>.(2)[160:kworker/2:1]dsy:-------stk_low_pass_fir 882 start-----
[   51.912318] <2>.(2)[160:kworker/2:1]dsy:-------stk_read_accel_rawdata 961 start-----

最后

以上就是勤劳人生为你收集整理的MTK 9.0平台调试 gsensor的全部内容,希望文章能够帮你解决MTK 9.0平台调试 gsensor所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部