驅動程式key_drv_int.c
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define s3c6410_gpncon_pa (0x7f008830)
#define s3c6410_gpndat_pa (0x7f008834)
#define s3c6410_gpnpud_pa (0x7f008838)
#define s3c6410_gplcon0_pa (0x7f008810)
#define s3c6410_gplcon1_pa (0x7f008814)
#define s3c6410_gpldat_pa (0x7f008818)
#define s3c6410_gplpud_pa (0x7f00881c)
static volatile unsigned long* gpncon = null;
static volatile unsigned long* gpndat = null;
static volatile unsigned long* gplcon0 = null;
static volatile unsigned long* gplcon1 = null;
static volatile unsigned long* gpldat = null;
struct key_irq_desc;
static struct key_irq_desc key_irqs = , \
, \, \
, \, \
, \, \
};static volatile char key_values = ;
static int major = 0;
static struct class* key_drv_int_class;
static declare_wait_queue_head(key_waitq);
static volatile int ev_press = 0;
static irqreturn_t key_drv_irq(int irq, void* dev_id)
disable_irq(key_irqs[i].irq);
free_irq(key_irqs[i].irq, (void *)&key_irqs[i]);
} return -ebusy; }
ev_press = 1;
/* set key(1~8) gpio pin = input */
// *gpncon &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)|(0x3<<6)|(0x3<<8)|(0x3<<10)); /* set key1~key6 pin = input*/
// *gpncon |= ((0x0<<0)|(0x0<<2)|(0x0<<4)|(0x0<<6)|(0x0<<8)|(0x0<<10)); /* gpn0~gpn5 */
// *gplcon1 &= ~((0xf<<12)|(0xf<<16)); /* set key7~key8 pin = input*/
// *gplcon1 |= ((0x0<<12)|(0x0<<16)); /* gpl11~gpl12 */
return 0;
}static ssize_t key_drv_int_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
else
}ev_press = 0;
ret = copy_to_user(buf, &key_values, sizeof(key_values)makefile
kerneldir = /sdb/kernel/linux-2.6.38-tiny6410/linux-2.6.38/
pwd := $(shell pwd)
modules:
$(make) -c $(kerneldir) m=$(pwd) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.phony: modules clean
obj-m := key_drv_int.o
測試程式--poll
#include #include #include #include #include #define device_name "/dev/key_drv_int"
int main(int argc, char* argv)
unsigned char key_values[8];
int ret;
struct pollfd fds[1];
fds[0].fd = fd;
fds[0].events = pollin;
for( ; ; )
else if(ret > 0)
else
}close(fd);
return 0;
}
測試程式--select
#include #include #include #include //#include #include #include #define device_name "/dev/key_drv_int"
int main(int argc, char* argv)
unsigned char key_values[8];
int ret;
fd_set readset;
struct timeval timeout;
for( ; ; )
else if(ret < 0)
else if(fd_isset(fd, &readset))/*如果描述符集readset的fd位被設定*/
}close(fd);
return 0;
}
執行結果
Tiny6410 buttons c 按鍵驅動程式
最近一直在找帶中斷的led驅動程式先貼出來方便自己複習。tiny6410 buttons xyl.c 引用的標頭檔案 include 模組有關的 include 核心有關的 include 檔案系統有關的 include include include include include 中斷 incl...
Tiny6410核心移植
一 開發環境 宿主機 fedora9.0 或 ubuntu10.04 開發板 tiny6410 編譯器 4.3.2 二 核心移植 linux 2.6.38 2.解壓 進入根目錄下的 home poplar expr4 kernel目錄,解壓原始碼 tar xvfj home poplar expr4...
tiny6410 驅動程式 定時器
drv timer.c driver timer test include include include include static struct timer list my timer static void timer func unsigned long data my timer.exp...