Avadhana Technologies
Avadhana Technologies

Reputation: 692

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?

Upvotes: 2

Views: 2087

Answers (1)

David Grayson
David Grayson

Reputation: 87486

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.

Upvotes: 2

Related Questions