GPIO宏定义的位置

s3c2410_gpio_cfgpin(S3C2410_GPG(0), S3C2410_GPIO_OUTPUT);
s3c2410_gpio_cfgpin()的定义在arch/arm/march-2410/include/mach/gpio-fns.h
S3C2410_GPG()的定义在arch/arm/march-2410/include/mach/gpio-nrs.h
S3C2410_GPIO_OUTPUT的定义在arch/arm/march-2410/include/mach/regs-gpio.h


我要用GPF0~6 和GPG0,则根据头文件

arch/arm/march-2410/include/mach/gpio-nrs.h中

/* GPIO bank sizes */
#define S3C2410_GPIO_A_NR (32)
#define S3C2410_GPIO_B_NR (32)
#define S3C2410_GPIO_C_NR (32)
#define S3C2410_GPIO_D_NR (32)
#define S3C2410_GPIO_E_NR (32)
#define S3C2410_GPIO_F_NR (32)
#define S3C2410_GPIO_G_NR (32)
#define S3C2410_GPIO_H_NR (32)
#define S3C2410_GPIO_J_NR (32) /* technically 16. */
#define S3C2410_GPIO_K_NR (32) /* technically 16. */
#define S3C2410_GPIO_L_NR (32) /* technically 15. */
#define S3C2410_GPIO_M_NR (32) /* technically 2. */

#if CONFIG_S3C_GPIO_SPACE != 0
#error CONFIG_S3C_GPIO_SPACE cannot be zero at the moment
#endif

#define S3C2410_GPIO_NEXT(__gpio) /
((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 0)


//这里的CONFIG_S3C_GPIO_SPAC是内核配置选项,在.config中可以找到,一般配置都是:

CONFIG_S3C_GPIO_SPACE = 0

蓝色字体的意思就是宏定义传递,比如我要用GPG0,则


S3C2410_GPIO_NEXT(S3C2410_GPIO_F) +0 =>


(S3C2410_GPIO_F_START + S3C2410_GPIO_F_NR +  CONFIG_S3C_GPIO_SPACE + 0) + 0 =>

这样一步一步传递,可以得出GPG0的地址

所以才有S3C2410_GPG(0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值