Skip to main content
Ted NIVAN
Associate II
September 11, 2017
Solved

STM32CubeMX USB control request

  • September 11, 2017
  • 1 reply
  • 1523 views
Posted on September 11, 2017 at 21:16

Hi there,

I am using STM32CubeMX to develop a USB HID touchscreen with the STM32F103C8T6 MCU.

In the HID descriptor, I must report the following feature to support multi-touch:

 0x85, REPORTID_MAX_COUNT, // REPORT_ID (Feature)
 0x09, 0x05, // USAGE(Contact Count Maximum)
 0x95, 0x01, // REPORT_COUNT (1)
 0x25, 0x02, // LOGICAL_MAXIMUM (2)
 0xb1, 0x02, // FEATURE (Data,Var,Abs)

Which function should I use to do a USB control request as feature request?

#stm32-hid-usb #usb-hid-getfeature-setfeature #stm32f103c8t6 #usb-hid #stm32cubemx(hal)
This topic has been closed for replies.
Best answer by John Lee_O
Posted on September 13, 2017 at 05:08

Ah, I misunderstood your question. 

I think if the 'Feture report' were sent via contol pipe as described in HID1_11 document, following function would be used.

  - USBD_CtlSendData (USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)

And it need to be added as class specific request in USBD_CUSTOM_HID_Setup() function like below.

I hope this works for you .

0690X00000608CFQAY.png

1 reply

John Lee_O
Visitor II
September 12, 2017
Posted on September 12, 2017 at 09:12

Hello,

You can generate a CustomHID project from CubeMX and modify the existing report descriptor(CUSTOM_HID_ReportDesc_FS[]) in 'usbd_custom_hid_if.c'. Than the report descriptor will be transmitted during the enumeration process automatically.

Ted NIVAN
Ted NIVANAuthor
Associate II
September 12, 2017
Posted on September 12, 2017 at 12:18

Thanks for replying John.

I am able to create a report descriptor and transmit it but the point is that I don't know how to send feature report over usb (which function to use).

For this part of the descriptor:

 0x85, REPORTID_MAX_COUNT, // REPORT_ID (Feature)
 0x09, 0x05, // USAGE(Contact Count Maximum)
 0x95, 0x01, // REPORT_COUNT (1)
 0x25, 0x02, // LOGICAL_MAXIMUM (2)
 0xb1, 0x02, // FEATURE (Data,Var,Abs)

I must transmit the following structure:

static

const

uint8_t

hid_feature_report[] = {

0x02

,

//

report id

0x05

//

number of contact points

};

My question is: Which function should I use to respond to GET_REPORT(feature) requests?

In the HID1_pdf documentation, it is written that:

Only Input reports are sent via the Interrupt In pipe. Feature and

Output reports must be initiated by the host via the Control pipe or an optional Interrupt Out pipe.
John Lee_O
Visitor II
September 13, 2017
Posted on September 13, 2017 at 05:08

Ah, I misunderstood your question. 

I think if the 'Feture report' were sent via contol pipe as described in HID1_11 document, following function would be used.

  - USBD_CtlSendData (USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)

And it need to be added as class specific request in USBD_CUSTOM_HID_Setup() function like below.

I hope this works for you .

0690X00000608CFQAY.png