根据Document下的文档,文件suniv-f1c100s-licheepi-nano.dts增加:
/dts-v1/;
#include "suniv-f1c100s.dtsi"
+#include "suniv-lradc.dtsi"
#include <dt-bindings/gpio/gpio.h>
@@ -46,6 +47,12 @@
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
+ reg_vcc3v0: vcc3v0 {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc3v0";
+ regulator-min-microvolt = <3000000>;
+ regulator-max-microvolt = <3000000>;
+ };
新增 suniv-lradc.dtsi,内容如下:
#include <dt-bindings/input/input.h>
/ {
lradc:
lradc@1c22800 {
compatible = "allwinner,sun4i-a10-lradc-keys";
reg = <0x01c22800 0x100>;
interrupts = <31>;
vref-supply = <®_vcc3v0>;
button@191 {
label = "Volume Up";
linux,code =
<KEY_VOLUMEUP>;
channel = <0>;
voltage = <191274>;
};
button@392 {
label = "Volume Down";
linux,code =
<KEY_VOLUMEDOWN>;
channel = <0>;
voltage = <392644>;
};
button@601 {
label = "Menu";
linux,code = <KEY_MENU>;
channel = <0>;
voltage = <601151>;
};
button@795 {
label = "Enter";
linux,code =
<KEY_ENTER>;
channel = <0>;
voltage = <795090>;
};
button@987 {
label = "Home";
linux,code =
<KEY_HOMEPAGE>;
channel = <0>;
voltage = <987387>;
};
};
};
(内核使用git clone https://github.com/Icenowy/linux.git)
现象为:系统起来之后会生成event0, 然而改变lradc引脚的电压,并没有按键事件
产生,查看adc的中断数,一直是0,是否还有其他地方需要设置? 谢谢
离线
根据 https://whycan.cn/t_1916.html 的信息,中断号改成30/34,表现均一致。
离线
没有找到F100C的手册,看F1C600的lradc基地址应该是0x01C23400,下午设备树改成0x01C23400试一下:
4.1.5. KEYADC Register List
Module Name Base Address
KEYADC 0x01C23400
Register Name Offset Description
离线
那么,问题来了,如果基地址要改,那中断号也应该是不对的...
离线
楼主要的是这个吗?
https://whycan.cn/t_1728.html
离线
https://whycan.cn/t_1728.html
链接分享的是音频口作adc,我这边只是想把f1c100s的keyadc用起来而已,还没到用音频adc这个层次,谢谢。
离线
我也遇到这个问题,请问楼主解决了吗
离线
没有找到F100C的手册,看F1C600的lradc基地址应该是0x01C23400,下午设备树改成0x01C23400试一下:
4.1.5. KEYADC Register List
Module Name Base Address
KEYADC 0x01C23400
Register Name Offset Description
请问最后 LRADC 用作 Key 可以了吗?
离线
根据 https://whycan.cn/t_1916.html 的信息,中断号改成30/34,表现均一致。
手册写的中断不是应该改成 22 吗? 30/34 是怎么算出来的?
spi0: spi@1c05000 {
compatible = "allwinner,suniv-spi",
"allwinner,sun8i-h3-spi";
reg = <0x01c05000 0x1000>;
interrupts = <10>;
clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_BUS_SPI0>;
clock-names = "ahb", "mod";
resets = <&ccu RST_BUS_SPI0>;
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
};spi1: spi@1c06000 {
compatible = "allwinner,suniv-spi",
"allwinner,sun8i-h3-spi";
reg = <0x01c06000 0x1000>;
interrupts = <11>;
clocks = <&ccu CLK_BUS_SPI1>, <&ccu CLK_BUS_SPI1>;
clock-names = "ahb", "mod";
resets = <&ccu RST_BUS_SPI1>;
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
};
离线
上面的中断有问题, 就是 22
arch/arm/boot/dts/suniv.dtsi 添加:
lradc: lradc@1c23400 {
compatible = "allwinner,sun4i-a10-lradc-keys";
reg = <0x01c23400 0x400>;
interrupts = <22>;
status = "disabled";
};
&lradc {
vref-supply = <®_vcc3v3>;
status = "okay";
button@200 {
label = "Volume Up";
linux,code = <KEY_VOLUMEUP>;
channel = <0>;
voltage = <200000>;
};
button@400 {
label = "Volume Down";
linux,code = <KEY_VOLUMEDOWN>;
channel = <0>;
voltage = <400000>;
};
button@600 {
label = "Select";
linux,code = <KEY_SELECT>;
channel = <0>;
voltage = <600000>;
};
button@800 {
label = "Start";
linux,code = <KEY_OK>;
channel = <0>;
voltage = <800000>;
};
};
用我的吧, 保证药到病除.
离线
终于搞定, 感谢万能的晕哥.
# /mnt/sdcard/evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: 1c23400.lradc
/dev/input/event1: 1c24800.rtp
Select the device event number [0-1]: 0
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "1c23400.lradc"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 114 (KEY_VOLUMEDOWN)
Event code 115 (KEY_VOLUMEUP)
Event code 352 (KEY_OK)
Event code 353 (KEY_SELECT)
Properties:
Testing ... (interrupt to exit)
Event: time 26.366489, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
Event: time 26.366489, -------------- SYN_REPORT ------------
Event: time 26.539027, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 26.539027, -------------- SYN_REPORT ------------
Event: time 29.266293, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
Event: time 29.266293, -------------- SYN_REPORT ------------
Event: time 29.445736, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 29.445736, -------------- SYN_REPORT ------------
Event: time 29.957952, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
Event: time 29.957952, -------------- SYN_REPORT ------------
Event: time 30.121078, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 30.121078, -------------- SYN_REPORT ------------
Event: time 30.447588, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 30.447588, -------------- SYN_REPORT ------------
Event: time 30.607447, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 30.607447, -------------- SYN_REPORT ------------
Event: time 31.299260, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 31.299260, -------------- SYN_REPORT ------------
Event: time 31.459163, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 31.459163, -------------- SYN_REPORT ------------
Event: time 31.883504, type 1 (EV_KEY), code 353 (KEY_SELECT), value 1
Event: time 31.883504, -------------- SYN_REPORT ------------
Event: time 32.076111, type 1 (EV_KEY), code 353 (KEY_SELECT), value 0
Event: time 32.076111, -------------- SYN_REPORT ------------
Event: time 32.539590, type 1 (EV_KEY), code 353 (KEY_SELECT), value 1
Event: time 32.539590, -------------- SYN_REPORT ------------
Event: time 32.699518, type 1 (EV_KEY), code 353 (KEY_SELECT), value 0
Event: time 32.699518, -------------- SYN_REPORT ------------
Event: time 33.156510, type 1 (EV_KEY), code 352 (KEY_OK), value 1
Event: time 33.156510, -------------- SYN_REPORT ------------
Event: time 33.322983, type 1 (EV_KEY), code 352 (KEY_OK), value 0
Event: time 33.322983, -------------- SYN_REPORT ------------
Event: time 34.149170, type 1 (EV_KEY), code 352 (KEY_OK), value 1
Event: time 34.149170, -------------- SYN_REPORT ------------
Event: time 34.328744, type 1 (EV_KEY), code 352 (KEY_OK), value 0
Event: time 34.328744, -------------- SYN_REPORT ------------
离线
顺便传一个控制荔枝派 nano 底板 三色LED 的脚本:
#########控制PE4 (绿) 4*32 + 4 = 132
echo 132 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio132/direction
#打开绿灯
echo 0 > /sys/class/gpio/gpio132/value
#关闭绿灯
echo 1 > /sys/class/gpio/gpio132/value
#########控制PE5 (蓝) 4*32 + 5 = 133
echo 133 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio133/direction
#打开蓝灯
echo 0 > /sys/class/gpio/gpio133/value
#关闭蓝灯
echo 1 > /sys/class/gpio/gpio133/value
#########控制PE6 (红) 4*32 + 6 = 134
echo 134 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio134/direction
#打开红灯
echo 0 > /sys/class/gpio/gpio134/value
#关闭红灯
echo 1 > /sys/class/gpio/gpio134/value
离线
又学到新姿势了 ^_^
离线
赞一个
离线
@晕哥
tiny200 R3
在哪里增加呢?
离线
请教
1.476746] sun4i-a10-lradc-keys 1c23400.lradc: keymap is missing in device tree
[ 1.484349] sun4i-a10-lradc-keys: probe of 1c23400.lradc failed with error -22
离线
提示dts不全,缺key map表,你检查一下。
在devicetree.dts 增加后,提示
linux-5.4.99 devicetree.dtb
DTC arch/arm/boot/dts/devicetree.dtb
Error: arch/arm/boot/dts/devicetree.dts:296.31-32 syntax error
FATAL ERROR: Unable to parse input tree
scripts/Makefile.lib:285: recipe for target 'arch/arm/boot/dts/devicetree.dtb' failed
make[3]: *** [arch/arm/boot/dts/devicetree.dtb] Error 1
Makefile:1262: recipe for target 'devicetree.dtb' failed
make[2]: *** [devicetree.dtb] Error 2
package/pkg-generic.mk:266: recipe for target '/home/fly/mangopi/buildroot-mangopi-r/output/build/linux-5.4.99/.stamp_built' failed
make[1]: *** [/home/fly/mangopi/buildroot-mangopi-r/output/build/linux-5.4.99/.stamp_built] Error 2
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2
离线
dts 296行语法错误
evtest 如何安装呢?
离线
buildroot 勾选 EVTEST包
测试工作了,怎么按键的时候点亮一个LED呢? 请教下
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 132 (KEY_FRONT)
Properties:
Testing ... (interrupt to exit)
Event: time 3635.574514, type 1 (EV_KEY), code 132 (KEY_FRONT), value 1
离线
在devicetree.dts 增加后,提示
linux-5.4.99 devicetree.dtb
DTC arch/arm/boot/dts/devicetree.dtb
Error: arch/arm/boot/dts/devicetree.dts:296.31-32 syntax error
FATAL ERROR: Unable to parse input tree
scripts/Makefile.lib:285: recipe for target 'arch/arm/boot/dts/devicetree.dtb' failed
make[3]: *** [arch/arm/boot/dts/devicetree.dtb] Error 1
Makefile:1262: recipe for target 'devicetree.dtb' failed
make[2]: *** [devicetree.dtb] Error 2
package/pkg-generic.mk:266: recipe for target '/home/fly/mangopi/buildroot-mangopi-r/output/build/linux-5.4.99/.stamp_built' failed
make[1]: *** [/home/fly/mangopi/buildroot-mangopi-r/output/build/linux-5.4.99/.stamp_built] Error 2
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2
缺少头文件
#include <dt-bindings/input/input.h>
最近编辑记录 卓林 (2021-09-10 20:47:35)
离线