[ 1966.839917] usb 3-1: USB disconnect, device number 22 [ 1971.497942] usb 3-1: new full-speed USB device number 23 using ohci_hcd [ 1971.672939] usb 3-1: New USB device found, idVendor=fff0, idProduct=0001 [ 1971.672957] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1971.672966] usb 3-1: Product: LPC13xx USB HID [ 1971.672975] usb 3-1: Manufacturer: NXP SEMICOND [ 1971.672984] usb 3-1: SerialNumber: DEMO00000001 [ 1971.681803] input: NXP SEMICOND LPC13xx USB HID as /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input35 [ 1971.682183] hid-generic 0003:FFF0:0001.0018: input,hidraw2: USB HID v1.00 Mouse [NXP SEMICOND LPC13xx USB HID ] on usb-0000:00:12.0-1/input0 [ 2136.392365] usb 3-1: USB disconnect, device number 23 |
USB_WriteEP(0x81, &InReport, sizeof(InReport)); |
usbdesc.c /* HID Report Descriptor */ const uint8_t HID_ReportDescriptor[] = { 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x03, // USAGE_MAXIMUM (Button 3) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x95, 0x03, // REPORT_COUNT (3) 0x75, 0x01, // REPORT_SIZE (1) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x05, // REPORT_SIZE (5) 0x81, 0x03, // INPUT (Cnst,Var,Abs) 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x02, // REPORT_COUNT (2) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xc0 // END_COLLECTION }; |
byte offset 0 button1 (LSB), button2, button3, and 5 bits padding 1 X axis 2 Y axis |
config.h #define USB_VENDOR_ID NXP_VID // Vendor ID <---- 0xFFF0 #define USB_PROD_ID 0x0003// Product ID <---- 0x0001 |
usbdesc.c /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor) */ const uint8_t USB_ConfigDescriptor[] = { ... /* 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(0x0004), /* wMaxPacketSize */ <---- WBVAL(0x0003) 0x20, /* 32ms */ /* bInterval */ <---- 0x01 ... |
usbdesc.c /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor) */ const uint8_t USB_ConfigDescriptor[] = { ... /* 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_SUBCLASS_BOOT HID_PROTOCOL_NONE, /* bInterfaceProtocol */ <---- HID_PROTOCOL_MOUSE 0x00, /* iInterface */ ... |
usbuser.c #define HID_BOOT_PROTOCOL 0 #define HID_REPORT_PROTOCOL 1 extern uint8_t HID_Protocol; uint8_t hid_int_EP_busy; #if USB_CONFIGURE_EVENT void USB_Configure_Event (void) { if (USB_Configuration) { /* Check if USB is configured */ /* comment these lines GetInReport(); USB_WriteEP(0x81, &InReport, sizeof(InReport)); */ HID_Protocol = HID_REPORT_PROTOCOL; // the default is report protocol hid_int_EP_busy = FALSE; } } #endif |
hiduser.c uint8_t InReport; <---- InReport[3] demo.h extern uint8_t InReport; <---- InReport[3] |
usbuser.c void USB_EndPoint1 (uint32_t event) { switch (event) { case USB_EVT_IN: /* comment this line GetInReport(); */ if ( hid_int_EP_busy ) { USB_WriteEP(0x81, &InReport, sizeof(InReport)); hid_int_EP_busy = FALSE; } break; } } |
void timer_ISR( void ) { if ( ! hid_int_EP_busy ) { // // poll mouse movement and its buttons, here // InReport[0] = buttons; // put input report to the buffer InReport[1] = x_relative_movement; InReport[2] = y_relative_movement; hid_int_EP_busy = TRUE; LPC_USB->DevIntSet = 1 << 2; // force endpoint 1 interrupt } LPC_TMR32B0->IR = 1;/* clear interrupt flag */ } |