LPC1347 HID_SetReport and HID_GetReport functions NOT called

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1347 HID_SetReport and HID_GetReport functions NOT called

991 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bonitusb on Fri Jun 27 03:51:48 MST 2014
Hello everyone,

has anyone had success with the Lpc1347 USB_HID_Generic using IAR Embedded workbench?
I used Visual Basic to create my interface panel and it is working very fine with Lpc1343.

i am using this example bundle, "lpcopen_2_05_keil_iar_nxp_lpcxpresso_1347"
With LPC1347, i can connect the device to the host but the problem is that no information is exchanged between them. I also discovered that the two functions responsible for information exchange are not being called, i.e HID_SetReport and HID_GetReport.

Has anyone an idea?
Thanks
Labels (1)
0 Kudos
5 Replies

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bonitusb on Thu Jul 10 15:22:27 MST 2014
Hello Tsuneo,

I have made some little progress. On the PC side[color=#f03]Send/Read reports using a control transfer[/color] were disabled.

For the previous PC program that was working fine with 1343,
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
  was used in reading a report by interrupt. Important was the call of GetInputReportData() for reading the input data. If i place this sequence within the control Transfer Read Request,
If (chkUseControlTransfersOnly.Checked = True) Then
' Read a report using a control transfer.                        
success = MyHid.GetInputReportViaControlTransfer(hidHandle, inputReportBuffer)
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
the PC program hangs. At such, i cannot read a report and if i remove it, only the send report is implemented. Does BeginRead works with interrupt transfers only?

Secondly, the behavior of the PC application is as described above, only if on the firmware, the PCInReportData was sent at buffer 0
*pBuffer[0] = PCInReportData
. Other than this, any PCInReportData sent at other buffers hangs the PC application.
For example
*pBuffer[1] = adcValue
. To this regard, i changed this part of uC codes  but the problems were not solved.
USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, loopback_report, [color=#f03]3[/color]); 
*plength = [color=#f03]3[/color]; (static ErrorCode_t HID_GetReport())
USB_HID_REPORT_T reports_data[[color=#f03]3[/color]]; (ErrorCode_t usb_hid_init())
#define HID_INPUT_REPORT_BYTES      [color=#f03] 3[/color] (hid_desc.h)
I want to write InputReportof 3bytes, what must be changed?

Thanks for your reply
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Sat Jul 05 12:06:14 MST 2014
The OP has put a related question to Jan Axelson's USB forum
http://janaxelson.com/forum/index.php?topic=1367.0

Answered to his new question in above link.

Tsuneo
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Thu Jul 03 13:12:01 MST 2014

Quote:
My problem is that both HID_SetReport() and HID_GetReport() do not respond to the host Set/GetReport request, at such the instructions within case HID_REPORT_OUTPUT: and case HID_REPORT_INPUT: are not executed.


I tested usbd_rom_hid_generic example in this LPCOpen library on my LPCXpresso LPC1347 board.
http://www.lpcware.com/system/files/lpcopen_2_05_keil_iar_nxp_lpcxpresso_1347.zip

As I don’t have recent IAR setup, I ran the example on Keil MDK-ARM v4.74
The source files are common either for IAR or Keil.

On my side, HID_GetReport( HID_REPORT_INPUT ) and HID_SetReport( HID_REPORT_OUTPUT ) are correctly hit at breakpoints on the debugger, when a host app sends Get_/Set_Report requests.

I tested it using SimpleHIDWrite on Windows. Try this test bench, instead.
http://janaxelson.com/files/SimpleHIDWrite3.zip
- At launch, SimpleHIDWrite lists up HID devices attached to the PC, on the upper side of its dialog.
Click on "LPC11Ux HID (Serial=ABCD123456789)"
To send Get_Report request, click on "Get Report" button at the bottom.
To send Set_Report request,
- type in 0 at ReportID, any hex number at the next text box, and then click on "Set Report" button


In this part of your above code,
/* HID Interrupt endpoint event handler. */
static ErrorCode_t HID_Ep_Hdlr(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{
USB_HID_CTRL_T *pHidCtrl = (USB_HID_CTRL_T *) data;
         
switch (event) {
case USB_EVT_IN:
/* last report is successfully sent. Do something... */
                /* loopback the report received. */
USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, loopback_report, 3);                
break;

HID_Ep_Hdlr( USB_EVT_IN ) is called just after the input report is sent over the interrupt EP. You have to call USBD_API->hw->WriteEP() at outside of this "case USB_EVT_IN", somewhere appropriate when the input report is available.

Tsuneo
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bonitusb on Wed Jul 02 03:10:13 MST 2014
/* HID Interrupt endpoint event handler. */
static ErrorCode_t HID_Ep_Hdlr(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{
USB_HID_CTRL_T *pHidCtrl = (USB_HID_CTRL_T *) data;
         
switch (event) {
case USB_EVT_IN:
/* last report is successfully sent. Do something... */
                /* loopback the report received. */
USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, loopback_report, 3);                
break;

case USB_EVT_OUT:
/* Read the new report received. */
USBD_API->hw->ReadEP(hUsb, pHidCtrl->epout_adr, loopback_report);               
break;
}
return LPC_OK;
}



/* HID set report callback function. */
static ErrorCode_t HID_SetReport(USBD_HANDLE_T hHid, USB_SETUP_PACKET *pSetup, uint8_t **pBuffer, uint16_t length)
{ 
    uint8_t PCOutReportData = *pBuffer[0];
  
/* we will reuse standard EP0Buf */
if (length == 0) {         
return LPC_OK;
}

/* ReportID = SetupPacket.wValue.WB.L; */
switch (pSetup->wValue.WB.H) {
case HID_REPORT_INPUT:
return ERR_USBD_STALL;/* Not Supported */
                
case HID_REPORT_OUTPUT:
*loopback_report = **pBuffer;
                                                             //bonitusb
                PCOutReportData = *pBuffer[0];
                
                if(PCOutReportData & 0x01)
                  GPIO_PIN0_bit.P0_2 = 1;                    
                else
                  GPIO_PIN0_bit.P0_2 = 0;             
break;

case HID_REPORT_FEATURE:
return ERR_USBD_STALL;/* Not Supported */
} 
return LPC_OK;
}


Thank you so much for your reply.

If i am correct, the USBD_API->hw->WriteEP() and USBD_API->hw->ReadEP() reads and write to the Endpoints buffer to be used by the HID_SetReport() and HID_GetReport() at [color=#f03]uint8_t **pBuffer[/color] .

From the HID_SetReport() function above for example, i want to light and LED on my LPC board when the host sends a Set request. I have confirmed every other functions and interrupt routines to be responding, the host sends request as well.

My problem is that both HID_SetReport() and HID_GetReport() do not respond to the host Set/GetReport request, at such the instructions within [color=#f00]case HID_REPORT_OUTPUT: and case HID_REPORT_INPUT:[/color] are not executed.

I humbly still need your help.
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Tue Jul 01 09:37:55 MST 2014

Quote:
I also discovered that the two functions responsible for information exchange are not being called, i.e HID_SetReport and HID_GetReport.


HID_SetReport() and HID_GetReport() are called just when your host sends Set/GetReport request over the control transfer. These routines are not called by the interrupt OUT/IN endpoint events.

When the interrupt OUT EP receives an output report, HID_Ep_Hdlr() callback is called with USB_EVT_OUT "event" parameter. Your code reads out the report using USBD_API->hw->ReadEP(), as the HID_Ep_Hdlr( USB_EVT_OUT ) does on usbd_rom_hid_generic example, hid_generic.c

You may send an input report over the interrupt IN EP, using USBD_API->hw->WriteEP(), as the above routine does.

Tsuneo
0 Kudos