在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 嵌入式Linux設(shè)備驅(qū)動(dòng)開發(fā)之:GPIO驅(qū)動(dòng)程序?qū)嵗?/p>

            嵌入式Linux設(shè)備驅(qū)動(dòng)開發(fā)之:GPIO驅(qū)動(dòng)程序?qū)嵗?/h1>
            作者: 時(shí)間:2013-09-13 來源:網(wǎng)絡(luò) 收藏

            本文引用地址:http://www.biyoush.com/article/257110.htm

            staticintgpio_ioctl(structinode*inode,structfile*file,

            unsignedintcmd,unsignedlongarg)

            {/*ioctl函數(shù)接口:主要接口的實(shí)現(xiàn)。對5個(gè)GPIO設(shè)備進(jìn)行控制(發(fā)亮或發(fā)聲)*/

            unsignedintswt=(unsignedint)arg;

            switch(cmd)

            {

            caseLED_D09_SWT:

            {

            switch_gpio(S3C2410_GPF7,swt);

            }

            break;

            caseLED_D10_SWT:

            {

            switch_gpio(S3C2410_GPF6,swt);

            }

            break;

            caseLED_D11_SWT:

            {

            switch_gpio(S3C2410_GPF5,swt);

            }

            break;

            caseLED_D12_SWT:

            {

            switch_gpio(S3C2410_GPF4,swt);

            }

            break;

            caseBEEP_SWT:

            {

            switch_gpio(S3C2410_GPB0,swt);

            break;

            }

            default:

            {

            printk(Unsupportedcommandn);

            break;

            }

            }

            return0;

            }

            staticintgpio_release(structinode*node,structfile*file)

            {/*release操作函數(shù),熄滅所有燈和關(guān)閉蜂鳴器*/

            switch_gpio(S3C2410_GPB0,BEEP_SWT_OFF);

            switch_gpio(S3C2410_GPF4,LED_SWT_OFF);

            switch_gpio(S3C2410_GPF5,LED_SWT_OFF);

            switch_gpio(S3C2410_GPF6,LED_SWT_OFF);

            switch_gpio(S3C2410_GPF7,LED_SWT_OFF);

            return0;

            }

            staticvoidgpio_setup_cdev(structcdev*dev,intminor,

            structfile_operations*fops)

            {/*字符設(shè)備的創(chuàng)建和注冊*/

            interr,devno=MKDEV(major,minor);

            cdev_init(dev,fops);

            dev->owner=THIS_MODULE;

            dev->ops=fops;

            err=cdev_add(dev,devno,1);

            if(err)

            {

            printk(KERN_NOTICEError%daddinggpio%d,err,minor);

            }

            }

            staticstructfile_operationsgpio_fops=

            {/*gpio設(shè)備的file_operations結(jié)構(gòu)定義*/

            .owner=THIS_MODULE,

            .open=gpio_open,/*進(jìn)行初始化配置*/

            .release=gpio_release,/*關(guān)閉設(shè)備*/

            .read=gpio_read,

            .write=gpio_write,

            .ioctl=gpio_ioctl,/*實(shí)現(xiàn)主要控制功能*/

            };

            staticstructcdevgpio_devs;

            staticintgpio_init(void)

            {

            intresult;

            dev_tdev=MKDEV(major,0);

            if(major)

            {/*設(shè)備號的動(dòng)態(tài)分配*/

            result=register_chrdev_region(dev,1,GPIO_DEVICE_NAME);

            }

            else

            {/*設(shè)備號的動(dòng)態(tài)分配*/

            result=alloc_chrdev_region(dev,0,1,GPIO_DEVICE_NAME);

            major=MAJOR(dev);

            }

            if(result0)

            {

            printk(KERN_WARNINGGpio:unabletogetmajor%dn,major);

            returnresult;

            }

            gpio_setup_cdev(gpio_devs,0,gpio_fops);

            printk(Themajorofthegpiodeviceis%dn,major);

            return0;

            }

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

            linux相關(guān)文章:linux教程


            蜂鳴器相關(guān)文章:蜂鳴器原理


            評論


            相關(guān)推薦

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

            關(guān)閉