OK6410按鍵驅動 Qt程式 改 親測可以執行

2021-07-11 05:18:53 字數 2609 閱讀 7087

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

//#include

#include

#define device_name "keyint"

#define keynum 6

dev_t devid;

//static define_semaphore(key_lock);  //declare a mutex lock for keyint

//定義乙個訊號量

struct semaphore key_lock;

static struct fasync_struct *key_async;

static struct timer_list key_timer;

struct key_irq_desc ;

static struct key_irq_desc key_irqs = , ,

, ,

, ,

};/*define a waiting queue here*/

static declare_wait_queue_head(key_waitq);

/*define a event flag ev_press*/

static volatile int ev_press = 0;

static volatile int press_cnt[keynum] = ;

/*中斷處理函式*/

static irqreturn_t keys_interrupt(int irq, void *dev_id)

//定時器處理函式

static void key_timer_func(unsigned long data)

static int key_fasync(int fd, struct file *filp, int on)

static unsigned key_poll(struct file *file, poll_table *wait)

static int key_open(struct inode *inode, struct file *file)

else

//為每個按鍵註冊中斷處理程式

for(num=0;num//釋放中斷號

for(num=0;num<6;num++)

up(&key_lock);

printk("key_close free irqs\n");

return 0; }

static int key_read(struct file *filp, char __user *buff, size_t count, loff_t *offp)

else

//阻塞結束,有鍵按下了

ev_press = 0;

//拷貝資料到使用者空間

copy_to_user(buff,(const void *)press_cnt,min(sizeof(press_cnt),count));

memset((void *)press_cnt,0,sizeof(press_cnt));

//    printk("read and clean press_cnt\n");

return 1; }

static struct file_operations key_ops = ;

static struct cdev *cdev_keyint;

static struct class *keyint_class;

//模組初始化函式

static int __init s3c6410_keyint_init(void)

cdev_keyint = cdev_alloc();

cdev_init(cdev_keyint, &key_ops);

cdev_keyint->owner = this_module;

cdev_keyint->ops   = &key_ops;

val = cdev_add(cdev_keyint,devid,1);

if(val)

keyint_class = class_create(this_module,device_name);

device_create(keyint_class,null,devid,null,"%s",device_name);

printk("key initialezed ^_^\n");

return 0; }

static void __exit s3c6410_keyint_exit(void)

module_init(s3c6410_keyint_init);

module_exit(s3c6410_keyint_exit);

module_license("gpl");

通知qt,讓qt捕捉訊號就好了

OK6410裸機程式 hello world

上面已經解決 了幾個問題。現在我們的狀態 可以在pc ok6410 之間進行tftp傳輸,確定了一下可用的位址 空間,下面我們來說一下printf除錯 因為沒有jlink,只能用printf除錯,你也許會問,我們自己實現printf麼?答曰 不是,我們只是弄個hello world,何必那麼認真呢?...

飛凌ok6410開發板的按鍵驅動改程式

因為飛凌開發板自己在核心裡面整合了矩陣鍵盤的驅動,所以要用按鍵做實驗必須先禁用之前的驅動模組,否則的話無法註冊中斷,去檢視free irq的 在kernel irq manage.c中 可以發現,出現這個trying to free already free irq 101 告警的原因是 存在該中斷...

OK6410裸機程式 點亮LED

globl start start 硬體相關的設定 peri port setup ldr r0,0x70000000 orr r0,r0,0x13 mcr p15,0,r0,c15,c2,4 256m 0x70000000 0x7fffffff 關看門狗 往wtcon 0x7e004000 寫0 ...