cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID on STM32 CL and MD

mpachock
Associate
Posted on July 15, 2011 at 15:31

Hello,

I'm stucked at programming a USB. Based on ST USB Library and sample project (Custom HID) i've created an program that send to PC data in report of size 10 bytes. So i changed an description of usb (in usb_desc.c) lines (101, 112 and 226 line) commented as:

/*     REPORT_SIZE             */ and /* wMaxPacketSize*/

On STM Eval B it's works fine. I have bigger packet size, but when i recompile code and run it on STM Eval C with STM32F107 my packet are still 2 bytes length as in example.

Could anyone can help me? Maybe provide USB HID code for a CL processors?

best regards

Micha?

#usb-stm32cl-hid
3 REPLIES 3
ColdWeather
Senior
Posted on July 18, 2011 at 11:36

Take care of many conditional defines regarding CL line in the application part of the USB library. I suppose, you have changed the defines that are in effect for MD line only. My suggestion is, place #warning ''your text'' in the #ifdef...#else..#endif sections to monitor, what section is being compiled.

tsuneo
Senior
Posted on July 18, 2011 at 21:56

> with STM32F107 my packet are still 2 bytes length as in example.

Did you replace these ''2''s into 10 (or 11, including report ID) at the last argument of OTG_DEV_EP_Init()?

The last argument tells wMaxPacketSize of the EP to the USB engine.

usb_prop.c

void CustomHID_Reset(void)

{

  /* Set Joystick_DEVICE as not configured */

  pInformation->Current_Configuration = 0;

  pInformation->Current_Interface = 0;/*the default Interface*/

 

  /* Current Feature initialization */

  pInformation->Current_Feature = CustomHID_ConfigDescriptor[7];

 

#ifdef STM32F10X_CL  

  /* EP0 is already configured in DFU_Init() by USB_SIL_Init() function */

 

  /* Init EP1 IN as Interrupt endpoint */

  OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_INT, 2);   //<------

 

  /* Init EP1 OUT as Interrupt endpoint */

  OTG_DEV_EP_Init(EP1_OUT, OTG_DEV_EP_TYPE_INT, 2);   //<------

#else

  ...

Tsuneo

mpachock
Associate
Posted on July 19, 2011 at 17:53

Yes, that works. Thanks.