用户空间使用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 下。