在beagleboard或beaglebone中有不同的模式来工作引脚。对于以前的内核,它们位于/sys/ kernel /debug/omap_mux中。你知道上一个内核的那些文件在哪里吗?
发布于 2013-07-03 22:23:10
我发现在hipstercircuits上提供的许多例子有点压倒一切;特别是如果你只是想把引脚调整到模式7。如果任何阅读本文的人都有同样的问题,下面的链接可能会有所帮助:http://bbbadventures.blogspot.ca/2013/06/pinmuxing.html它提供了最基本的模板。
如果上面的链接断开了,下面是提供的代码片段(为了清晰起见做了一些调整):
/*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;
/ { compatible = "ti,beaglebone", "ti,beaglebone-black";
/* identification */
part-number = "pinctrl-test-0";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
pinctrl_test: pinctrl_test_0_pins {
pinctrl-single,pins = <
0x030 0x07 /* P8_12 OUTPUT | MODE7 */
0x034 0x07 /* P8_11 OUTPUT | MODE7 */
/* Add more pins here */
>;
};
};
};
fragment@1 {
target = <&ocp>;
__overlay__ {
test_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_test>;
status = "okay";
};
};
};
};向上述代码段添加更多管脚时,可以使用下表确定哪些十六进制值与管脚匹配:
通过将附加条目附加到pinctrl-single,pins中来设置每个管脚。格式如下所示:
偏移
示例: 0x030 0x07
在上面链接的两个表中,对于偏移值,请参考标题为"ADDR/ offset“的第三列。
我希望这能有所帮助:)
编辑:我还应该提到,Martin和Don提供的答案都很好,应该有助于涵盖其余的重要细节。
发布于 2013-06-12 20:00:31
Don Branson的回答很好地介绍了如何读取GPIO引脚,但不幸的是,它没有涵盖如何更改引脚的模式,例如从GPIO到SPI。这就变成了more complicated with kernels 3.8.13 (?)再往上。由于多种原因,内核开发人员转而使用"device tree model"。
到目前为止,关于如何使用设备树模型的细节似乎还在不断变化,所以我将只描述一般的过程。首先,在名为“设备树源”的文件中描述要与之交互的引脚。引脚及其模式使用十六进制数字指定,您必须在处理器的文档中查找这些数字。
然后使用dtc将该文件编译为“设备树二进制文件”,并将该二进制文件放入/lib/firmware中。最后,通过向/sys/devices/bone_capemgr.*/slots回显二进制文件的名称(可以省略.dtb扩展名)来启用引脚模式。
在这篇博文中提供了一个非常有用的例子:
http://hipstercircuits.com/enable-spi-with-device-tree-on-beaglebone-black-copy-paste/
当我自己了解到更多关于这个话题的知识时,我会尝试扩展我的答案。或者,也许有人可以建议编辑,甚至希望是他们自己的更广泛的答案?目前可用的信息似乎有点稀疏……
祝你好运!
发布于 2013-06-07 10:22:50
我在这里找到了我需要的东西:http://www.armhf.com/index.php/using-beaglebone-black-gpios/。
我正在运行内核3.8.13。
基于此,我编写了以下脚本:
#!/bin/bash
# http://www.armhf.com/index.php/using-beaglebone-black-gpios/
# pin 9:11, gpio0[30] - 0 + 30 = 30
echo 30 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio30/direction
cat /sys/class/gpio/gpio30/value
# 1=switch open; 0=switch closed
while [ 1 ] ; do cat /sys/class/gpio/gpio30/value ; sleep .5 ; done当引脚保持低时,脚本显示0,高时显示1。我写了一个基于http://www.digikey.com/us/en/techzone/microcontroller/resources/articles/protecting-inputs-in-digital-electronics.html的电路。
图片右侧的橙色电线起到开关的作用。
我的计划是从一台坏掉的打印机上拿出这个和一个门开关来做一个冰箱开关。然后,我将修改脚本,使其在冰箱打开超过10分钟时向我发送电子邮件。

编辑:
我做了一些研究,发现了更多关于如何设置pinmux的信息,特别是在设备树覆盖方面:
好了,看了这个,学到了很多:http://www.youtube.com/watch?v=wui_wU1AeQc
最终能够使用下面的设备树覆盖来控制BBB上的pinmux设置。fragment@1部分对我来说仍然很神奇,所以希望在某种程度上它会更有意义。然而,至少我可以检测到所有针脚上的闭合开关。
其中一个关键部分是德里克项目中的图表:https://github.com/derekmolloy/boneDeviceTree/tree/master/docs
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
part-number = "mousetraps";
version = "00A1";
/* https://github.com/derekmolloy/boneDeviceTree/blob/master/docs/BeagleboneBlackP9HeaderTable.pdf */
fragment@0{
target = <&am33xx_pinmux>;
__overlay__ {
mousetrap_pins: pinmux_mousetrap_pins {
pinctrl-single,pins = <
0x070 0x2f /* P9_11 30 INPUT MODE7 none */
0x074 0x2f /* P9_13 31 INPUT MODE7 none */
0x040 0x2f /* P9_15 48 INPUT MODE7 none */
0x15c 0x2f /* P9_17 05 INPUT MODE7 none */
>;
};
};
};
fragment@1{
target = <&ocp>;
__overlay__ {
test_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&mousetrap_pins>;
status = "okay";
};
};
};
};https://stackoverflow.com/questions/16872763
复制相似问题