CHAILink SDK  Version 1.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USB Device Description

Device Descriptor

A CopperLan Device declares itself at interface level and not at device level. That's the reason why Class, Subclass and protocol are all 0 in the USB Device Descriptor.

Example:

USB_DEVICE_DESCRIPTOR device_dsc =
{
0x12, // Size of this descriptor in bytes
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
0x0200, // USB Spec Release Number in BCD format
0x00, // Class Code
0x00, // Subclass code
0x00, // Protocol code
USB_EP0_BUFF_SIZE, // Max packet size for EP0, see usb_config.h
0xvvvv, // Vendor ID
0xpppp, // Product ID
0x0001, // Device release number in BCD format
0x01, // Manufacturer string index
0x02, // Product string index
0x03, // Device serial number string index
0x01 // Number of possible configurations
};

We will see what can be used for VenderID (0xvvvv) and Product ID (0xpppp) in USB CopperLan Driver mapping..

Remarks
The USB Configuration Descriptor is not described here, because it is completely standard. Complete USB descirptors sample can be found in CopperDuino samples
Warning
USB VendorID and ProducID are totaly independent from CopperLan BrandID and ProductID.

Interface Descriptor

A CopperLan Device can have several interfaces (standard and custom) but must have only one CopperLan Interface. It is composed of an interface descriptor followed by a custom descriptor for unequivocal validation.

Example of Interface Desriptor:

// Interface Descriptor
0x09, // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type
0, // Interface Number
0, // Alternate Setting Number
2, // Number of endpoints in this interface
0xFF, // Custom Class code
0x43, // CopperLan Subclass code
0x50, // CopperLan Protocol code
0, // Interface string index

Specificities of this descriptor:

  • Custom class must be specified (0xFF)
  • Subclass must be set to 0x43
  • Protocol must be set to 0x50
  • The number of endpoints for this interface must be 2.

This interface descriptor must be directly followed by a custom descriptor defined as follow:

  • It is 5 bytes long, so first byte is 0x05.
  • Second byte (the descriptor type) must be set to 0x43. This is a Vendor specific descriptor type. For references see "3.11 Identifying Class and Vendor-Specific Requests and Descriptors" in "Universal Serial Bus Common Class Specification" (usbccs10.pdf) and "Table 9-2. Format of Setup Data" in "USB Specification" (usb_20.pdf).
  • Third byte corresponds to the index of the corresponding custom interface descriptor.
  • Fourth byte corresponds to the interface version. Actually it is 0x10 for 1.0
  • Fifth and last byte is the protocol. It must be 0x01 for CHAILink
    // CopperLan Interface Descriptor
    0x05, // Size of this descriptor in bytes
    0x43, // CopperLan Custom INTERFACE descriptor type
    0, // Interface Number (here the first interface)
    0x10, // Interface version (1.0)
    0x01, // Interface protocol (0x01 for CHAILink)
Remarks
Do not forget to add the size of the custom descriptor (0x05) to the global descriptors size.

Endpoints Descriptor

The CopperLan USB Interface must implement two bulk endpoints, one in and one out. The order of these endpoints do not care (In or Out pipe can be the first one). The default size of the two bulk endpoints is 64 but can be placed at a different value depending on the version of the USB standard used, USB speed ...

Endpoint descriptors sample:

// First Endpoint Descriptor (Out Bulk Pipe)
0x07, // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor type
0x01, // Out Endpoint Address
_BULK, // Attributes
64, // Max Packet size (16-bit)
1, // Interval
// Second Endpoint Descriptor (In Bilk Pipe)
0x07, // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor type
0x81, // In EndpointAddress
_BULK, // Attributes
64, // Max Packet size (16-bit)
1, // Interval

Based on this definition, once the USB device is declared on the host, the CHAILink Client Transport must send data through Out Endpoint and process received data through In endpoint.

  • For Out Endpoint : If the CHAILink Client Transport wants to send (see CHAILink Client Transport) a frame larger than the Max Packet Size of the bulk endpoint, the transport must simply splits the packet into multiple USB frames. (e.g. for a MaxPaket size of 64 and a packet of 135 bytes, the transport should send 3 packets : 64 + 64 + 7 bytes)
  • For In endpoint : Each packet must be transmitted to the CHAI Link transport protocol (see CHAILink Client Transport) which will do the reassembly of the complete CHALink packet.