0
votes

I'm new with USB.

I want to implement a pointing device on a PIC microcontroller. USB will be used for communications between the pointing device and the host.

I would like to do the following:

  1. Send deltas to the host's HID class driver, so the device can function as a simple mouse immediately after plug-in.

  2. Send other data to the host using the CDC class for it to be post-processed by an application running on user space.

My main questions are:

  • What is the best way to implement this? Should I define 2 distinct interfaces?

  • What descriptors should I define?

I'm thinking of the following:

 Device descriptor
 Config descriptor

 Interface 0 descriptor
 Functional descriptors
 EP descriptor

 Interface 1 descriptor (CDC)
 EP descriptors

 Interface 2 descriptor (HID)
 EP descriptors

How should I define the "functional descriptors" that go after Interface 0 descriptor? Should I define interfaces 1 and 2 as slaves of interface 0?

1
You should implement a composite device. It's probably a good idea to get an Arduino Leonardo and use the Arduino Mouse library to see how they do it. It implements a CDC serial port and a mouse at the same time. You can use lsusb on a Linux computer to list its descriptors in detail. - David Grayson

1 Answers

0
votes

I believe you must implement two distinct interface for two interface types. You need to go through the CDC and HID specifications to understand the interface descriptors and (Endpoint descriptors).

I did not understand "slave interface" word. Did you mean alternate interface? You do not need any alternate interfaces.

Example for multiple interfaces please refer to the image.

enter image description here

Thanks