CDC ClearUnitParameter
2025-07-11
0
0
1. 请求用途
ClearUnitParameter 用于恢复由Unit Parameter Structure标识的Unit参数的默认值。
主机通过此请求将特定Unit的参数重置为出厂默认值,新参数生效的时机取决于协议或厂商特定功能。
2. USB 控制传输格式
字段 | 值/说明 |
---|---|
bmRequestType | 0x21 (00100001B) 方向:主机到设备,类型:类,接收者:接口 |
bRequest | 0x39 (CLEAR_UNIT_PARAMETER) |
wValue | Unit Parameter Structure(见Table 60) |
wIndex | 接口号 |
wLength | 0 |
Data | 无 |
3. Unit Parameter Structure(Table 60)
偏移量 | 字段名 | 大小 | 值/说明 |
---|---|---|---|
0 | bEntityId | 1 | Unit ID |
1 | bParameterIndex | 1 | 基于零的值,指示Unit参数索引 |
C 结构体定义:
typedef struct _UNIT_PARAMETER_STRUCTURE {
uint8_t bEntityId; // Unit ID
uint8_t bParameterIndex; // 参数索引(从0开始)
} UNIT_PARAMETER_STRUCTURE;
4. 典型主机端请求示例
C 结构体示例:
UNIT_PARAMETER_STRUCTURE unit_param = {
.bEntityId = 0x01, // Unit ID 1
.bParameterIndex = 0x00 // 参数索引 0
};
USB_SETUP_PACKET setup = {
.bmRequestType = 0x21, // 主机到设备,类,接口
.bRequest = 0x39, // CLEAR_UNIT_PARAMETER
.wValue = *(uint16_t*)&unit_param, // Unit Parameter Structure
.wIndex = interface_number, // 通信接口号
.wLength = 0 // 无数据阶段
};
// 发送setup包,无data阶段
5. 设备端处理要点
- 解析wValue中的Unit Parameter Structure。
- 根据bEntityId和bParameterIndex确定目标参数。
- 将指定参数重置为默认值。
- 完成后通过状态阶段(Status Stage)ACK主机。
6. 常见应用场景
场景 | bEntityId | bParameterIndex | 说明 |
---|---|---|---|
音频Unit | 0x01 | 0x00 | 重置音频Unit参数 |
控制Unit | 0x02 | 0x01 | 重置控制Unit参数 |
厂商特定Unit | 0xFF | 0x00 | 重置厂商特定Unit参数 |
7. 参考
- USB CDC 规范 6.2.18](https://www.usb.org/document-library/class-definitions-communication-devices-12)
- SetUnitParameter 6.2.16](https://www.usb.org/document-library/class-definitions-communication-devices-12)
- GetUnitParameter 6.2.17](https://www.usb.org/document-library/class-definitions-communication-devices-12)