news 2026/10/23 2:43:51

USB CDC class

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
USB CDC class

What is USB CDC?

USB CDC (Communications Device Class)is a USB device class defined by the USB-IF that allows a USB device to present itself as a communication device, such as a serial port, modem, network adapter, or telephony device. The most commonly used CDC subclass in embedded systems isCDC-ACM (Abstract Control Model), which emulates a traditional UART COM port. [usb.org], [en.wikipedia.org]


CDC Class Hierarchy

USB Device Class (0x02) │ ├── CDC-ACM (Virtual COM Port) ├── CDC-ECM (Ethernet Control Model) ├── CDC-NCM (Network Control Model) ├── CDC-ATM ├── CDC-PSTN └── CDC-WMC

The most common embedded implementation is:

USB CDC-ACM ↓ Windows → COM3, COM4 ... Linux → /dev/ttyACM0 macOS → /dev/cu.usbmodemxxxx ``

[usb.org], [en.wikipedia.org]


CDC Architecture

CDC separates communication into two interfaces:

1. Communication Interface (CIC)

Used for control and management.

Class = 0x02 (CDC)

Carries:

  • Line coding configuration
  • DTR/RTS status
  • Notification messages
  • Modem status

Typical endpoint:

Interrupt IN

2. Data Interface (DIC)

Used for actual payload transfer.

Class = 0x0A (CDC Data)

Typical endpoints:

Bulk OUT Bulk IN

Endpoint Layout

A typical CDC-ACM device uses:

EP0 Control EP1 IN Interrupt (Notification) EP2 OUT Bulk (Host → Device) EP2 IN Bulk (Device → Host) ``
Host │ ▼ +---------------+ | CDC Driver | +---------------+ │ ┌────────┴─────────┐ ▼ ▼ Interrupt EP Bulk EP (Control) (Data)

Enumeration Example

During enumeration, the host sees:

Device Descriptor Configuration Descriptor Interface 0 CDC Communication Interface Interface 1 CDC Data Interface ``

The host loads the CDC driver and creates a virtual serial port.

Examples:

Windows : COM5 Linux : /dev/ttyACM0 macOS : /dev/cu.usbmodem101

[en.wikipedia.org], [usb.org]


CDC-ACM Control Requests

After enumeration, the host sends class-specific requests.

SET_LINE_CODING

typedef struct { uint32_t baudrate; uint8_t stopbits; uint8_t parity; uint8_t databits; } LINE_CODING;

Example:

115200 8 data bits No parity 1 stop bit

GET_LINE_CODING

Host requests current UART settings.

SET_CONTROL_LINE_STATE

Controls:

DTR RTS

Many MCU applications use DTR as:

Terminal Connected

signal.


SEND_BREAK

Generate UART break condition.

CDC-ACM Data Flow

Application │ UART-style API │ CDC Driver │ USB Bulk IN/OUT │ USB Host ``

Example:

printf("Hello\r\n");

MCU:

CDC_Transmit_FS()

USB:

Bulk IN Endpoint

PC Terminal:

COM Port Window

shows:

Hello

Why CDC Is Popular

No Custom Driver Needed

Most operating systems already provide CDC drivers.

Windows usbser.sys Linux cdc_acm macOS built-in

UART Replacement

Instead of:

USB-UART Bridge ↓ FT232 CP2102 CH340

the MCU directly implements:

USB CDC-ACM ``

saving hardware cost.

Debug Console

Used for:

Firmware logs CLI commands Bootloader communication AT commands

CDC vs HID

FeatureCDCHID
Appears asCOM PortKeyboard/Mouse
Bulk transferYesNo
Driver supportCDC DriverHID Driver
ThroughputHighLower
Virtual UARTYesNo

CDC vs Vendor Specific

FeatureCDCVendor Class
StandardizedYesNo
Host DriverBuilt-inUsually custom
COM PortYesDepends
PortabilityHighLower

Typical Descriptor Classes

Device Class 0x02 CDC Communication 0x02 CDC Data 0x0A

Functional descriptors:

Header Descriptor Call Management Descriptor ACM Descriptor Union Descriptor

These descriptors tell the host that the device implements the CDC-ACM model and that Interface 0 controls Interface 1. [cscott.net], [usb.org]

For embedded firmware engineers,CDC-ACM is essentially "USB behaving like a UART", although the transport underneath is actually USB control, interrupt, and bulk transfers rather than UART signaling.

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/10/23 2:43:03

基于 Spring Boot 的奖助学金申报与评审系统设计与实现

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/10/23 2:42:16

Path of Building PoE2:10 分钟定下你的 BD

Path of Building PoE2:10 分钟定下你的 BD 【免费下载链接】PathOfBuilding-PoE2 项目地址: https://gitcode.com/GitHub_Trending/pa/PathOfBuilding-PoE2 你盯着天赋树看了二十分钟,第一个节点还是不知道该点哪;捡到一件多行词条的…

作者头像 李华
网站建设 2026/10/23 2:40:16

agents-generator - server-actions

服务器操作 / 后端 入口 {{ENTRY_POINT_DESCRIPTION}} 流动 {{请求流程}} {{RESPONSE_TYPE_TITLE}} {{RESPONSE_TYPE}} 错误处理 {{错误处理}} 速率限制 {{速率限制}} 生成规则 入口点描述: 服务器操作:主文件,导出函数,参数。API 路由&#…

作者头像 李华