Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Implementing SET_REPORT/ GET_REPORT in USB full speed and low speed HID devices

lock attach
Attachments are accessible only for community members.

Implementing SET_REPORT/ GET_REPORT in USB full speed and low speed HID devices

Anonymous
Not applicable
Question: How to transfer data to and from device using SET_REPORT/GET_REPORT HID class-specific requests?

 

Answer:

 

Implementaion is as follows:

 

The RAM location for feature report data is USBFS_INTERFACE_0_FEATURE_RPT_DATA.

Transfers using feature report can be implemented by directly accessing this buffer.

 

This buffer is declared in the ‘USBFS_descr.asm’ file associated with the USBFS user module as follows:

 

_USBFS_INTERFACE_0_FEATURE_RPT_DATA:            

USBFS_INTERFACE_0_FEATURE_RPT_DATA:             

BLK  8                                         ;

 

Proceed by exporting this RAM buffer for use in your ‘main.c’ file. This can be done with the line of code:

 

externUSBFS_INTERFACE_0_FEATURE_RPT_DATA[4];

 

You can assign values to these locations as:

 

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[0]=0x1122;

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[1]=0x3344;

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[2]=0x5566;

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[3]=0x7788;

 

Each location is capable of handling a WORD sized data.

GET_REPORT request reads data from these locations to the HOST. Similarly, SET_REPORT request writes data from HOST to these locations.

 

The ‘main.c’ firmware is as follows:

 

#include<m8c.h>        // part specific constants and macros

#include"PSoCAPI.h"    // PSoC API definitions for all User Modules

 

externUSBFS_INTERFACE_0_FEATURE_RPT_DATA[4];

 

voidmain()

{

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[0]=0x1122;

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[1]=0x3344;

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[2]=0x5566;

      USBFS_INTERFACE_0_FEATURE_RPT_DATA[3]=0x7788;

 

      M8C_EnableGInt;

      USBFS_Start(0, USB_5V_OPERATION);

      while(!USBFS_bGetConfiguration());

      while(1)

      {

            //Application code

      }

     

}

 

The HID report descriptor used in the project is as follows:

 

Usage Page 06 FF FF

Usage 09 01

Collection (Application 01)

Report ID 85 01

Usage 09 02

Logical Minimum 15 00

Logical Maximum 25 FF

Report Size 75 08

Report Count 95 08

Input (Data, Variable, Absolute 02)

Usage 09 03

Report ID 85 02

Report Count 95 01

Logical Maximum 25 10

Feature (Data, Variable, Absolute 02)

End Collection C0

 

Note that irrespective of the report descriptor configuration, all HID class devices are supposed to respond to the HID class requests like SET_REPORT and GET_REPORT.

 

To test this firmware, please follow the instructions given in the attached word document

Attachments
0 Likes
2240 Views
Contributors