本文主要是介绍I.MX6UL 增加ADC,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
项目需要,需要增加ADC功能,通道数量是8个
因为中间GPIO06和GPIO07没有对应IO,且不知道如何跳过这两个IO,所以配置中使用了10通道。
1. 修改设备树
&adc1 {pinctrl-names = "default";pinctrl-0 = <&pinctrl_adc1>;num-channels = <10>;vref-supply = <®_vref_3v3>;status = "okay";
};
上图使用了10通道
regulators {compatible = "simple-bus";#address-cells = <1>;#size-cells = <0>;reg_can_3v3: regulator@0 {compatible = "regulator-fixed";reg = <0>;regulator-name = "can-3v3";regulator-min-microvolt = <3300000>;regulator-max-microvolt = <3300000>;};reg_vref_3v3: regulator@3 {compatible = "regulator-fixed";regulator-name = "vref-3v3";regulator-min-microvolt = <3300000>;regulator-max-microvolt = <3300000>;};reg_usb_ltemodule: regulator@1 {compatible = "regulator-fixed";regulator-name = "ltemodule-pwr";regulator-min-microvolt = <3800000>;regulator-max-microvolt = <3800000>;gpios = <&gpio5 5 GPIO_ACTIVE_HIGH>;enable-active-high;regulator-boot-on;};reg_gpio_wifi: regulator@2 {compatible = "regulator-fixed";regulator-name = "wifi-pwr";regulator-min-microvolt = <3300000>;regulator-max-microvolt = <3300000>;gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;regulator-boot-on;};};
pinctrl_adc1: adc1grp {fsl,pins = <MX6UL_PAD_GPIO1_IO00__GPIO1_IO00 0xb0 /*ADC1*/MX6UL_PAD_GPIO1_IO01__GPIO1_IO01 0xb0MX6UL_PAD_GPIO1_IO02__GPIO1_IO02 0xb0MX6UL_PAD_GPIO1_IO03__GPIO1_IO03 0xb0MX6UL_PAD_GPIO1_IO04__GPIO1_IO04 0xb0MX6UL_PAD_GPIO1_IO05__GPIO1_IO05 0xb0 MX6UL_PAD_GPIO1_IO06__GPIO1_IO06 0xb0 /*NULL*/MX6UL_PAD_GPIO1_IO07__GPIO1_IO07 0xb0 /*NULL*/MX6UL_PAD_GPIO1_IO08__GPIO1_IO08 0xb0 /*ADC7*/MX6UL_PAD_GPIO1_IO09__GPIO1_IO09 0xb0 /*ADC8*/>;};
ADC6和7实际没用上,但是也要加上去,否者读不了ADC8和9。这个问题应该是可以解决的吧,有空再说吧。
2. 升级后
[root@SCU iio:device0]# cd /sys/bus/iio/devices/iio\:device0/
[root@SCU iio:device0]# ls
dev in_voltage6_raw of_node
in_voltage0_raw in_voltage7_raw power
in_voltage1_raw in_voltage8_raw sampling_frequency_available
in_voltage2_raw in_voltage9_raw subsystem
in_voltage3_raw in_voltage_sampling_frequency uevent
in_voltage4_raw in_voltage_scale
in_voltage5_raw name
[root@SCU iio:device0]#
直接到/sys/bus/iio/devices/iio\:device0/目录下,就可以看到新增的10个ADC通道,in_voltage0_raw ~ in_voltage9_raw
直接cat就可以读到对应的ADC值了。
后话:如何跳过ADC6 ADC7通道?
这篇关于I.MX6UL 增加ADC的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!