Getting HID Input report - WriteEP Vs GetReport?

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting HID Input report - WriteEP Vs GetReport?

221 Views
Contributor II

Hi,

We are using a small Python program as HID host that communicates with our LPC4357 based HID device.

Inside the EP Handler, after reading, we are sending an input buffer. Example code

{input_report as well as output_report is allocated in the USB ram area)

case USB_EVT_OUT::

USBD_API->hw->ReadEP(hUsb, pHidCtrl->epout_adr, output_report);

//do some processing

USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, input_report, 64);

 

 

Then in the GetReport Handler we have the following code

case HID_REPORT_INPUT:

*pBuffer = input_report;

 *plength = 64;

 

Now at the host end, we are receiving input report due to getreport not due to WriteEP in the EP handler.  For example, even if we comment the WriteEP, the fetching input at the host end works, not the other way around.  What is the use of WriteEP ?  Does it depend on the host command whether the host receives Input sent via WriteEP Vs GetReport? In other words, maybe we are not using the right command to receive what WriteEP has sent?

Thanks

0 Kudos
6 Replies

5 Views
Contributor II

Thanks Sol.

As we mentioned earlier, we are able to get Input report using the GetReport (at the device end we hit a break point inside GerReport and also we are modifying report value inside GerReport and able to see that at the host end.) At the host side, when we use output report to send data to the device, our EPHandler gets executed and our device is able to see the output report the Host sends.

In Our EP handler code  

case USB_EVT_OUT:

We have WriteEP call after reading and the host never receives that. Do we need to use any special command at the host side to receive through interrupt endpoint Vs control?

 

We never hit a break point at our case USB_EVT_IN: despite of calling WriteEP immediately after ReadEP.  Since host never acknowledges, it is fair to assume that host is not receiving that.

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;

            static unsigned int report_pending = 0;

        static uint8_t fail_count = 0;

       

 

            switch (event) {

            case USB_EVT_IN:

                        report_pending = 0;

                        break;

               

         

 

            case USB_EVT_OUT_NAK:

          

          USBD_API->hw->ReadReqEP(hUsb, pHidCtrl->epout_adr, output_report, 64);

          

                        break;

 

            case USB_EVT_OUT:

                        

             

                //bns - testing some communication logic between the host and this device

                 

                USBD_API->hw->ReadEP(hUsb, pHidCtrl->epout_adr, output_report);

                if (output_report[1] == 0xff)

                {

                  input_report[25] = 25;

                 

                }

                else

                input_report[25] = 55;

               

                        if (!report_pending) {

                                    report_pending = 1;

                                    

                         USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, input_report, 8);

                        }

                        break;

            }

            return LPC_OK;

}

0 Kudos

5 Views
NXP Employee
NXP Employee

Please check the following thread and let me know if this helps.

https://community.nxp.com/thread/457788

Regards 

Sol 

0 Kudos

5 Views
Contributor II

Any idea about this?

0 Kudos

5 Views
NXP Employee
NXP Employee

I only can add the USB stack it is based on the USB 2.0 protocol standard and the EP has the same information that any, so  I am little confuse about what you want to accomplish with the report of the EP or the reading  of the EP.

Have a nice day!

Sol

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

5 Views
Contributor II

OK First for all, does USB_EVT_IN event occurs every time the device sends

an input report to host irrespective of whether it has sent using control

or interrupt EP?

We are experiencing something strange. We are testing different report ID

format.

We have one simple report descriptor without any report ID or anything

which we took from the sample code and it looks like this.

const uint8_t HID_ReportDescriptor[] = {

HID_UsagePageVendor(0x00),

HID_Usage(0x01),

HID_Collection(HID_Application),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8), // 8 bits -- /bns 3/4 chaning

this to 10 from 8

HID_ReportCount(HID_INPUT_REPORT_BYTES),

HID_Usage(0x01),

HID_Input(HID_Data | HID_Variable | HID_Absolute),

HID_ReportCount(HID_OUTPUT_REPORT_BYTES),

HID_Usage(0x01),

HID_Output(HID_Data | HID_Variable | HID_Absolute),

HID_ReportCount(HID_FEATURE_REPORT_BYTES),

HID_Usage(0x01),

HID_Feature(HID_Data | HID_Variable | HID_Absolute),

HID_EndCollection,

};

When we use the above report descriptor, we do get USB_EVT_IN.

However, when we use the following report descriptor, the host receives

input report, however at the device end we never receive USB_EVT_IN.

const uint8_t HID_ReportDescriptor[] = {

HID_UsagePageVendor(0x45),

HID_Usage(0x00), //name of hhe usage for the entire

application

HID_Collection(HID_Application),

HID_Usage(0xA010), //name of the usage for the entire

input report

HID_ReportID(0x01),

HID_Collection(HID_Logical),

HID_Usage(0xA011),

HID_Usage(0xA012),

HID_Usage(0xA013),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(3),

HID_Input(HID_Variable),

HID_Usage(0xA014),

HID_Usage(0xA015),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xF),

HID_ReportSize(4),

HID_ReportCount(2),

HID_Input(HID_Variable),

HID_Usage(0xA016),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(60), //when input length is 8 there is no

EV_In so changing this from 4 to 60 total 64

HID_Input(HID_Variable),

HID_EndCollection, //end of input collection

HID_ReportID(0x02),

HID_ReportSize(8),

HID_ReportCount(HID_OUTPUT_REPORT_BYTES),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_Usage(0xA020),

HID_Output(HID_Variable),

HID_Usage(0xA0001), //name of the usage for the entire

feature report

HID_ReportID(0x03),

HID_Collection(HID_Logical),

HID_Usage(0xA0002),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(1),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_Usage(0xA0003),

HID_Usage(0xA0004),

HID_LogicalMin(0), // value range: 0 - 0xF

HID_LogicalMaxS(0xF),

HID_ReportSize(4),

HID_ReportCount(2),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_Usage(0xA0005),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(1),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_Usage(0xA0006),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(61),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_EndCollection, //end of feature

//testing another feature report with ID 4 format is the same

HID_Usage(0x30), //name of the usage for the entire

feature report

HID_ReportID(0x04),

HID_Collection(HID_Logical),

HID_Usage(0x32),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(1),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_Usage(0x33),

HID_Usage(0x34),

HID_LogicalMin(0), // value range: 0 - 0xF

HID_LogicalMaxS(0xF),

HID_ReportSize(4),

HID_ReportCount(2),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_Usage(0x35),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(1),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_Usage(0x36),

HID_LogicalMin(0), // value range: 0 - 0xFF

HID_LogicalMaxS(0xFF),

HID_ReportSize(8),

HID_ReportCount(5),

HID_Feature(HID_Variable| HID_Volatile), //device might change

HID_EndCollection, //end of feature

HID_EndCollection,

};

Any idea?

Thanks

0 Kudos

5 Views
NXP Employee
NXP Employee

Hi, 

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.

Please check the following threads and let me know if this helps,

USBD API: How to use WriteEP reliably? 

timing  

Have a nice day!

Sol

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos