Changes

Jump to: navigation, search

FPGAmstrad

3 bytes added, 12:10, 28 February 2012
/* USB joystick */
==== Sniffing USB frames ====
USB use two wires in order to transmit frames, green and white, each with two logical values : 0v and 5v.
 
Let's plug a joystick on PC, if you listen at its two wires, you can snif a USB transmission. Saving it for example on RAM.
 
Theses two wires can be traduce into one with four states : 00 01 10 11.
 
One of this state is sleep state, in fact it depends on USB mode you use.
===== USB mode : USB1 or USB2 ; low speed, full speed or high speed =====
===== pull up and pull down =====
If you respect USB protocol, you have to plug some pull-up and pull-down resistors and some capacitor. But as I am a bad electrician, I just simulate then in VHDL, they are important because they cause USB speed negotiations. You also have an electronic mechanism in order to detect presence of joystick plug, I don't care about it.
 
==== Synchronize, decode and check USB frames ====
One time sample is done, it is not readable. In fact USB frames are synchronized (they started with a certain synchronization pattern), encoded (NRZI), and checked (CRC). CRC type depends on frame length. Encoding is done for synchronization optimization.
 
Then using USB HID manual, you can understand type of frames, and author of them, and remark that the author alternate : USB master (PC) or USB slave (joystick)
==== Build a minimum USB master frames state-machine ====
1,200
edits