STM32 F407 Discovery Joystick Thrustmaster T-Flight Hotas X - usb

I am trying to use the Thrustmaster T-Flight Hotas X joystick with my STM32 f407 Discovery board. As you know, the joystick has a USB connection, but actually I do not know how it transmits data and I do not know what kind of protocol it uses...do you have any advice?
Is there a way to connect the joystick to the board?

Yes, you can use the USB OTG port in host mode to connect your joystick.
The joystick will use USB HID protocol - this is documented in detail at usb.org. Short version: The device tells you in its "report descriptor" how the data is formatted. The data itself is transmitted via interrupt endpoint.
Unfortunately, the software side is non-trivial, as you need host mode on the MCU. Parsing the report descriptor is not required if you only ever use the same joystick model - which can be identified using the VID:PID in the device descriptor.
There should be an appnote with some example code for USB host mode on the STM website, but in order to support your joystick you probably have to make some modifications - which are rather difficult for beginners.

Related

STM32G4 USB Link Power Management

I want to use the USB 2.0 Port on an STM32G431CB as Virtual Com Port (VCP). The Device is self powered, so I need to enable the USB Link Power Management, to detect when the USB Cable is plugged in. The STM32G431 has no dedicated VBUS Pin, so according to this document [1] any 5 Volt tolerant pin with EXTI capabilities should be able to fullfill that role.
So far so good, but how do I reset the USB statemachine, when I detect, that the USB Power has been connected / the USB cable has been plugged in? I looked through several documents, but I could not find any hint, how I caould reset the USB Statemachine, when this Interrupt occurs. Is there any HAL function or something similar?
But it's even more confusing, that I can enable the Link Power Management in CubeMX, but there are no further parameters, like which Pin I'd like to use, or callback functions, etc. It's just an "enabled" or "disabled" - even the tooltip / online help is empty.
can anyone point me in the right direction?
[1] Link: https://community.st.com/s/article/FAQ-Management-of-VBUS-sensing-for-USB-device-design

STM32 HAL USB CDC Control Data Decoding / Open Port Detection

I get lost trying to figure out how to parse control data in CDC_Control_FS() function. Can you point me any documentation about that?
Background:
I am using stm32f103, trying to implement USB CDC communication with HAL libraries. I need to detect if usb port is opened by PC, it should handle power on scenario as well as cable reconnetion during runtime. After some research I think that checking DTR signal may be the (most elegant) solution. I know there is CDC_Control_FS() function that delivers all line configuration to stm32f103 from PC driver, but unfortunately I don't know data format / how to extract DTR signal, to be able to set some flag for indicating that usb port is currently open or closed.

USB host/peripheral design

I'm looking to create a device that acts as a host to a USB peripheral, format the data, then send it out to another host (the PC). Are on-the-go chips capable of accomplishing this or would you need to implement both a host USB microcontroller and a peripheral USB controller? I don't see much information out there for creating a middleman that performs data molding for USB prior to reaching a host. Any information would be appreciated, hopefully I didn't butcher this concept.
you should use a microcontroller with 2 USB busses.
One should act as a host, and the other as a slave.
You will need to implement them both.
USB OTG is used to create a host and a slave in 1 device with 1 connector,
so it's impossible to use them together at the same time.

USB port to detect "close" or "open" switch

I need to make a program that would play a sound as I press a push button switch. My idea is to use the USB port, and that if I short 2 wires from it (like for example the data+ and data-), the program would play a sound repeatedly while the 2 wires are shorted. Is my idea possible and simple to do? Can you please help me do it using VB? Thanks a lot for any help.
No, that is not practical. USB ports do not have that feature is far as I know. There are plenty of small, cheap USB microcontroller boards that are up to the task though.
For example, you could get an A-Star 32U4 Micro, program it using the Arduino IDE, and make it send a certain message on the its virtual COM port (which is accessed from the Serial object) when a button is pressed and another message when it is released. Then in Visual Basc, you would use the SerialPort class to connect to the A-Star's COM port and listen for that message.
USB ports are mainly used for transmitter and receiver communications for data transfers. They are not used for open or closed switch detection. In order to use a USB port for switch detection, you can used a serial to USB conversion breakout board with a specialized IC chip designed to detect an open or closed switch and communicate this via the USB protocols to send out a communications data transmission that a switch has just been open or closed. Then you would program an application in any language to listen on that USB port for this specific data transmission for a closed or open thrown switch. You can potentially detect about 4 switches opened or closed simultaneously if you want. And this serial to USB breakout board can easily be purchased online at:
https://www.sparkfun.com/products/199

External USB device interface with Xilinx Atlys board

I'm trying to interface the Mindwave (http://store.neurosky.com/products/mindwave-1) with my Altys board, through the USB UART port. The dongle I'm trying to connect is basically a wireless reciever that outputs serial data stream on the USB connection. I'm trying to read in this serial stream on the FPGA.
The problem I'm seeing is that when I try to Chipscope the UartRx pin (A16), I see no activity on it even though the dongle is supposed to send 0xAA in standby mode.
Since the FPGA does not power the dongle, I have it connected to an external power USB hub and then connect the hub to the FPGA. However I don't see any activity.
Do I need to convert the signals to another level, or invert them? I thought the EXAR chip takes care of it.
Did you try swapping RX and TX?
Did you have acces to a scope? To check you can repeatly send 'U's (0x55) and look with a scope to see which line is RX and which is TX. You can also check the speed of the interface with this method.