Content originally posted in LPCWare by maxxracing on Fri Dec 04 06:35:51 MST 2015
Hello,
I would like to make a USB HID Keyboard with my LPC1754.
I have already a program with the LPC1754 with a usb hid, but i on the PC side i have a software that make a HID connection and after that a make transactions.
I would like that my board be recognised by the PC like a hid keyboard, and the datas send to the PC will be write on the active cursor like a hid keyboard.
I already modify HID_ReportDescriptor[] in the file usbdesc.c, the PC recognised the board like a keyboard PIH, so i think it's a good start.
But after that i can't send data to the PC.
I have in the file usbuser.c this callback, but since i modify HID_ReportDescriptor, it's not tell:
/*
* USB Endpoint 1 Event Callback
* Called automatically on USB Endpoint 1 Event
* Parameter: event
*/
void USB_EndPoint1 (uint32_t event) {
switch (event) {
case USB_EVT_IN:
GetInReport();
USB_WriteEP(HID_EP_IN, &InReport, sizeof(InReport));
break;
}
}
file usbdesc.c :
const uint8_t HID_ReportDescriptor[] = {
/****/ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
/****/ 0x09, 0x06, /* USAGE (Keyboard) */
/****/ 0xa1, 0x01, /* COLLECTION (Application) */
/******/ 0x05, 0x07, /* USAGE_PAGE (Keyboard) */
/******/ 0x85, 0x01, /* REPORT_ID (1) */
/* Ctrl, Shift and other modifier keys, 8 in total */
/******/ 0x19, 0xe0, /* USAGE_MINIMUM (kbd LeftControl) */
/******/ 0x29, 0xe7, /* USAGE_MAXIMUM (kbd 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) */
/* Reserved byte */
/******/ 0x95, 0x01, /* REPORT_COUNT (1) */
/******/ 0x75, 0x08, /* REPORT_SIZE (8) */
/******/ 0x81, 0x01, /* INPUT (Cnst,Ary,Abs) */
/* LEDs for num lock etc */
/******/ 0x95, 0x05, /* REPORT_COUNT (5) */
/******/ 0x75, 0x01, /* REPORT_SIZE (1) */
/******/ 0x05, 0x08, /* USAGE_PAGE (LEDs) */
/******/ 0x85, 0x01, /* REPORT_ID (1) */
/******/ 0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */
/******/ 0x29, 0x05, /* USAGE_MAXIMUM (Kana) */
/******/ 0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
/* Reserved 3 bits */
/******/ 0x95, 0x01, /* REPORT_COUNT (1) */
/******/ 0x75, 0x03, /* REPORT_SIZE (3) */
/******/ 0x91, 0x03, /* OUTPUT (Cnst,Var,Abs) */
/* Slots for 6 keys that can be pressed down at the same time */
/******/ 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 (no event indicated)) */
/******/ 0x29, 0x65, /* USAGE_MAXIMUM (Keyboard Application) */
/******/ 0x81, 0x00, /* INPUT (Data,Ary,Abs) */
/****/ 0xc0, // END_COLLECTION
};
/* USB Standard Device Descriptor */
const uint8_t USB_DeviceDescriptor[] = {
USB_DEVICE_DESC_SIZE, /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0200), /* 2.00 */ /* bcdUSB */
0x00, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
USB_MAX_PACKET0, /* bMaxPacketSize0 */
WBVAL(0x1FC9), /* idVendor */
WBVAL(0x8002), /* idProduct */
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
0x01, /* iManufacturer */
0x02, /* iProduct */
0x03, /* iSerialNumber */
0x01 /* bNumConfigurations: one possible configuration*/
};
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor) */
const uint8_t USB_ConfigDescriptor[] = {
/* Configuration 1 */
USB_CONFIGUARTION_DESC_SIZE, /* bLength */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL( /* wTotalLength */
USB_CONFIGUARTION_DESC_SIZE +
USB_INTERFACE_DESC_SIZE +
HID_DESC_SIZE +
USB_ENDPOINT_DESC_SIZE
),
0x01, /* bNumInterfaces */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */
/*USB_CONFIG_REMOTE_WAKEUP*/,
USB_CONFIG_POWER_MA(100), /* bMaxPower */
/* Interface 0, Alternate Setting 0, HID Class */
USB_INTERFACE_DESC_SIZE, /* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x01, /* bNumEndpoints */
USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */
HID_SUBCLASS_NONE, /* bInterfaceSubClass */
HID_PROTOCOL_NONE, /* bInterfaceProtocol */
0x04, /* iInterface */
/* HID Class Descriptor */
/* HID_DESC_OFFSET = 0x0012 */
HID_DESC_SIZE, /* bLength */
HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0100), /* 1.00 */ /* bcdHID */
0x00, /* bCountryCode */
0x01, /* bNumDescriptors */
HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(HID_REPORT_DESC_SIZE), /* wDescriptorLength */
/* Endpoint, HID Interrupt In */
USB_ENDPOINT_DESC_SIZE, /* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
USB_ENDPOINT_IN(1), /* bEndpointAddress */
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
WBVAL(0x0040), /* wMaxPacketSize */ //OLD 0x0004
0x40, /* 32ms */ //OLD 0x20 /* bInterval */
/* Terminator */
0 /* bLength */
};
If someone can help me :)
If you need i can send more code for help.
Thank's.