omap_udc.c g_hid.c hid gadget在beagleboard与angstrom linux [英] omap_udc.c g_hid.c hid gadget on beagleboard with angstrom linux
问题描述
要使用beagleboard xm作为HID外设,我计划执行以下操作:
To use the beagleboard xm as an HID peripheral I plan to do the following:
- 发现如何用埃及构建东西。 / li>
- 获取内核源码2.6.32。
- 编译omap_udc和g_hid
- 将这些模块插入内核
- 编辑gadget_hid.txt中的示例
- 使用hid_gadget_test / dev / hidg0键盘发送键盘命令
- Discover how to build things with angstrom.
- Get the kernel source 2.6.32.
- Compile omap_udc and g_hid
- Insert those modules into the kernel
- Compile the example from gadget_hid.txt
- Send keyboard commands with hid_gadget_test /dev/hidg0 keyboard
这是一个很好的方法来做我想要的东西?
Is that a good way to do what I want?
http://www.edaboard.com/thread145675.html 是与'09相关的问题。
http://www.edaboard.com/thread145675.html is a somewhat related issue from '09.
寻找例如嵌入式Linux HID设备代码是非常相似的。
推荐答案
我想我会在这里发布,因为我看了一下答案, o有用,所以我得到创意。
I figured I would post this here because I looked and looked for an answer but to no avail so I had to get creative.
首先
去这里获取内核
http://eewiki.net/display/linuxonarm/BeagleBone
第二个
KERNEL / arch / arm / mach-omap2 / board-am335xevm.c
Second in The KERNEL/arch/arm/mach-omap2/board-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配置内核构建
转到设备驱动程序 - > usb支持 - > USB小工具支持 - > USB小工具驱动程序 - >编译HID小工具作为模块(您可能必须寻找它,但它在这个部分在更多子菜单)
Build the kernel following the Guide from earlier In the makemenu config section of the kernel build go to the device drivers->usb support-> USB Gadget Support-> USB Gadget Drivers -> Compile HID Gadget as Module ( you may have to hunt for it but it's around this section in a couple more sub menus)
从内核文档
或此页面中的示例代码部分 http://www.mjmwired.net/kernel/Documentation/usb/gadget_hid.txt
编译GCC
insmod g_hid.ko驱动
然后运行编译后的示例代码
insmod the g_hid.ko driver and then run the compiled sample code
这篇关于omap_udc.c g_hid.c hid gadget在beagleboard与angstrom linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!