Loading...
Searching...
No Matches
cdc.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Dylan Laduranty <dylan.laduranty@mesotic.com>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
21
22#include <stdint.h>
23
24#include "usb.h"
25#include "usb/descriptor.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define USB_TYPE_DESCRIPTOR_CDC 0x24
32#define USB_CDC_VERSION_BCD 0x0120
33
39#define USB_CDC_SUBCLASS_NONE 0x00
40#define USB_CDC_SUBCLASS_DLCM 0x01
41#define USB_CDC_SUBCLASS_ACM 0x02
42#define USB_CDC_SUBCLASS_TCM 0x03
43#define USB_CDC_SUBCLASS_MCCM 0x04
44#define USB_CDC_SUBCLASS_CCM 0x05
45#define USB_CDC_SUBCLASS_ENCM 0x06
46#define USB_CDC_SUBCLASS_ANCM 0x07
47#define USB_CDC_SUBCLASS_WHCM 0x08
48#define USB_CDC_SUBCLASS_DM 0x09
49#define USB_CDC_SUBCLASS_MDLM 0x0A
50#define USB_CDC_SUBCLASS_OBEX 0x0B
51#define USB_CDC_SUBCLASS_EEM 0x0C
52#define USB_CDC_SUBCLASS_NCM 0x0D
54
59#define USB_CDC_PROTOCOL_NONE 0x00
60#define USB_CDC_PROTOCOL_ITU 0x01
61#define USB_CDC_PROTOCOL_PCCA 0x02
62#define USB_CDC_PROTOCOL_PCCA_A 0x03
63#define USB_CDC_PROTOCOL_GSM 0x04
64#define USB_CDC_PROTOCOL_3GPP 0x05
65#define USB_CDC_PROTOCOL_CS 0x06
66#define USB_CDC_PROTOCOL_EEM 0x07
67#define USB_CDC_PROTOCOL_EXT 0xFE
68#define USB_CDC_PROTOCOL_VENDOR 0xFF
70
75#define USB_CDC_DESCR_SUBTYPE_FUNCTIONAL 0x00
77#define USB_CDC_DESCR_SUBTYPE_CALL_MGMT 0x01
79#define USB_CDC_DESCR_SUBTYPE_ACM 0x02
81#define USB_CDC_DESCR_SUBTYPE_UNION 0x06
82#define USB_CDC_DESCR_SUBTYPE_ETH_NET 0x0f
84
89
93#define USB_CDC_MGNT_REQUEST_SET_LINE_CODING (0x20)
94
98#define USB_CDC_MGNT_REQUEST_GET_LINE_CODING (0x21)
99
103#define USB_CDC_MGNT_REQUEST_SET_CONTROL_LINE_STATE (0x22)
104
108#define USB_CDC_MGNT_REQUEST_SET_ETH_MULTICAST_FILTER 0x40
109
113#define USB_CDC_MGNT_REQUEST_SET_ETH_PM_PATTERN_FILTER 0x41
114
118#define USB_CDC_MGNT_REQUEST_GET_ETH_PM_PATTERN_FILTER 0x42
119
123#define USB_CDC_MGNT_REQUEST_SET_ETH_PACKET_FILTER 0x43
124
128#define USB_CDC_MGNT_REQUEST_GET_ETH_STATISTICS 0x44
130
135
139#define USB_CDC_ACM_CONTROL_LINE_DTE (0x01)
140
144#define USB_CDC_ACM_CONTROL_LINE_CARRIER (0x02)
146
151
155#define USB_CDC_MGNT_NOTIF_NETWORK_CONNECTION 0x00
156
160#define USB_CDC_MGNT_NOTIF_RESPONSE_AVAILABLE 0x01
161
165#define USB_CDC_MGNT_NOTIF_AUX_JACK_HOOK_STATE 0x08
166
170#define USB_CDC_MGNT_NOTIF_RING_DETECT 0x09
171
175#define USB_CDC_MGNT_NOTIF_SERIAL_STATE 0x20
176
180#define USB_CDC_MGNT_NOTIF_CALL_STATE_CHANGE 0x28
181
185#define USB_CDC_MGNT_NOTIF_LINE_STATE_CHANGE 0x29
186
190#define USB_CDC_MGNT_NOTIF_CONN_SPEED_CHANGE 0x2A
191
193
199typedef struct __attribute__((packed)) {
200 uint8_t length;
201 uint8_t type;
202 uint8_t subtype;
203 uint8_t macaddress;
205 uint16_t maxsegmentsize;
209
215typedef struct __attribute__((packed)) {
216 uint8_t length;
217 uint8_t type;
218 uint8_t subtype;
219 uint8_t capabilities;
221
227typedef struct __attribute__((packed)) {
228 uint8_t length;
229 uint8_t type;
230 uint8_t subtype;
231 uint16_t bcd_cdc;
233
237typedef struct __attribute__((packed)) {
238 uint8_t length;
239 uint8_t type;
240 uint8_t subtype;
241 uint8_t master_if;
242 uint8_t slave_if;
244
250typedef struct __attribute__((packed)) {
251 uint8_t length;
252 uint8_t type;
253 uint8_t subtype;
254 uint8_t capabilities;
255 uint8_t data_if;
257
263typedef struct __attribute__((packed)) {
265 uint32_t down;
266 uint32_t up;
268
273
278typedef struct __attribute__((packed)) {
279 uint32_t baud;
280 uint8_t format;
281 uint8_t parity;
282 uint8_t databits;
284
285#define USB_CDC_ACM_CODING_STOP_BITS_1 0
286#define USB_CDC_ACM_CODING_STOP_BITS_1_5 1
287#define USB_CDC_ACM_CODING_STOP_BITS_2 2
288
289#define USB_CDC_ACM_CODING_PARITY_NONE 0
290#define USB_CDC_ACM_CODING_PARITY_ODD 1
291#define USB_CDC_ACM_CODING_PARITY_EVEN 2
292#define USB_CDC_ACM_CODING_PARITY_MARK 3
293#define USB_CDC_ACM_CODING_PARITY_SPACE 4
295
296#ifdef __cplusplus
297}
298#endif
299
Definitions for USB protocol messages.
USB CDC ACM descriptor.
Definition cdc.h:215
uint8_t subtype
Descriptor subtype (USB_CDC_DESCR_SUBTYPE_ACM)
Definition cdc.h:218
uint8_t type
Descriptor type (USB_TYPE_DESCRIPTOR_CDC)
Definition cdc.h:217
uint8_t length
Size of this descriptor.
Definition cdc.h:216
uint8_t capabilities
Bitmap indicating the capabilities.
Definition cdc.h:219
USB CDC call management functional descriptor.
Definition cdc.h:250
uint8_t length
Size of this descriptor.
Definition cdc.h:251
uint8_t capabilities
Supported capabilities.
Definition cdc.h:254
uint8_t type
Descriptor type (USB_TYPE_DESCRIPTOR_CDC)
Definition cdc.h:252
uint8_t data_if
Interface number used for the call management.
Definition cdc.h:255
uint8_t subtype
Descriptor subtype (USB_CDC_DESCR_SUBTYPE_CALL_MGMT)
Definition cdc.h:253
Generic USB CDC descriptor.
Definition cdc.h:227
uint8_t subtype
Descriptor subtype (usb_cdc_subtype)
Definition cdc.h:230
uint8_t length
Size of this descriptor.
Definition cdc.h:228
uint8_t type
Descriptor type (USB_TYPE_DESCRIPTOR_CDC)
Definition cdc.h:229
uint16_t bcd_cdc
CDC release number in bcd (USB_CDC_VERSION_BCD)
Definition cdc.h:231
USB CDC ECM connection speed change notification.
Definition cdc.h:263
uint32_t down
Downlink bit rate.
Definition cdc.h:265
uint32_t up
Uplink bit rate.
Definition cdc.h:266
usb_setup_t setup
Setup request header for the notification.
Definition cdc.h:264
USB CDC ECM descriptor.
Definition cdc.h:199
uint16_t maxsegmentsize
Maximum segment size of the interface.
Definition cdc.h:205
uint8_t macaddress
Index of the string containing the ethernet MAC address.
Definition cdc.h:203
uint8_t length
Size of this descriptor.
Definition cdc.h:200
uint8_t subtype
Descriptor subtype (USB_CDC_DESCR_SUBTYPE_ETH_NET)
Definition cdc.h:202
uint16_t numbermcfilters
Number of configurable multicast filters.
Definition cdc.h:206
uint8_t numberpowerfilters
Number of pattern filters for host wake-up.
Definition cdc.h:207
uint8_t type
Descriptor type (USB_TYPE_DESCRIPTOR_CDC)
Definition cdc.h:201
uint32_t ethernetstatistics
Bitmap indicating the statistics caps.
Definition cdc.h:204
USB union descriptor.
Definition cdc.h:237
uint8_t master_if
Master/controlling interface number.
Definition cdc.h:241
uint8_t length
Size of this descriptor.
Definition cdc.h:238
uint8_t slave_if
Slave/subordinate interface number.
Definition cdc.h:242
uint8_t subtype
Descriptor subtype (USB_CDC_DESCR_SUBTYPE_UNION)
Definition cdc.h:240
uint8_t type
Descriptor type (USB_TYPE_DESCRIPTOR_CDC)
Definition cdc.h:239
USB CDC ACM line coding setup content.
Definition cdc.h:278
uint8_t parity
Parity settings.
Definition cdc.h:281
uint8_t format
Stop bits settings.
Definition cdc.h:280
uint8_t databits
Number of data bits (5, 6, 7, 8 or 16)
Definition cdc.h:282
uint32_t baud
Requested baud rate.
Definition cdc.h:279
USB setup packet (USB 2.0 spec table 9-2)
Definition descriptor.h:205
Definition of global compile time configuration options.