Hi!
I'm working on LPC1768 MCU.
I'm writing a program based on USBHID example delivered by Keil, and I'm trying to modify it to a Vendor specific in order to use a bulk transer, to deliver data from ADC to GUI interface.
The problem I'm actually faceing is how to make my MCU understand the commands from my GUI interface like:
const byte SWITCH_LED = 0xE0; const byte READ_ADC = 0xDE;
I thought that the easiest way is to scan an endpoit, to which I'm sending the command and if anything appears, scan it(the buffer) for a command. But it looks unprofessional IMHO. In Keil example there is something much more smarter, which I don't completely understand. They are using theese functions:
hiduser.c uint32_t HID_GetReport (void) { /* ReportID = SetupPacket.wValue.WB.L; */ switch (SetupPacket.wValue.WB.H) { case HID_REPORT_INPUT: GetInReport(); EP0Buf[0] = InReport; break; case HID_REPORT_OUTPUT: return (FALSE); /* Not Supported */ case HID_REPORT_FEATURE: /* EP0Buf[] = ...; */ /* break; */ return (FALSE); /* Not Supported */ } return (TRUE); } /* * HID Set Report Request Callback * Called automatically on HID Set Report Request * Parameters: None (global SetupPacket and EP0Buf) * Return Value: TRUE - Success, FALSE - Error */ uint32_t HID_SetReport (void) { /* ReportID = SetupPacket.wValue.WB.L; */ switch (SetupPacket.wValue.WB.H) { case HID_REPORT_INPUT: return (FALSE); /* Not Supported */ case HID_REPORT_OUTPUT: *OutReport = EP0Buf[0]; SetOutReport(); break; case HID_REPORT_FEATURE: return (FALSE); /* Not Supported */ } return (TRUE); }
And they are calling them from
usbcore.c #if USB_HID if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) { // IF number correct? switch (SetupPacket.bRequest) { case HID_REQUEST_GET_REPORT: if (HID_GetReport()) { EP0Data.pData = EP0Buf; // point to data to be sent USB_DataInStage(); // send requested data goto setup_class_ok; } break;
Finally, the question is: Is it possible(think it is) to modify a Vendor Specific to achieve that, and where to send commands to, for instance, get to the command HID_REQUEST_GET_REPORT.
Thank You in advance for a reply, and sorry if I was unprecise.
Hope That I'm not repeating the thread. I search through the forum, but didn't find answer for how to use theese commands.