cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 USB Library for WinUSB

Stephen28
Associate III
Posted on April 10, 2012 at 04:57

Does anyone have a demo /  tutorial on how to setup the STM32 USB Library to work with the WinUSB driver.  Jan Axelson's ''USB Complete Fourth Edition'' describes how to setup the descriptor, and how to setup the INF file for Windows, but I am not sure what pieces of the USB Library that I need or how to set them up.

#winusb #stm32 #usb
12 REPLIES 12
flyer31
Senior
Posted on April 11, 2012 at 08:07

You really mean this sincerely? Did you ever program anything for USB based from the scratch - I think if you do so, you must be very old already (... a participant of the USB definition spec group perhaps?...) and full of grey hairs ... :).

It would really be VERY helpful, if ST could present a WinUSB demo, e. g. with a minimized Visual C++ application to test the maximum bulk transfer speed in read AND write mode.

Stephen28
Associate III
Posted on April 12, 2012 at 14:36

Well, I guess the answer to my question is that nobody has done this.

I was hoping to be lazy and not ''re-invent the wheel''.  
tomasz2399
Associate II
Posted on April 17, 2012 at 09:03

Use CDC example as a template. There are two BULK endpoints. For better transfer speed CDC example would require small modifications.

1) Change VCOMPORT_IN_FRAME_INTERVAL to lower value. I'm not sure is value = 1 is suitable when transfer needs to be bidirectional, so I've used value = 2. It won't make much difference though.

2) Increase USART_RX_DATA_SIZE. I've used 8192 bytes (2 x 4 kB), but I think that there would be no speed difference with values above 4096 B (maximum number of data would be transmitted in every or almost every frame).

3) Modify Handle_USBAsynchXfer so it wouldn't transmit data unless half of the USART_Rx_Buffer would be full. Thus after each SOF maximum number of bytes would be sent. If there is a change that buffer would be filled with low speed or not filled at all for some time then some kind of timeout would be needed here that would cause transmitting whatever is in buffer already - you may know this problem if you've used USB to UART converters before.

 On a PC side make sure that application is constantly ready to accept new data. I've used libusb, so I've used combination of usb_submit_async/usb_reap_async to enqueue multiple read requests. I guess with WinUSB that could be made with overlapped I/O.

I wasn't interested in high PC to device speed, so I haven't any tips on reverse direction.

If you are using STM32F103C8T6 or similar, then

http://tomeko.net/miniscope_v2c/

source code (CoIDE+gcc) might be helpful. Otherwise better start with clean CDC example - I've removed some code not related to this specific MCU from source code to make it easier to understand.
flyer31
Senior
Posted on April 18, 2012 at 12:50

Did you check the maximum data rate for direction device to PC?

(I assume you checked only full speed - or did you also test high speed with STM32F4?)

tomasz2399
Associate II
Posted on April 18, 2012 at 13:29

For a moment I've tested 857 kB/s stream and it seemed stable. I've reverted back to 600 kB/s as higher sampling would require lowering S/H time to 1.5 cycle and I didn't put proper input buffer at ADC so 7.5 cycles were safer for me (ADCCLK = 72 MHz/6).

I don't have STM32F4 (AFAIK separate high speed PHY would be required also), so I've tested only full speed with STM32F103C8T6.

zomirp2
Associate II
Posted on April 25, 2012 at 09:28

There is something going on here:

http://searchingforbit.blogspot.com/2012/04/winusb-communication-with-stm32-part-1.html

flyer31
Senior
Posted on April 27, 2012 at 09:50

Thank you for this link, looks interesting - but there I find only some very rudimentary / introductory information - no source code or so (also not if I follow the link to the Google code project site). Could you look into the source code?

zomirp2
Associate II
Posted on April 28, 2012 at 20:52

Last post is now only 4 days old.

I think that 3 files at 

https://code.google.com/p/found-bits/source/browse/trunk/Sources/Projects/Libs/WinUSBComm/

are what should be the library.

There is nothing else besides the WinUSBCommSTM32Demo under projects. I guess it uses the library. I haven't checked it. It is an Eclipse project which I don't use.

Also I didn't find the VS sources as depicted in first post.

dkattan
Associate
Posted on July 18, 2012 at 08:59

Hey guys,

I think this is the answer you're looking for. In this post I attached modified versions of the latest STM32 USB Firmware libraries in such a way that the HID project autobinds the WinUSB driver automatically when you plug it into Windows Vista/7/8.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=23332