USB Device Controller Driver Specification - usb

For USB Host Controllers there are the UHCI/OHCI/EHCI/XHCI specification that define how to program a driver. Is there an equivalent specification for USB Device Controllers?

No. Generally, every USB-capable microcontroller has a USB block that you can control by writing to some registers in your code, but those registers are pretty different on the different microcontrollers and I have not heard of any attempt to standardize them.

Related

Data input/output on Basys3 board's USB port

I'm trying to configure/write VHDL code that would let me output or input data from the USB port on a Basys3 FPGA board. Problem is I have yet to found any threads or questions that talk about this topic.
The nearest thing to an answer I've found is this:
Provide input data to FPGA using USB
and it does not contain what I'm looking for.
Any clues anyone¿?
The Basys3 board has a usb-uart bridge chip as described in the reference manual. This will appear to a PC (or any device with a usb host and the appropriate usb-serial drivers) as a virtual com port. Sending data to and from a PC com port is quite easy.
You will need a uart implementation on the FPGA. There are lots of example designs on the web. One way is to implement a soft core microblaze processor with a uart peripheral in the FPGA. This example looks like it includes foundation for the functionality you desire.
The simplest implementation from the PC side is using a terminal program such as putty, Tera Term or realterm. Most languages include com(serial) port libraries or bindings. This type of interface tops out at a raw bandwidth of around 3-12Mbits per second depending on the drivers and implementation.
Read the manual for the Basys 3 board. It will explain how you can interface with USB devices plugged into the USB port. Be warned, however, that your options are pretty limited.
Short version: if you plug in a USB mouse or keyboard, they will be exposed to your design as an emulated PS/2 device. USB storage devices can be used to configure the FPGA. Other devices are not supported.

USB interface between two microcontroller

I have been tasked to write a device driver for an embedded system which has two microcontroller interfaced via USB. The data transfer between two controller will take place across USB.
I am facing difficulty in reading USB specification.
Which USB class is suitable for communicating between two controllers?
USB is an asymmetric protocol where there is a host and a device, and the host is the one who initiates all communication. The device can conform to a USB Device Class, or your device can just have a vendor-defined interface that doesn't conform to any particular class.
Without knowing anything about the data you are sending between the microcontrollers, I would suggest just using a vendor-defined interface (USB device class code 0xFF). The host can initiate custom control transfers on endpoint 0 that transfer arbitrary data between the host and device. You can also use bulk/interrupt/isochronous endpoints to transfer data.
The USB CDC ACM class is used for virtual serial ports, and it provides a way to send bytes back and forth between the host and device; many devices use it for a generic communication mechanism.
The HID (Human Interface Device) class is another one that is designed for things like keyboards, but it can also be used for generic communication.
The main point of using a USB Device Class is that it allows you to take advantage of built-in drivers that different operating systems have for these types of devices without having to write your own driver. You might look to see if your host microcontroller has special USB drivers for one of those device classes. If it doesn't then there is not much point in using a USB Device Class. It sounds like you will be writing the code on both ends of the USB cable and you don't intend to take your device and plug it into any other type of USB host, so there is no point in forcing your protocol to conform to a USB class.

How to write firmware for a custom USB keyboard?

I have a custom ps2 keyboard(8x8 matrix) interfaced with AT89C51ED2 microcontroller, now I need to change it to USB interface. I have been studying about the basics of USB HID class communication(USB HID class specs, USB complete, Beyond logic) and have come to know little bit about the theory behind it.
But I am not able to understand the firmware part, I read a demo keypad application by Microchip which had given a sample source code, but I am not able to understand in the code how data(key pressed) is sent to the IN endpoint and how the host reads that through polling. I know that endpoint is a buffer from which data is sent to host, but Is it one of the registers of the micro-controller and how do I use it in my code?.
And I have been searching the suitable micro-controller with USB support, but no supported demo's are available, any suggestions will be helpful
The AT89C51ED2 datasheet does not mention hardware support for USB, so the answer is no: an endpoint does not correspond to a hardware register. Instead, an endpoint would refer to some software buffers in the RAM of the chip, and some data to keep track of the endpoint's state. Every bit of every USB packet must be handled by the firmware of the device, and endpoints are an abstraction that live entirely in the firmware of your device.
Note: I am assuming that the keyboard doesn't have some kind of USB interface chip, and that the data lines of the USB cable connect more-or-less directly to the microcontroller.
If you can't find the source code for the keyboard, you might look into using an open-source AVR software USB implementation. Here are some useful links:
https://www.obdev.at/products/vusb/
http://www.fischl.de/usbasp/
Please note that you are undertaking an advanced project, and if you are not familiar with AVRs, USB, microcontrollers, reverse engineering, and embedded development/debugging, it might be useful to start with something simpler first.

Arduino Leonardo USB device emulation

I recently got an Arduino Leonardo, and I'm fascinated by its ability to emulate USB HIDs.
But from what I can see, there are only libraries for keyboard and mouse emulation.
Is it possible to make it emulate a printer, microphone, headphones, anything other than a mouse or keyboard?
Yes, assuming that the device is HID compliant. You would just need to simulate the signals.
That said, it's unlikely that these other devices are HID compliant. They might, however, be class-compliant. Class-compliant means that you don't need special Windows drivers to plug it in and use it. There are a number of devices that are class-compliant; here is an example.
In the case of your Leonardo, it does not appear to be generally class-compliant, but more specifically HID compliant. I suppose, however, that you could write a driver on the Leonardo to make it class-compliant (for some other class).
See Also
USB Device Classes
You can use the LUFA toolchain to build much more than a few Leo examples.
It is possible to emulate any HID device with Arduino Leonardo, Pro Micro or their clones. It is not possible though with the stock Arduino HID library because it supports only SendReport method (Interrupt pipe), while generic HID support requires SetFeature/GetFeature methods (Control pipe).
Without going too deep into the theory of HID protocol implementation, you may check the emulation of the HID-compliant UPS on Arduino and implement something similar for any device class.

arm7 usb programming

we are developing a sendor device, with a arm7(current: LPC2368) .
this device samples a mv signal,A/D, and need to send this signal data to the PC.(continusly)
at the same time, PC need send command to arm7 (like get temperature, control status, etc..)
rs232 is too slow, so we choose USB.(20K/s - 200K/s)
but the question is, we donnot known how to do usb programming(both pc and arm..)
any direction? any portal? any tutorial?
currently we only sim the device as a HID....
For the ARM side you need a USB Stack. For the PC side you need to implement an USB driver and an application interfacing the driver. It is therefore easier to stick to one of the common profiles (HID, Mass Storage, Virtual COM). For all these you will be able to find USB stacks and not to have to implenent your own. Also you won't need to implement a USB driver for the PC.
I think that the easiest thing to do is to use a Virtual COM approach. From the PC side it would like you are accessing a Serial Port. The speed however can be higher than standard RS232 ports. I have found this USB Stack targetting an earlier processor. You could adapt it for your needs or use it as reference. Generally a Virtual COM driver for the PC will be provided along with the ARM USB stack.
Another approach is to use libusb. This will allow you to interact with USB without writing a kernel driver.
For application notes and commercial USB stacks look here. If you are determined to write your own stack and driver, Jungo is the industry leader for embedded USB stacks and drivers.