青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天下

記錄修行的印記

韋根驅動

#include <linux/types.h>
#include 
<linux/module.h>
#include 
<linux/init.h>
#include 
<linux/poll.h>
#include 
<linux/errno.h>
#include 
<linux/gpio.h>
#include 
<linux/interrupt.h>
#include 
<linux/miscdevice.h>
#include 
<linux/ioport.h>
#include 
<linux/device.h>
#include 
<asm/io.h>
#include 
<asm/irq.h>
#include 
<mach/irqs.h>
#include 
<mach/regs-gpio.h>

#include 
"../ioctl_new.h"

static spinlock_t    wiegand_lock;
static int            wiegand_in = 0;
static int            wiegand_in_cur = 0;
static int            wiegand_in_stime = 0;
static int            wiegand_in1_stime = 0;
static int            wiegand_in2_stime = 0;
static unsigned char wiegand_data[40];
static WIEGAND_TYPE    wiegand_mode;

inline 
void wiegand_delay(int microseconds)
{
    
int i;
    
while (microseconds--)
    {
        
for (i=0; i<65; i++) __asm("NOP");
    }
}

static int wiegand_gettickcount(void)
{
    
static int __start_time = 0//second
    struct timeval tv;

    do_gettimeofday(
&tv);

    
if (__start_time == 0)
        __start_time 
= tv.tv_sec;

    
return ((tv.tv_sec - __start_time) * 1000 + tv.tv_usec / 1000);
}

inline 
void wiegand_minus_interrupt(void)
{
    
if (wiegand_in != WGNSTAT_RECVFULL)
    {
        
if (wiegand_gettickcount() - wiegand_in_stime >= 100)
            wiegand_in_cur 
= 0;
        wiegand_in_stime 
= wiegand_gettickcount();
        wiegand_data[wiegand_in_cur
++= 0;
        
if (wiegand_in_cur >= 34)
            wiegand_in 
= WGNSTAT_RECVFULL;
        
else if (wiegand_in_cur >= 26)
            wiegand_in 
= WGNSTAT_RECV26;
    }
}

inline 
void wiegand_plus_interrupt(void)
{
    
if (wiegand_in != WGNSTAT_RECVFULL)
    {
        
if (wiegand_gettickcount() - wiegand_in_stime >= 100)
            wiegand_in_cur 
= 0;
        wiegand_in_stime 
= wiegand_gettickcount();
        wiegand_data[wiegand_in_cur
++= 1;
        
if (wiegand_in_cur >= 34)
            wiegand_in 
= WGNSTAT_RECVFULL;
        
else if (wiegand_in_cur >= 26)
            wiegand_in 
= WGNSTAT_RECV26;
    }
}

static irqreturn_t wiegand_minus1_interrupt(int irq, void *dev_id)
{
    spin_lock(
&wiegand_lock);
//    printk("wiegand_minus1_interrupt\n");
    if (wiegand_gettickcount() - wiegand_in2_stime > 200)
    {
        wiegand_minus_interrupt();
        wiegand_in1_stime 
= wiegand_in_stime;
    }
    spin_unlock(
&wiegand_lock);
    
return IRQ_HANDLED;
}

static irqreturn_t wiegand_plus1_interrupt(int irq, void *dev_id)
{
    spin_lock(
&wiegand_lock);
//    printk("wiegand_plus1_interrupt\n");
    if (wiegand_gettickcount() - wiegand_in2_stime > 200)
    {
        wiegand_plus_interrupt();
        wiegand_in1_stime 
= wiegand_in_stime;
    }
    spin_unlock(
&wiegand_lock);
    
return IRQ_HANDLED;
}


static int wiegand_open(struct inode * inode, struct file * filp);
static int wiegand_release(struct inode * inode,struct file * filp);
static ssize_t wiegand_read(struct file *flip, char *buf, size_t len, loff_t *pos);
static ssize_t wiegand_write(struct file *flip, const char *buf, size_t len, loff_t *pos);
static long wiegand_ioctl(struct file *file, unsigned int cmd, unsigned long arg);

static struct file_operations wiegand_fops = {
    owner:        THIS_MODULE,
    open:        wiegand_open,
    release:    wiegand_release,
    read:        wiegand_read,
    write:        wiegand_write,
    unlocked_ioctl:        wiegand_ioctl,
};

static struct miscdevice wiegand_dev = {
    WIEGAND_MINOR,
    WIEGAND_MODULE_NAME,
    
&wiegand_fops
};

static void config_wiegand_pins(void)
{
    s3c2410_gpio_cfgpin(WGNIN_0, WGNIN_0_CON);
    s3c2410_gpio_cfgpin(WGNIN_1, WGNIN_1_CON);
    s3c2410_gpio_cfgpin(WGNOUT0, WGNOUT0_CON);
    s3c2410_gpio_cfgpin(WGNOUT1, WGNOUT1_CON);
#if 0
    
if (request_irq(WGNIN_0_IRQ_NUM, &wiegand_minus1_interrupt, 
        IORESOURCE_IRQ 
| IRQF_TRIGGER_RISING, 
        WIEGAND_IRQ_MINUS, 
        
&wiegand_dev)         
        
|| request_irq(WGNIN_1_IRQ_NUM, &wiegand_plus1_interrupt,  
        IORESOURCE_IRQ 
| IRQF_TRIGGER_RISING, 
        WIEGAND_IRQ_PLUS, 
        
&wiegand_dev))
        
    {
        printk(
"WIEGAND request_irq Fail\n");
    }
#endif
}

static int wiegand_open(struct inode * inode, struct file * filp)
{
    config_wiegand_pins();
    
return 0;
}

static int wiegand_release(struct inode * inode,struct file * filp)
{
#if 0
    free_irq(WGNIN_0_IRQ_NUM, 
&wiegand_dev);
    free_irq(WGNIN_1_IRQ_NUM, 
&wiegand_dev);
#endif
    
return 0;
}

static ssize_t wiegand_read(struct file *flip, char *buf, size_t len, loff_t *pos)
{
    
int result;
    spin_lock(
&wiegand_lock);
    
if (wiegand_in == WGNSTAT_NONE || len > sizeof(wiegand_data) || (wiegand_gettickcount() - wiegand_in_stime > 1800))        //500
    {
        wiegand_in 
= WGNSTAT_NONE;
        spin_unlock(
&wiegand_lock);
        
return 0;
    }
    
if (len > wiegand_in_cur)
        len 
= wiegand_in_cur;
    result 
= copy_to_user(buf, wiegand_data, len);
    wiegand_in 
= WGNSTAT_NONE;
    wiegand_in_cur 
= 0;
    spin_unlock(
&wiegand_lock);
    
return len;
}

static ssize_t wiegand_write(struct file *flip, const char *buf, size_t len, loff_t *pos)
{
    
int i;
    
char data[40];

    
if (len > sizeof(data))
        
return 0;

    i 
= copy_from_user(data, buf, len);
    
for (i=0; i<len; i++)
    {
        
if (data[i] == 0)
        {
            WGNOUT0_1; wiegand_delay(wiegand_mode.dwTpw); WGNOUT0_0;
        }
        
else
        {
            WGNOUT1_1; wiegand_delay(wiegand_mode.dwTpw); WGNOUT1_0;
        }
        wiegand_delay(wiegand_mode.dwTpi);
    }

    
return len;
}

static long wiegand_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    
int result = 0;
    spin_lock(
&wiegand_lock);
    
switch(cmd)
    {
    
case WIEGAND_MODE_SET:
        result 
= copy_from_user(&wiegand_mode, (void*)arg, sizeof(WIEGAND_TYPE));
        
break;
    }
    spin_unlock(
&wiegand_lock);
    
return (result == sizeof(WIEGAND_TYPE) ? 0 : -1);
}



static int __init s3c2416_wiegand_init(void)
{
    
int ret = 0;
    
    ret 
= misc_register(&wiegand_dev);
    
if (ret)
    {
        printk(
"probuck s3c2416 WIEGAND Driver" WIEGAND_DRIVER_VERSION "Fail\n");
        
goto exit_sb3kt_wiegand_init;
    }
    spin_lock_init(
&wiegand_lock);

    printk(
"probuck s3c2416 WIEGAND Driver" WIEGAND_DRIVER_VERSION "\n");
    
exit_sb3kt_wiegand_init:
    
return ret;
}

static void __exit s3c2416_wiegand_cleanup(void)
{
    misc_deregister(
&wiegand_dev);
}

module_init(s3c2416_wiegand_init);
module_exit(s3c2416_wiegand_cleanup);
MODULE_LICENSE(
"GPL");

MODULE_DESCRIPTION(
"s3c2416 WIEGAND Driver");
MODULE_SUPPORTED_DEVICE(
"s3c2416 WIEGAND");

posted on 2014-03-21 17:33 天下 閱讀(1374) 評論(0)  編輯 收藏 引用 所屬分類: kernel & Driver

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

導航

統計

常用鏈接

留言簿(4)

隨筆分類(378)

隨筆檔案(329)

鏈接

最新隨筆

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美国产日韩亚洲一区| 欧美亚洲一级片| 亚洲日本中文| 国产精品成人一区| 美女精品在线| 国产日韩欧美黄色| 开心色5月久久精品| 欧美日韩精品不卡| 蜜桃精品久久久久久久免费影院| 欧美日韩在线一区二区| 欧美电影在线播放| 一区二区三区欧美日韩| 午夜亚洲性色视频| 欧美精品v日韩精品v国产精品| 久久久久久夜| 国产目拍亚洲精品99久久精品| 亚洲激情另类| 亚洲国产精品热久久| 午夜宅男欧美| 午夜精品久久一牛影视| 欧美日韩国产欧美日美国产精品| 免费精品视频| 韩国三级电影久久久久久| 亚洲欧美日本精品| 亚洲综合精品| 国产精品白丝av嫩草影院| 亚洲欧洲精品一区二区三区| 在线观看日韩精品| 欧美一区二区视频在线观看| 欧美一区二区| 国产精品第一区| 99国产精品99久久久久久粉嫩| 亚洲精品日韩在线| 欧美激情一区二区三区不卡| 亚洲春色另类小说| 亚洲激情另类| 欧美高清视频| 亚洲麻豆一区| 亚洲性视频网址| 国产精品极品美女粉嫩高清在线 | 欧美日韩国产片| 欧美在线播放一区| 国产精品一区二区你懂的| 亚洲午夜在线| 欧美一区二区三区视频在线| 国产欧美一区二区三区国产幕精品| 亚洲一区二区三区中文字幕在线 | 亚洲国产精品久久人人爱蜜臀| 久久九九电影| 欧美激情中文字幕乱码免费| 亚洲精选久久| 欧美性理论片在线观看片免费| 一区二区日韩精品| 欧美影院精品一区| 在线日韩电影| 欧美福利专区| 亚洲综合视频1区| 久久久综合网站| 亚洲欧洲精品一区二区| 欧美日韩亚洲一区| 羞羞视频在线观看欧美| 欧美成人精品高清在线播放| 99精品国产热久久91蜜凸| 国产精品播放| 久久国产精品久久久| 蜜桃av综合| 亚洲欧美乱综合| 伊人狠狠色j香婷婷综合| 99视频精品免费观看| 欧美另类视频在线| 亚洲天堂网在线观看| 欧美一区二区三区免费看| 国产精品一区二区三区乱码| 久久伊人亚洲| 亚洲免费电影在线观看| 久久精品国产视频| 亚洲理论在线观看| 国产区精品视频| 欧美大胆成人| 亚洲欧美在线另类| 亚洲三级影院| 久久免费国产精品| 亚洲一区欧美激情| 亚洲成人原创| 国产精品一区二区女厕厕| 欧美高清视频一二三区| 欧美一区二区三区四区视频| 亚洲精品在线视频| 欧美成人一区二区三区片免费| 亚洲欧美日韩成人| 日韩五码在线| 在线欧美日韩| 国产老女人精品毛片久久| 欧美激情一区二区三区高清视频 | 99re66热这里只有精品4| 久久三级福利| 亚洲午夜精品久久| 亚洲日本aⅴ片在线观看香蕉| 国产自产在线视频一区| 欧美国产精品va在线观看| 欧美一区=区| 一区二区欧美在线| 亚洲二区视频| 免费欧美日韩| 久久综合久久美利坚合众国| 午夜视频一区在线观看| 最新国产成人在线观看| 亚洲欧洲精品一区二区三区| 国产一区二区丝袜高跟鞋图片 | 欧美激情精品| 久久久久网站| 久久激情视频久久| 久久不射网站| 香蕉av777xxx色综合一区| 亚洲深夜影院| 这里只有精品电影| 亚洲视频免费在线| 一区二区三区www| 99re6这里只有精品视频在线观看| 亚洲国产婷婷综合在线精品| 亚洲第一在线综合在线| 亚洲国产日韩综合一区| 亚洲黄网站黄| 日韩小视频在线观看| 亚洲国产婷婷| 亚洲日本免费| 在线视频你懂得一区| 亚洲一二三区在线| 亚洲最新视频在线| 亚洲宅男天堂在线观看无病毒| 欧美日韩一区二| 欧美成人精品影院| 欧美电影电视剧在线观看| 欧美激情在线播放| 欧美天堂亚洲电影院在线观看 | 久久久爽爽爽美女图片| 欧美一级理论性理论a| 久久精品一区二区三区不卡牛牛| 久久精品亚洲乱码伦伦中文| 久久综合狠狠综合久久综青草| 另类综合日韩欧美亚洲| 欧美激情精品久久久久久变态 | 国产精品欧美在线| 国产精品嫩草99av在线| 国产日韩亚洲欧美精品| 伊人久久成人| 亚洲美女在线一区| 欧美一级二区| 久久综合九色| 亚洲精品小视频在线观看| 亚洲欧美成人网| 久久综合久久综合九色| 欧美日韩国产一级| 国产一区导航| 亚洲六月丁香色婷婷综合久久| 亚洲欧美国产77777| 久久精品人人做人人综合| 亚洲国产欧美久久| 亚洲一二三四区| 欧美成人黄色小视频| 国产精品久久久久久一区二区三区 | 国产一区二区| 一区二区不卡在线视频 午夜欧美不卡'| 亚洲一区二区三区高清不卡| 久久狠狠一本精品综合网| 亚洲激情偷拍| 欧美一区二区啪啪| 欧美日韩国产123区| 伊人成人在线视频| 午夜在线成人av| 亚洲丁香婷深爱综合| 午夜精品福利一区二区蜜股av| 欧美刺激午夜性久久久久久久| 欧美午夜精品电影| 亚洲高清资源综合久久精品| 午夜国产精品影院在线观看 | 欧美一级大片在线观看| 亚洲欧美日韩中文播放| 欧美日韩1区2区| 亚洲二区视频| 久久久91精品国产| 在线中文字幕不卡| 欧美激情国产日韩| 亚洲高清资源| 久久亚洲精品网站| 亚洲欧美日产图| 国产精品chinese| 一本久久综合| 亚洲国产美女| 米奇777超碰欧美日韩亚洲| 国产欧美日韩一区二区三区在线| 一区二区三区视频在线| 亚洲黄页视频免费观看| 免费视频亚洲| 在线日韩精品视频| 欧美国产日本在线| 久久婷婷一区| 亚洲第一综合天堂另类专| 毛片基地黄久久久久久天堂| 久久精品123|