Reading a sysfs GPIO input pin (direction as “in”) always print a fixed value (0)

雨燕双飞 提交于 2020-01-06 02:25:06

问题


After enabling the GPIO device support in kernel device driver (Kernel verion 3.10.92) I wanted to read the value of an input pin of my GPIO expander through GPIO sysfs. After exporting and setting the direction as "in", on reading, the value is always given as 0 even after the event is happening which will change the pin value as 1. While the output direction is working fine i.e. I am able to glow a LED by altering the value as 0 or 1.

Base address for my GPIO expander in GPIO sysfs is 184. So, to read the pin number 22 i.e. pin number 206 according to GPIO sysfs, the commands i gave in kernel are

echo 206 > / sys / class / gpio / export
echo "in" > / sys / class / gpio / gpio206 / direction
cat / sys / class / gpio / gpio206 / value (always gives the value as 0)

I am using PCA9505 GPIO expander (40 I/O pins) which is connected to MPC8308 microprocessor and controlled through mpc I2C bus.

来源:https://stackoverflow.com/questions/33751674/reading-a-sysfs-gpio-input-pin-direction-as-in-always-print-a-fixed-value-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!