2013-07-14 01:32 PM
Does the free ''STM32F105/7, STM32F2 and STM32F4 USB on-the-go Host and device library (UM1021)'' support reading data from a USB keyboard and USB mouse that are connected through a USB hub?
If not, does anybody know where I can get some free source code that does? #usb2013-07-16 07:35 AM
ST's host stack doesn't support hub yet.
I don't have hub code on ST's stack, 'cause I've written my original stack for our paid job ;) If you would like to write the hub code, I could help you. 1) Enumeration of a hub, which directly connects to STM32F host port. - This is the easiest part, existing stack code is applied almost as is. - Get hub descriptor, to know the number of ports. - Power up hub ports. - Poll hub's status (interrupt IN) endpoint, to detect hub port status change (connection / disconnection) 2) Device enumeration over a hub port - Hub's status EP reports change on one of hub port - Using Get_Port_Status(), firmware knows device connection at the port - after 100ms (or more) delay, - bus reset is put to the segment of the port using Set_Port_Feature (PORT_RESET) - Now that the device is connected to the main trunk of the bus. - Run enumeration sequence, as usual, as if the device would directly connects to the host - - Get_Descriptor(Device), Set_Address, Get_Descriptor(Config) and Set_Configuration I posted more detailed summary on this post. http://www.microchip.com/forums/fb.ashx?m=523499 Tsuneo2013-07-16 12:10 PM
Thanks for the tip Tsuneo
To implement those sequence of events you've outlined, should I be using ST's provided files and add to them? Or should I start from scratch? I've sort of already started to read through the reference manual and write out my own code. I've recently obtained a JLink and will obtain a hardware USB analyzer soon. This should make it easier.This is just a hobby project, but I'm debating between NXP and ST or maybe use AVR with MAX3421E. ST is the most difficult in terms of software but good in terms of hardware. I'm not sure if I should ''vote with my wallet'' and punish ST for not providing as much code.edit:I have begun to restructure the code, encapsulating some global variables into structs, and passing struct pointers into callback functions that need to know the originating device. The hardcoded device address has been replaced with something dynamic. I think I know what to do. From this point.2013-07-17 10:45 AM
> To implement those sequence of events you've outlined, should I be using ST's provided files and add to them?
Yes, with a little modification of a ST's host example, the first step, the enumeration of hub itself, should be done. But you have to write 300-400 lines of code to implement the rest.> This is just a hobby project, but I'm debating between NXP and ST or maybe use AVR with MAX3421E. Arduino USB Host Shield (AVR with MAX3421E) is the easiest option, because it has already supported hub. http://www.circuitsathome.com/arduino_usb_host_shield_projects Tsuneo2013-07-18 10:45 PM
I'm learning a lot while doing this coding.
The existing HID implementation doesn't support multiple interfaces. The deeper code for Get/Set Descriptor just assigns 0 to wIndex, I had to add more parameters to those functions so I can specify an interface numberI think I'll stick with ST since the dual OTG interface plus hub setup offers the lowest latency over all of my other options. A setup with multiple MAX3421E running on a slow AVR has the highest latency. out of all of my options2013-08-20 07:53 AM
Hi Tsuneo,
Thank you for your detail steps on the hub port setup.I met a problem after reset the port, in the STM32F2xx official usb stack, it uses USBH_GetDescriptor (pdev, phost, ..) to get the usb device descriptor. After the hub port reset, the new device plugged into hub port is put to default address 0. However, I cannot find any way to set the dev address back to 0, you know we need to set the device address to 1(or else) during the first round of enumeration. I also tried to create new host handlers, allocate new channel and tx/rx fifo for the new host, but after sending the ''GetDescriptor'' setup packet, there is no response.In the AVR with Max3421e source code, I notice it uses ''regWr (rPERADDR, addr);'' to set the peripheral address.So how do we do that in STM32 usb stack?