<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

          嵌入式Linux下USB驅(qū)動(dòng)程序的設(shè)計(jì)

          作者: 時(shí)間:2013-10-08 來源:網(wǎng)絡(luò) 收藏

            else

            { handle_scancode(0xe0,1);

            handle_scancode(0x4d,1);

            handle_scancode(0xe0,0);

            handle_scancode(0x4d,0);

            }

            }

            printk("new=%x %x %x %x %x %x %x %x", kbd->new[0],kbd->new[1],kbd->new[2],kbd->new[3],

            kbd->new[4],kbd->new[5],kbd->new[6],kbd->new[7]);

            }

            static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)

            {

            struct usb_interface *iface;

            struct usb_interface_descriptor *interface;

            struct usb_endpoint_descriptor *endpoint;

            struct usb_kbd *kbd;

            int pipe, maxp;

            iface = dev->actconfig->interface[ifnum];

            interface = iface->altsetting[iface->act_altsetting];

            if ((dev->descriptor.idVendor != _HOTKEY_VENDOR_ID) || (dev->descriptor.idProduct != _HOTKEY_PRODUCT_ID) || (ifnum != 1))

            {

            return NULL;

            }

            if (dev->actconfig->bNumInterfaces != 2)

            {

            return NULL;

            }

            if (interface->bNumEndpoints != 1) return NULL;

            endpoint = interface->endpoint + 0;

            pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);

            maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));

            usb_set_protocol(dev, interface->bInterfaceNumber, 0);

            usb_set_idle(dev, interface->bInterfaceNumber, 0, 0);

            printk(KERN_INFO "GUO: Vid = %.4x, Pid = %.4x, Device = %.2x, ifnum = %.2x, bufCount = %.8x", dev->descriptor.idVendor,dev->descriptor.idProduct,dev->descriptor.bcdDevice, ifnum, maxp);

            if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) return NULL;

            memset(kbd, 0, sizeof(struct usb_kbd));

            kbd->usbdev = dev;

            FILL_INT_URB(kbd->irq, dev, pipe, kbd->new, maxp > 8 ? 8 : maxp, usb_kbd_irq,kbd, endpoint->bInterval); kbd->irq.dev = kbd->usbdev;

            if (dev->descriptor.iManufacturer) usb_string(dev, dev->descriptor.iManufacturer, kbd->name, 63);

            if (usb_submit_urb(kbd->irq)) {

            kfree(kbd); return NULL; }

            printk(KERN_INFO "input%d: %s on usb%d:%d.%d", kbd->dev.number, kbd->name, dev->bus->busnum, dev->devnum, ifnum);

            return kbd; }

            static void usb_kbd_disconnect(struct usb_device *dev, void *ptr)

            {

            struct usb_kbd *kbd = ptr;

            usb_unlink_urb(kbd->irq);

            kfree(kbd);

            }

            static struct usb_device_id usb_kbd_id_table [] = {

            { _DEVICE(USB_HOTKEY_VENDOR_ID, USB_HOTKEY_PRODUCT_ID) },

            { } /* Terminating entry */

            };

            MODULE_DEVICE_TABLE (usb, usb_kbd_id_table);

            static struct usb_driver usb_kbd_driver = {

            name: "Hotkey",

            probe: usb_kbd_probe,

            disconnect: usb_kbd_disconnect,

            id_table: usb_kbd_id_table,

            NULL,

            };

            static int __init usb_kbd_init(void)

            {

            usb_register(usb_kbd_driver);

            info(DRIVER_VERSION ":" DRIVER_DESC);

            return 0;

            }

            static void __exit usb_kbd_exit(void)

            {

            usb_deregister(usb_kbd_driver);

            }

            module_init(usb_kbd_init);

            module_exit(usb_kbd_exit);

            三、結(jié)語

            USB規(guī)范是一門比較新的技術(shù),接口使用方便,但是的設(shè)計(jì)較復(fù)雜。上面介紹了USB設(shè)備的設(shè)計(jì),主要分析了主機(jī)端的設(shè)計(jì),并且給出了一個(gè)編寫USB驅(qū)動(dòng)程序的實(shí)例。

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

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

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



          上一頁 1 2 3 下一頁

          評(píng)論


          相關(guān)推薦

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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();