⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdc implementation.txt

📁 USB CDC using C8051F320/340, virtual COM port thru usb connection
💻 TXT
字号:
Implementation summary of CDC ACM (Abstract Control Model)

This is only one of variations of the enormous CDC implementations.
The purpose of this implementation is to make the device recognized as a COM port on major OS's, Windows, Mac, Linux.

History
    rev 0.1 Initial documentation
    rev 0.2 Revised after actual CDC ACM implementation

a) Descriptors
  The structure of descriptors

    Device
    Configuration
        Interface(0) - Communication Class
            Class-specific IF (Header Functional)
            Class-specific IF (Call Management Functional)
            Class-specific IF (Abstract Control Management Functional)
            Class-specific IF (Union Functional)
            Endpoint (Interrupt IN)
        Interface(1) - Data Interface Class
            Endpoint (Bulk IN)
            Endpoint (Bulk OUT)

a-1) Device descriptor (usbcdc11.pdf 5.1.1 p31)
    bDeviceClass:       0x02   (Communication Class)
    bDeviceSubClass:    0x00
    bDeviceProtocol:    0x00

    idVendor:           VID/PID must be unique
    idProduct:

a-2) Configuration descriptor
    wTotalLength:       0x43
    bNumInterfaces:     0x02

a-3) Interface descriptor(0) - Communication Class (usbcdc11.pdf 5.1.3 p31)
    bInterfaceNumber:   0x00
    bNumEndpoints:      0x01
    bInterfaceClass:    0x02   (Communication Class)
    bInterfaceSubClass: 0x02   (Abstract Control Model)
    bInterfaceProtocol: 0x01   (V.25ter, Common AT commands)

a-3-1) Class specific descriptors
a-3-1-1) Header Functional Descriptor (usbcdc11.pdf 5.2.3.1 p34)
    bLength:            0x05
    bDescriptorType:    0x24   (CS_INTERFACE)
    bDescriptorSubtype: 0x00   (Header Functional)
    bcdCDC:             0x0110 (CDC spec release number, 1.1)


a-3-1-2) Call Management Functional Descriptor (usbcdc11.pdf 5.2.3.2 p34)
    bLength:            0x05
    bDescriptorType:    0x24   (CS_INTERFACE)
    bDescriptorSubtype: 0x01   (Call Management)
    bmCapabilities:     0x01   (only over Communication Class IF / handles itself)
    bDataInterface:     0x01   (Interface number of Data Class interface)


a-3-1-3) Abstract Control Management Functional Descriptor (usbcdc11.pdf 5.2.3.3 p34)
    bLength:            0x04
    bDescriptorType:    0x24   (CS_INTERFACE)
    bDescriptorSubtype: 0x02   (Abstract Control Management)
    bmCapabilities:     0x06   (Supports Send_Break, Set_Line_Coding, Set_Control_Line_State,
                                Get_Line_Coding, and the notification Serial_State)


a-3-1-4) Union Functional Descriptor (usbcdc11.pdf 5.2.3.8 p40)
    bLength:            0x05
    bDescriptorType:    0x24   (CS_INTERFACE)
    bDescriptorSubtype: 0x06   (Union Functional)
    bMasterInterface:   0x00   (Interface number master interface in the union)
    bSlaveInterface0 :  0x01   (Interface number slave interface in the union)


a-3-2) Endpoint descriptor - (Interrupt IN)
    bmAttributes        0x03   (Interrupt)
    wMaxPacketSize:     0x0010 (16 bytes - more than SerialState response, 10 bytes)
    bInterval:          0x01   (1msec)


a-4) Interface descriptor(1) - Data Interface Class (usbcdc11.pdf 5.1.3 p32)
    bInterfaceNumber:   0x01
    bNumEndpoints:      0x02
    bInterfaceClass:    0x0A   (Data Interface Class)
    bInterfaceSubClass: 0x00
    bInterfaceProtocol: 0x00   (No class specific protocol required)

a-4-1) Endpoint descriptor (Bulk IN and Bulk OUT)
    bmAttributes        0x02   (Bulk)
    wMaxPacketSize:     0x0040 (64 bytes)
    bInterval:          0x00


b) Standard request
  Add extra Endpoints support in these request handler
    Get_Status
    Clear_Feature
    Set_Feature
    Set_Configuration

c) Class specific requests (usbcdc11.pdf 3.6.2.1 p16, 6.2 p51)
    0x00 SEND_ENCAPSULATED_COMMAND  (mandatory for the class, but unused in usbser.sys)
    0x01 GET_ENCAPSULATED_RESPONSE  (mandatory for the class, but unused in usbser.sys)
    0x20 SET_LINE_CODING
    0x21 GET_LINE_CODING
    0x22 SET_CONTROL_LINE_STATE
    0x23 SEND_BREAK

c-1) SEND_ENCAPSULATED_COMMAND (usbcdc11.pdf 6.2.1 p54)
  Nothing to do other than unloading the data sent in the data stage.

c-2) GET_ENCAPSULATED_RESPONSE (usbcdc11.pdf 6.2.2 p54)
  Return a zero-length packet

c-3) SET_LINE_CODING (usbcdc11.pdf 6.2.12 p57)
  Unload the line coding structure (7 bytes) sent in the data stage.
  Apply this setting to the UART
  Flush the communication buffer

    Line Coding Structure (7 bytes)
    0-3 dwDTERate    Data terminal rate (baudrate), in bits per second (LSB first)
    4   bCharFormat  Stop bits: 0 - 1 Stop bit, 1 - 1.5 Stop bits, 2 - 2 Stop bits
    5   bParityType  Parity:    0 - None, 1 - Odd, 2 - Even, 3 - Mark, 4 - Space
    6   bDataBits    Data bits: 5, 6, 7, 8, 16

c-4) GET_LINE_CODING (usbcdc11.pdf 6.2.13 p58)
  Return the line coding structure

c-5) SET_CONTROL_LINE_STATE (usbcdc11.pdf 6.2.14 p58)
  Set/reset RTS/DTR according to wValue
    wValue
     bit 1  RTS
     bit 0  DTR

c-6) SEND_BREAK (usbcdc11.pdf 6.2.15 p59)
  Send break from UART TX port, for wValue (msec) duration.
    wValue
     0xFFFF: continuous break
     0x0000: stop break


d) Vendor specific request (not supported by usbser.sys)
  Flow control
    Vendor OUT requrest
    0x41    bmRequestType (OUT, Vendor, Interface)
    0x01    bRequest      (Flow control request)
    xxxx    wValue        (Flow control code)
    0x0000  wIndex        (Interface #)
    0x0000  wLength

    Vendor IN requrest
    0xC1    bmRequestType (IN, Vendor, Interface)
    0x01    bRequest      (Flow control request)
    0x0000  wValue
    0x0000  wIndex        (Interface #)
    0x0002  wLength

    Flow control code
    0x01  RTS-CTS
    0x02  DTR-DSR

e) Interrupt IN EP - Notification element
  Return SerialState (usbcdc11.pdf 6.3.5 p75) notification response (10 bytes)
whenever the status are changed

    0:  0xA1   bmRequestType
    1:  0x20   bNotification (SERIAL_STATE)
    2:  0x00   wValue
    3:  0x00
    4:  0x00   wIndex (Interface #, LSB first)
    5:  0x00
    6:  0x02   wLength (Data length = 2 bytes, LSB first)
    7:  0x00
    8:  xx     UART State Bitmap (16bits, LSB first)
    9:  xx


    UART State Bitmap
    15-8: reserved
    7:  (no spec extra) CTS (not supported by usbser.sys)
    6:  bOverRun    overrun error
    5:  bParity     parity error
    4:  bFraming    framing error
    3:  bRingSignal RI
    2:  bBreak      break reception
    1:  bTxCarrier  DSR
    0:  bRxCarrier  DCD


f) Bulk IN/OUT EP - Data Interface
  Raw data to/from COM port


g) INF file

Win2K/XP/2K3 have a built-in CDC driver, Usbser.sys, as the default.
Vendors must provide an INF file for the device, However, because Windows doesn't have any standard INF file for Usbser.sys, unlike HID. INF file is generated with GenINF and checked by ChkINF included in WinDDK.

For Win98/98SE/ME, Usbser.sys is downloaded from this web page
"WDM Modem and USB Modem Kits" from MSDN
http://www.microsoft.com/whdc/device/network/modem/WDMmodem.mspx

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -