Linux GPIO处理 [英] Linux GPIOs handling

查看:202
本文介绍了Linux GPIO处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Linux内核和GPIO有一些疑问.我知道在Linux中所有内容都是文件,因此当我执行

I have some question about Linux kernel and GPIOs. I know that in Linux everything is file so when I do something like

echo 30 > /sys/class/gpio/export

echo 1 > /sys/class/gpio/gpio30/value

真正发生了什么?我的意思是sysfs如何处理呢?它会调用在gpiolib中实现的系统调用吗?

what really happens? I mean how does sysfs handle that? Does it call system calls implemented in gpiolib?

推荐答案

gpiolib 以这种方式注册value属性:

The gpiolib registers the value attribute in this way:

 static const DEVICE_ATTR(value, 0644, gpio_value_show, gpio_value_store);

它创建一个名为value的设备属性,权限为644;在读取时调用gpio_value_show,在写入时调用gpio_value_store

It creates a device attribute named value, with permission 644; on read it calls gpio_value_show, on write it calls gpio_value_store

sysfs的作用是将readwrite重定向到sysfs属性的相应功能.

What sysfs does, is to redirect read and write to the correspondent function of a sysfs attribute.

这篇关于Linux GPIO处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆