cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host With Multiple Vendor Specific Devices

jwormsley
Associate III
Posted on August 28, 2014 at 22:23

I'm new to USB programming, and am having some trouble getting my head around the concepts involved.  Hopefully someone can have a look at what I think I need to do to meet my goals and tell me where I'm right and where I'm horribly wrong.

First, my goal is to replace an STM32F103 series CPU on a board that uses all five serial ports available on the CPU, plus four more implemented via a quad UART via the FSMC, with an STM32F417 series CPU.  In the process, I want to be able to connect to some of those serial devices via USB instead, as USB versions of them exist (some are also dual interface), eliminating the need for the quad UART.  These devices include a pinpad, receipt printer, and cellular modem.  I'd also like to be able to insert a USB flash drive to perform software updates.

To do this, I know I'll have to add a USB hub chip to my board, but this doesn't seem to hard from a hardware standpoint.  Where things look difficult is with the software to handle all of this.  It's not simple like RS-232 serial ports.

Here's what I've managed to learn by going through the various demo code available via the STM32Cube package for the F4.

1. For devices that can be controlled via a class driver, I can use USBH_RegisterClass to allow the USB stack to recognize that class.  This should be sufficient for the flash drive by using the MSC class from the examples.

2. Most of my devices are VENDOR SPECIFIC, and so I will have to write a new class driver for this, that will in turn have to handle the individual devices based on their VID/PID values.  Hopefully I can use the HID example that determines whether a mouse or keyboard is attached as an example of figuring out which devices I have attached.  I do not know how to handle this via the VID/PID however, because the HID example uses subclass to determine mouse vs keyboard, and my subclasses are the same on the vendor specific devices.

3. USBH_Process will handle the high level USB functions such as enumeration, and pass any lower level things to the class driver(s).

4. USBH_BulkSendData and USBH_BulkReceiveData will be used to send and receive data from my devices.  These work by setting flags in the state machine for the device handle, which the state machine then processes.

Obviously I'm missing quite a lot here.  I'm trying to work on modifying one of the examples (CDC in this case, as it is similar to the cellular modem in terms of function) to handle the Vendor Specific class that my device uses.  I can get it as far as recognizing that this is a vendor specific class, but crash trying to execute the state machine in the HOST_CLASS_REQUEST state.

I've done a lot of searching, and I haven't really found much useful about interfacing to a vendor specific class device, and nothing about integrating a hub and supporting more than one of them.

Any pointers would be greatly appreciated.

Thanks,

  Jeff
24 REPLIES 24
christo
Associate III

Hi Moh

You can take a look on the following treads:

https://community.st.com/s/question/0D50X00009XkiCLSAZ/stm32f4-and-usb-fshs-with-ulpi

https://community.st.com/s/question/0D50X00009XkiCKSAZ/cp210x-usb-host-class-driver

At the end of the discussions you will find attached files with a code.

Unfortunately, I am not working on this projects but plan to put them on GitHub soon.

It will be good to notify me back if you find some of them helpful.

Success

Chris

Hi Moh

You can take a look on the following treads:

https://community.st.com/s/question/0D50X00009XkiCLSAZ/stm32f4-and-usb-fshs-with-ulpi

https://community.st.com/s/question/0D50X00009XkiCKSAZ/cp210x-usb-host-class-driver

At the end of the discussions you will find attached files with a code.

Unfortunately, I am not working on this projects but plan to put them on GitHub soon.

It will be good to notify me back if you find some of them helpful.

Success

Chris

christo
Associate III

Hi Moh

Find the code for the application described above. Take in account that this is one incomplete demo.

Success

Chris

Hi Moh,

Find the code for the application described above. Take in account that this is one incomplete demo.

Success

Chris

Hi @MMoha.2​ ,

I am also working to communicate with the CP102x device. Did you fix this error? Any solution for successful communication?

Thanks,

Param.