cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX USB control request

Ted NIVAN
Associate II
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)
1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

4 REPLIES 4
John Lee_O
Associate II
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.

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.
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
Posted on September 19, 2017 at 00:43

Yes I've finally found out. I should have told you.

What you wrote is exactly what I've done and it worked like a charm.

Thanks for your help though!