Electronics > Microcontrollers

Which USB class?

(1/3) > >>

AlfBaz:
I want to program my stm32f4 discovery board as USB device.
From the host (pc) I want to be able to either send it data or request it to send data.

Looking through the library code provided by STM I see they have various classes available, audio, cdc (Communications Device Class), dfu (Device Firmware Upgrade), hid (Human Interface Device) and msc (Mass Storage Class).

Having a very brief read through the descriptions for each of these classes it would look like cdc may be the class I'm after as wiki recons this class provides an easy path to USB-232

Any thoughts or suggestions?
(I know precious little about USB)

mrflibble:
USB CDC should do the trick if you want a virtual com port on the PC side.

AlfBaz:
Thanks for that. If I were to try some simple 2 way data transfer where the device does nothing unless instructed, would I have to create a driver for the PC... Something along the line of what companies like MicroChip offer with their stack?

JTR:
Not with CDC, you just need to use the inf file provided by microchip with windows. Nothing required for Mac or gnu/Linux.

If you bandwidth requirements are < 64KB/s and you are writing PC side code you would be far better off using hid. CDC is easy but there are a stack of issues with the windows driver. I am not going to even try to list them all but the biggie is the that CDC is PRONE to silently dropping the data IN endpoint and the only way to recover this is to close the port (PC) and reboot the USB firmware  on the micro.

Another option is to use generic bulk. This requires a USB library like WinUSB or libusb or the one provided by microchip (mchpfsusb.dll?) etc to provide the API but it is not as involved as writing a kernel level driver as such.

Generic bulk provides way more bandwidth than HID and somewhat better bandwidth than CDC (and uses the USB bandwidth in a far more social way too.)

AlfBaz:

--- Quote from: JTR on December 18, 2013, 08:35:31 am ---Not with CDC, you just need to use the inf file provided by microchip with windows. Nothing required for Mac or gnu/Linux.
--- End quote ---
Yeah sorry. In my previous post, it should have read "...simple 2 way data transfer without cdc"


--- Quote ---If you bandwidth requirements are < 64KB/s and you are writing PC side code you would be far better off using hid. CDC is easy but there are a stack of issues with the windows driver. I am not going to even try to list them all but the biggie is the that CDC is PRONE to silently dropping the data IN endpoint and the only way to recover this is to close the port (PC) and reboot the USB firmware  on the micro.
--- End quote ---
You'll have to excuse my brain I've been into very wide and varied stuff lately, but these issues with windows, are they pre windows vista? If not then the above is no good for me

--- Quote ---Another option is to use generic bulk. This requires a USB library like WinUSB or libusb or the one provided by microchip (mchpfsusb.dll?) etc to provide the API but it is not as involved as writing a kernel level driver as such.

Generic bulk provides way more bandwidth than HID and somewhat better bandwidth than CDC (and uses the USB bandwidth in a far more social way too.)

--- End quote ---
This rings a bell. In fact your mention of Win/lib/mchpfs-usb helped jog my memory. I remember having a detailed look at these a long time ago but never implementing them.
I might start with cdc just to have it for future use and then move right onto generic bulk

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod