单板上查看gpio使用情况

转载:Linux通过内核查看芯片gpio配置使用情况_cyf15238622067的博客-CSDN博客

 

Linux通过内核查看芯片gpio配置使用情况

Dwyane05 2018-05-04 14:30:05  6133  收藏 6
文章标签: Linux gpio
版权
用户空间使用gpio输出试,出错;

使用PB08输出1-----对应40:  32*(B-A) + 08 = 40

# echo 40 > export

sh: write error: Device or resource busy

# echo 41 > export

sh: write error: Device or resource busy

# echo 42 > export
# cd gpio42/
# ls
active_low  direction   edge        power       subsystem   uevent      value
# echo out > direction
# echo 0 > value

PB08和PB09出错了,PB10正确;

应该PB08,PB09IO口被占用了,资源已经分配;

下面进行验证;可以查看板级配置文件,也可以在内核中直接查看;

板级文件:


/* ****************************GPIO KEY START******************************** */
#define GPIO_HOME_KEY        GPIO_PC(6)
#define ACTIVE_LOW_HOME        0

#define GPIO_VOLUMEUP_KEY    GPIO_PB(8)
#define ACTIVE_LOW_VOLUMEUP    0

#define GPIO_VOLUMEDOWN_KEY     GPIO_PB(9)
#define ACTIVE_LOW_VOLUMEDOWN 0

//#define GPIO_ENDCALL_KEY    GPIO_PC(8)
//#define ACTIVE_LOW_ENDCALL      0

#define GPIO_MENU_KEY    GPIO_PC(8)
#define ACTIVE_LOW_MENU    0

/* ****************************GPIO KEY END********************************** */

确实配置了按键

在内核中查看输入下面两个命令

#mount -t debugfs debugfs /tmp

#cat /tmp/gpio

GPIOs 0-31, GPIO A:

GPIOs 32-63, GPIO B:
 gpio-32  (NC_PIN              ) in  hi
 gpio-33  (NC_PIN              ) in  hi
 gpio-34  (NC_PIN              ) in  hi
 gpio-35  (NC_PIN              ) in  hi
 gpio-36  (NC_PIN              ) in  hi
 gpio-38  (0BB뢆            ) out lo
 gpio-40  (volum up key        ) in  lo
 gpio-41  (volum down key      ) in  hi
 gpio-45  (yellow              ) out lo
 gpio-46  (green               ) out lo
 gpio-47  (red                 ) out lo
 gpio-48  (lcd rd              ) out hi
 gpio-50  (lcd cs              ) out lo
 gpio-59  (NC_PIN              ) in  hi
 gpio-60  (NC_PIN              ) in  hi
 gpio-61  (NC_PIN              ) in  hi
 gpio-62  (NC_PIN              ) in  lo

GPIOs 64-95, GPIO C:
 gpio-70  (home key            ) in  lo
 gpio-72  (menu key            ) in  lo
 gpio-88  (NC_PIN              ) in  hi
 gpio-89  (pwm0                ) in  lo

GPIOs 96-101, GPIO D:
 gpio-96  (lcd rst             ) out hi
 gpio-97  (BL PWR              ) out hi
 gpio-100 (0BB뢆            ) out hi
 gpio-101 (0BB뢆            ) out hi


发现PB08 PB09已经被设置成了按键,PB10没有占用;

和板级配置文件一致;

关掉即可PB08 PB09  且将PB10配置成menu按键

/* ****************************GPIO KEY START******************************** */
#define GPIO_HOME_KEY        GPIO_PC(6)
#define ACTIVE_LOW_HOME        0

//#define GPIO_VOLUMEUP_KEY    GPIO_PB(8)
//#define ACTIVE_LOW_VOLUMEUP    0
//
//#define GPIO_VOLUMEDOWN_KEY     GPIO_PB(9)
//#define ACTIVE_LOW_VOLUMEDOWN 0

//#define GPIO_ENDCALL_KEY    GPIO_PC(8)
//#define ACTIVE_LOW_ENDCALL      0

#define GPIO_MENU_KEY    GPIO_PB(10)
#define ACTIVE_LOW_MENU    0
/* ****************************GPIO KEY END********************************** */

当#mount -t debugfs debugfs /tmp执行失败时,请再内核添加

CONFIG_DEBUG_FS=y

kernel hancking 下。


————————————————
版权声明:本文为CSDN博主「Dwyane05」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/cyf15238622067/article/details/80194031

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值