Electronic – Connecting PC and embedded system via USB

usb

I have embedded system with USB3300 PHY and FPGA, which I have to program as a Link. I want my system to be able to communicate with my PC but I am not sure if I have gathered all information. Here is how I see it. I program FPGA to handle ULPI interface to be able to communicate with PHY. Then I write simple computer program to send data via USB that my system will be able to understand ? I am not sure if PC sends some extra information at the beggining of the transmission that I have to ignore ?

Best Answer

It sounds like you have the embedded side straight. Your FPGA will need to communicate with the USB transceiver as described in the Application Notes (PDF link). This may be quite complicated though, because the USB3300 is just the physical layer, I believe you will still need to implement a USB controller in the FPGA to actually handle the data transfers and handshaking as a USB client. Also, make sure you check all the boxes in the USB Design Checklist (PDF Link) for your device.

On the host side, your PC, you will need to write a driver. The driver will be required to handle the handshaking with your USB device and configuring the endpoints for the device depending on which device class you decide to implement in your FPGA. Then the driver will make the USB device available to user applications and handle the data transfers. Exactly how this is accomplished will be depend on your OS, but there are a lot of libraries out there that can help you out. Just Google "USB Driver library" for your OS.

Once the driver is complete, you can create a user-space application to interact with the driver, which will communicate directly with the FPGA, but this should be the easiest step in the process.

One note about your last question: yes, there is communication at the beginning of USB transmissions that your userspace application can ignore, but your driver does not ignore them, and neither does your FPGA. The USB controller and driver that you implement use these packets and headers to establish communication and direct USB traffic. If you're just starting in USB development, I'd suggest reading through something like the OSDev USB Wiki to get started. It's long, but USB is a complicated and robust protocol that you're implementing from the ground up, so you'll need the information there.

On the other hand, your FPGA manufacturer may have pre-validated USB controller code for free or available for purchase so you can skip writing your own and use an API instead. If that's available, I'd suggest using it to save yourself a lot of time. Additionally, if they have that available, they may also have a driver available for it. For example, the Cypress PSoC chips (which are microcontrollers packaged with configurable PLDs) provide both.

Another alternative to implementing your own controller in the FPGA would be to use an external controller like the MAX3420E or similar device. You may still need to implement a SPI controller for that example if your FPGA doesn't have onboard support, but it would be much less daunting than a USB controller, and there are options for other buses like I2C or UART that your FPGA may already support.