中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Linux下CPLD驅(qū)動(dòng)程序

        Linux下CPLD驅(qū)動(dòng)程序

        作者: 時(shí)間:2012-05-25 來源:網(wǎng)絡(luò) 收藏

        static unsigned cpld_drv_poll(struct file *file, poll_table *wait)
        {
        unsigned int mask = 0;
        poll_wait(file, eint1_waitq, wait); //不會(huì)立即休眠
        if (ev_eint1)
        mask |= POLLIN | POLLRDNORM; //若產(chǎn)生中斷,mask賦值,表示有數(shù)據(jù)可讀
        return mask;
        }

        static int cpld_drv_fasync (int fd, struct file *filp, int on)
        {
        //printk(driver: cpld_drv_fasyncn);
        return fasync_helper (fd, filp, on, eint1_async);
        }

        int cpld_drv_close(struct inode *inode, struct file *file)
        {
        free_irq(IRQ_EINT1, 1); //釋放中斷
        return 0;
        }

        static struct file_operations cpld_drv_fops = {
        .owner = THIS_MODULE,
        .write = cpld_drv_write,
        .read = cpld_drv_read,
        .open = cpld_drv_open,
        .release = cpld_drv_close,
        .poll = cpld_drv_poll,
        .fasync = cpld_drv_fasync,
        };

        int major;
        static int cpld_drv_init(void)
        {
        major = register_chrdev(0, cpld_drv, cpld_drv_fops); //注冊設(shè)備
        cpld_class = class_create(THIS_MODULE, cplddrv); //創(chuàng)建類
        cpld_class_dev = device_create(cpld_class, NULL, MKDEV(major, 0), NULL, cpld_drv); //自動(dòng)創(chuàng)建設(shè)備文件 /dev/cpld_drv
        cpld_data = (volatile unsigned long *)ioremap(0x08000000,4); //映射物理地址到虛擬地址
        gpfcon = (volatile unsigned long *)ioremap(0x56000050, 8); //映射GPF寄存器物理地址到虛擬地址
        gpfdat = gpfcon+1;
        *gpfcon =~((0x30) | (0x3(2*2)));
        *gpfcon |=((0x10) | (0x01(2*2))); //設(shè)置GPF0、2為輸出
        *gpfdat |=0x1; //將使能位置1,加載驅(qū)動(dòng)時(shí)不輸出PWM
        printk(cpld_drv initialized!n);
        return 0;
        }

        static void cpld_drv_exit(void)
        {
        *gpfdat |=0x1; //將使能位置1,卸載驅(qū)動(dòng)后不輸出PWM
        unregister_chrdev(major, cpld_drv); //注銷驅(qū)動(dòng)
        device_unregister(cpld_class_dev); //注銷設(shè)備
        class_destroy(cpld_class); //注銷類
        iounmap(cpld_data); //取消映射
        iounmap(gpfcon);
        }

        module_init(cpld_drv_init);
        module_exit(cpld_drv_exit);

        MODULE_LICENSE(GPL);

        linux操作系統(tǒng)文章專題:linux操作系統(tǒng)詳解(linux不再難懂)

        上一頁 1 2 下一頁

        關(guān)鍵詞: 驅(qū)動(dòng)程序 CPLD Linux

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉