2012-03-23 29 views
0

要使用的BeagleBoard XM作爲HID外設我打算做到以下幾點:omap_udc.c g_hid.c躲在小工具上的BeagleBoard與埃Linux的

  1. 探索如何與埃建立的東西。
  2. 獲取內核源碼2.6.32。
  3. 編譯omap_udc和g_hid
  4. 插入這些模塊到內核
  5. 從gadget_hid.txt編譯例子
  6. 與hid_gadget_test的/ dev/hidg0鍵盤

  • 發送鍵盤命令這是一個好辦法做我想做的事?

    http://www.edaboard.com/thread145675.html與'09有點相關。

    Looking for Example Embedded Linux HID Device Code非常相似。

  • 回答

    1

    我想我會在這裏發佈這個,因爲我看了,尋找答案,但無濟於事,所以我不得不創意。

    首先 轉到這裏,並得到內核 http://eewiki.net/display/linuxonarm/BeagleBone

    其次在 內核/弓/ ARM /馬赫OMAP2 /板am335xevm.c

    地址:

    enter code here 
    #include <linux/usb/g_hid.h> 
    
    /* hid descriptor for a keyboard */ 
    static struct hidg_func_descriptor my_hid_data = { 
    .subclass  = 0, /* No subclass */ 
    .protocol  = 1, /* Keyboard */ 
    .report_length  = 8, 
    .report_desc_length = 63, 
    .report_desc  = { 
        0x05, 0x01, /* USAGE_PAGE (Generic Desktop)   */ 
        0x09, 0x06, /* USAGE (Keyboard)      */ 
        0xa1, 0x01, /* COLLECTION (Application)    */ 
        0x05, 0x07, /* USAGE_PAGE (Keyboard)    */ 
        0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */ 
        0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */ 
        0x15, 0x00, /* LOGICAL_MINIMUM (0)     */ 
        0x25, 0x01, /* LOGICAL_MAXIMUM (1)     */ 
        0x75, 0x01, /* REPORT_SIZE (1)      */ 
        0x95, 0x08, /* REPORT_COUNT (8)      */ 
        0x81, 0x02, /* INPUT (Data,Var,Abs)     */ 
        0x95, 0x01, /* REPORT_COUNT (1)      */ 
        0x75, 0x08, /* REPORT_SIZE (8)      */ 
        0x81, 0x03, /* INPUT (Cnst,Var,Abs)     */ 
        0x95, 0x05, /* REPORT_COUNT (5)      */ 
        0x75, 0x01, /* REPORT_SIZE (1)      */ 
        0x05, 0x08, /* USAGE_PAGE (LEDs)     */ 
        0x19, 0x01, /* USAGE_MINIMUM (Num Lock)    */ 
        0x29, 0x05, /* USAGE_MAXIMUM (Kana)     */ 
        0x91, 0x02, /* OUTPUT (Data,Var,Abs)    */ 
        0x95, 0x01, /* REPORT_COUNT (1)      */ 
        0x75, 0x03, /* REPORT_SIZE (3)      */ 
        0x91, 0x03, /* OUTPUT (Cnst,Var,Abs)    */ 
        0x95, 0x06, /* REPORT_COUNT (6)      */ 
        0x75, 0x08, /* REPORT_SIZE (8)      */ 
        0x15, 0x00, /* LOGICAL_MINIMUM (0)     */ 
        0x25, 0x65, /* LOGICAL_MAXIMUM (101)    */ 
        0x05, 0x07, /* USAGE_PAGE (Keyboard)    */ 
        0x19, 0x00, /* USAGE_MINIMUM (Reserved)    */ 
        0x29, 0x65, /* USAGE_MAXIMUM (Keyboard Application) */ 
        0x81, 0x00, /* INPUT (Data,Ary,Abs)     */ 
        0xc0  /* END_COLLECTION       */ 
    } 
    }; 
    
    static struct platform_device my_hid = { 
    .name   = "hidg", 
    .id   = 0, 
    .num_resources  = 0, 
    .resource  = 0, 
    .dev = { 
    .platform_data = &my_hid_data, 
    }, 
    }; 
    
    static void __init am33xx_hidg_init(void) 
    { 
    int ret; 
    
    
    
    ret = platform_device_register(&my_hid); 
    
    
    if (ret) 
        printk("HID Gadget registration failed\n"); 
    
    } 
    

    在:

    static void __init am335x_evm_init(void) 
    { 
    am33xx_cpuidle_init(); 
    am33xx_mux_init(board_mux); 
    omap_serial_init(); 
    am335x_rtc_init(); 
    **am33xx_hidg_init();** 
    clkout2_enable(); 
    } 
    

    按照之前的指南構建內核 在內核版本 的makemenu config部分中,轉至設備驅動程序 - > usb support-> USB Gadget Support-> USB Gadget Drivers - >將HID Gadget編譯爲模塊(可以必須去尋找它,但它是圍繞一對夫婦更多的子菜單本節)

    採取從內核文件 示例代碼部分或本頁面http://www.mjmwired.net/kernel/Documentation/usb/gadget_hid.txt

    編譯GCC

    insmod的的g_hid。 ko驅動程序 然後運行編譯示例代碼