Initially, as I mentioned, I am porting the nand2mario library, which covers USB mice, keyboards, and controllers. This will give us a lot of play in all respects.
I started here because I am studying the USB protocol and it seemed like a good first exercise to face this protocol, which is quite complex.
The good thing is that with icestudio, we will only have to drag a block and connect four cables to be able to use USB, so anyone who simply wants to have a keyboard, mouse, or controller can do it very easily.
This module is very simple, it only covers a minimal part of the HID protocol (it is the part of the USB protocol that allows you to connect human interfaces such as mice or keyboards) and in host mode, which means that when we advance initially we will need "pure" devices.
This means that, for example, a keyboard that has a USB input will not work, or a keyboard with a touch mouse and keyboard will not work either.
This is due to the fact that these compound devices operate in hub mode, they expose a USB hub to the outside and have their hosts facing inward.
I would like to improve this later and contribute it to the nan2mario project, but for now, having these initial blocks in icestudio will already be a great advance.
To start, we will test the mouse, I will pass you a test project, as you can see it is a zip, because I incorporate directly the nand2mario project (the two Verilog files and the ROM) you need to have everything in the same directory.
This project is serving me to test a new functionality that I will release soon to work more comfortably with external Verilog files, this is another battle but it is a very interesting feature, I work a lot with Verilog and I use icestudio as a "top layer" or in a way, an abstraction layer that allows me to see much more easily the complete designs or navigate between their modules and blocks, in addition to simplifying portability between boards, but as I say this we will talk about it later.
To connect the USB, depending on the board you are using, you need to incorporate a USB PMOD that you buy if the board supports PMODs or if you do not want to use a PMOD or the board does not support it, you can easily assemble the USB connector, as I did in the example with the Alhambra II.
The USB protocol is very interesting, a USB HID 1.1 connector like in this case (low speed) uses 4 pins, one GND, another VCC (5V), and then two differential lines (D+ and D-) to transmit the data.
According to the voltage between D+ and D- and its impedance, the interconnected elements define whether they are host, hub, etc.
In our case, since we will be host, the assembly of the female connector is the one I attach in the next pictures.
You need to connect GND to the GND of the board, VCC to 5V, and D+ and D- to the data pins with which we will transmit (in the example of the Alhambra II D0 and D1).
To indicate that it is a host, what we have to do is make a pulldown with a 15k resistor (connect the pin to GND through a 15K resistor) of the D+ and D- lines.
The previous image is from this blog https://blog.tkjelectronics.dk/2011/03/fez-panda-and-usb-host/ in which they connect a USB to a microcontroller. I have placed it to clarify the wiring.
Here I attach an image of the breadboard that I have assembled for testing. I have desoldered a USB connector from an old modem, but you can also cut a female USB cable and in a breadboard put the resistors and from there to the Alhambra.
In the example I send you, you can connect a USB mouse. Once loaded, with the sw1 button on the Alhambra II, you start the circuit.
Open the serial terminal at 115200bps and when you move the mouse and press the three buttons, if you activate the hexadecimal mode, you will see the data that arrives.
If you use another card, it is important that you use a PLL so that the circuit clock goes to 12Mhz which is what the USB communication needs to work. I will already do an example with a colorlight or another board at a faster speed and use multiple clocks but for those who want to try it now it is as simple as switching to the system clock to 12Mhz
As soon as I finish preparing the block to support keyboard and mouse, I will prepare some more interesting demos. For the moment, if you want to accompany me in the development of these blocks and help me test them on other boards, it would be fantastic, I think we will all learn a lot.
If you have any questions or comments, they will be welcome! I will try to explain in detail all the steps and the content of the circuit, but for the impatient I leave you the test here.
One important thing is that you need to use the last wip (download from https://downloads.icestudio.io) because you need an icestudio version that supports inout pins, and install from toolchain install menu, the apio development version (0.9.0).
I hope it is useful!
--
Has recibido este mensaje porque estás suscrito al grupo "FPGAwars: explorando el lado libre" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a fpga-wars-explorando-el...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/4216b1fe-ad6f-4dcc-a5b2-653d76f2e6d3n%40googlegroups.com.
Este finde lo pruebo y te cuento!
--
Has recibido este mensaje porque estás suscrito al grupo "FPGAwars: explorando el lado libre" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a fpga-wars-explorando-el...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/27af2c8b-5ab0-4dae-90dd-1916a3203acfn%40googlegroups.com.
Hace mucho tiempo compré 10 USB hembras, el que puse en las fotos fue el primero que estrené.
--
Has recibido este mensaje porque estás suscrito al grupo "FPGAwars: explorando el lado libre" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a fpga-wars-explorando-el...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/b6408a32-7c18-4ad0-96ef-68a73310ea65n%40googlegroups.com.
--
Has recibido este mensaje porque estás suscrito al grupo "FPGAwars: explorando el lado libre" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a fpga-wars-explorando-el...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/f0f4a86a-0b70-4937-8dd5-d7e7ec7862fen%40googlegroups.com.
--
Has recibido este mensaje porque estás suscrito al grupo "FPGAwars: explorando el lado libre" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a fpga-wars-explorando-el...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/6db321c0-1344-4ab3-941c-32e200d1dda6n%40googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/3284cf6d-f529-4d3e-ac6e-db4c50946b34n%40googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/fb357fad-9a53-43bd-ae74-8e79bb501703n%40googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/3e0b54c4-fff6-4177-a7b2-b564e5102dben%40googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/bac27429-f9a6-4c36-bb8d-46fb48863f9an%40googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/e9b67ca9-8be0-4cea-a7ab-6e07fad9fa32n%40googlegroups.com.
Analysis of the USB protocol. It's really complex, it's 650 pages. I leave a video explaining the most basic things and yet it has many complexities. The video is very good, but it is for people with a high learning curve. An interesting thing is that USB works by changing bits, to consider that something is 1 or 0.https://www.youtube.com/watch?v=wdgULBpRoXk
--
Has recibido este mensaje porque estás suscrito al grupo "FPGAwars: explorando el lado libre" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a fpga-wars-explorando-el...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/fpga-wars-explorando-el-lado-libre/8d5a8447-3130-4c56-b7c1-902e1dd246fcn%40googlegroups.com.