linux驱动学习笔记7

1.s3c2410_gpio_getpin函数(arch/arm/mach-s3c2410/include/mach/gpio-fns.h)

unsigned int s3c2410_gpio_getpin(unsigned int pin){    void __iomem *base = S3C24XX_GPIO_BASE(pin);    unsigned long offs = S3C2410_GPIO_OFFSET(pin);    return __raw_readl(base + 0x04) & (1<< offs);}

s3c2410_gpio_getpin()的返回值是GPxDAT寄存器的值与所要读取的GPIO对应的bit mask相与以后的值,0表示该GPIO对应的bit为0, 非0表示该bit为1,所以s3c2410_gpio_getpin(S3C2410_GPG(9))如果GPG9为低电平则返回的是0,如果是高电平则返回的是GPxDAT中的GPG9对应位的值为0x0100而不是0x0001,查处问题后修改也很简单了。

2.wait_event_interruptible函数

wait_event_interruptible(wq, condition);

wait_event_interruptible(button_waitq, ev_press);

static DECLARE_WAIT_QUEUE_HEAD(button_waitq); /* 中断事件标志, 中断服务程序将它置1,third_drv_read将它清0 */ static volatile int ev_press = 0;

在中断服务程序中

ev_press = 1;                  /* 表示中断发生了 */wake_up_interruptible(&button_waitq);   /* 唤醒休眠的进程 */

3.添加相应的库 linux/wait.h wake_up_interruptible wait_event_interruptible

linux/Sched.h TASK_INTERRUPTIBLE

mach/Gpio-nrs.h S3C2410_GPF0 -> S3C2410_GPF(0) \2.6.32内核中对应的宏已修改。

但一定要背上几本书,在花海里,草丛旁悠然品味,

linux驱动学习笔记7

相关文章:

你感兴趣的文章:

标签云: