Hi all,
I am trying the keil usbhid example with my board and gui. My aim is to send three adc value to my gui by usb. but i can send only one adc data, i can't send the other two. I have tried to change the descriptor file but i couldn't. I think i have to send my adc data as byte pockets, in other words as char array, but i couldn't set them. If you know how i can do it please help me.
I have tried to change the descriptor file but i couldn't.
Is the file read only?
No it isn't. I mean when i tried to change some descriptions the code didn't work. Maybe i have done wrong something. For example i have changed the descriptor sizes and Inreport/OutReport to arrays the code didn't work. Like this;
#define HID_INPUT_REPORT_BYTES 8 /* size of report in Bytes */ #define HID_OUTPUT_REPORT_BYTES 8 /* size of report in Bytes */ #define HID_FEATURE_REPORT_BYTES 8 /* size of report in Bytes */
extern uint8_t InReport[8]; extern uint8_t OutReport[8];
is there anyone can help me? :)
> I am trying the keil usbhid example with my board and gui. Is this example? C:\Keil\ARM\Boards\Keil\MCB1700\USBHID
You may increase wMaxPacketSize of the endpoint, so that your 8-bytes input report is sent in single transaction. Also, you may change bInterval value, to send the input report more frequently.
usbdesc.c const U8 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(HID_INPUT_REPORT_BYTES), 0x20, /* 32ms */ /* bInterval */ // <----- 0x01, // 1ms /* Terminator */ 0 /* bLength */ };
demo.c // U8 InReport; /* HID Input Report */ U8 InReport[HID_INPUT_REPORT_BYTES]; /* HID Input Report */ void GetInReport (void) { // // fill InReport[] with your data, here // }
Test the firmware change using SimpleHIDWrite.exe, first.
SimpleHIDWrite on Jan Axelson's site www.lvr.com/.../SimpleHIDWrite3.zip
Plug-in your device, and run SimpleHIDWrite. Click "Keil MCB1700 HID" on the top list. The input reports are displayed on the pane.
Tsuneo
usbdesc.c
#define HID_INPUT_REPORT_BYTES 8 /* size of report in Bytes */ #define HID_OUTPUT_REPORT_BYTES 8 /* size of report in Bytes */ #define HID_FEATURE_REPORT_BYTES 8 /* size of report in Bytes */ const uint8_t HID_ReportDescriptor[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(3), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(3), HID_ReportSize(1), HID_Input(HID_Data | HID_Variable | HID_Absolute), HID_ReportCount(1), HID_ReportSize(5), HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(8), HID_ReportSize(1), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, }; const uint16_t HID_ReportDescSize = sizeof(HID_ReportDescriptor); /* 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 + 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 */ 0x02, /* 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(0x0008), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0008), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Terminator */ 0 /* bLength */ };
demo.c
uint8_t InReport[8]; /* HID Input Report */ /* Bit0 : Buttons */ /* Bit1..7: Reserved */ uint8_t OutReport[8]; /* HID Out Report */ /* Bit0..7: LEDs */ /* * Get HID Input Report -> InReport */ void GetInReport (void) { InReport[1]=55; }
my demo.c and usbdesc.c files are above. when it sends inreport data to host, my gui remains motionless and it doesn't do anything
I am using keil sample code bundle usbhid example.
ics.nxp.com/.../
View all questions in Keil forum