Lightweight USB stack  1.0
usb_cdc.h
1 /* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
2  *
3  * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _USB_CDC_H_
17 #define _USB_CDC_H_
18 
19 #ifdef __cplusplus
20  extern "C" {
21 #endif
22 
31 #define USB_CLASS_CDC 0x02
32 #define USB_CLASS_CDC_DATA 0x0A
37 #define USB_CDC_SUBCLASS_ACM 0x02
42 #define USB_CDC_PROTO_NONE 0x00
43 #define USB_CDC_PROTO_V25TER 0x01
49 #define USB_CDC_PROTO_NTB 0x01
50 #define USB_CDC_PROTO_HOST 0xFD
54 #define USB_CDC_PROTO_CDCSPEC 0xFE
62 #define USB_DTYPE_CDC_HEADER 0x00
63 #define USB_DTYPE_CDC_CALL_MANAGEMENT 0x01
64 #define USB_DTYPE_CDC_ACM 0x02
66 #define USB_DTYPE_CDC_UNION 0x06
67 #define USB_DTYPE_CDC_COUNTRY 0x07
74 #define USB_CDC_SEND_ENCAPSULATED_CMD 0x00
77 #define USB_CDC_GET_ENCAPSULATED_RESP 0x01
80 #define USB_CDC_SET_COMM_FEATURE 0x02
82 #define USB_CDC_GET_COMM_FEATURE 0x03
84 #define USB_CDC_CLEAR_COMM_FEATURE 0x04
87 #define USB_CDC_SET_LINE_CODING 0x20
89 #define USB_CDC_GET_LINE_CODING 0x21
91 #define USB_CDC_SET_CONTROL_LINE_STATE 0x22
92 #define USB_CDC_SEND_BREAK 0x23
98 #define USB_CDC_NTF_NETWORK_CONNECTION 0x00
100 #define USB_CDC_NTF_RESPONSE_AVAILABLE 0x01
102 #define USB_CDC_NTF_SERIAL_STATE 0x20
103 #define USB_CDC_NTF_SPEED_CHANGE 0x2A
112 #define USB_CDC_COMM_FEATURE 0x01
114 #define USB_CDC_CAP_LINE 0x02
117 #define USB_CDC_CAP_BRK 0x04
118 #define USB_CDC_CAP_NOTIFY 0x08
124 #define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
125 #define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
132 #define USB_CDC_1_STOP_BITS 0x00
133 #define USB_CDC_1_5_STOP_BITS 0x01
134 #define USB_CDC_2_STOP_BITS 0x02
135 #define USB_CDC_NO_PARITY 0x00
136 #define USB_CDC_ODD_PARITY 0x01
137 #define USB_CDC_EVEN_PARITY 0x02
138 #define USB_CDC_MARK_PARITY 0x03
139 #define USB_CDC_SPACE_PARITY 0x04
144 #define USB_CDC_STATE_RX_CARRIER 0x0001
147 #define USB_CDC_STATE_TX_CARRIER 0x0002
150 #define USB_CDC_STATE_BREAK 0x0004
151 #define USB_CDC_STATE_RING 0x0008
152 #define USB_CDC_STATE_FRAMING 0x0010
153 #define USB_CDC_STATE_PARITY 0x0020
154 #define USB_CDC_STATE_OVERRUN 0x0040
161 struct usb_cdc_header_desc {
162  uint8_t bFunctionLength;
163  uint8_t bDescriptorType;
164  uint8_t bDescriptorSubType;
165  uint16_t bcdCDC;
166 } __attribute__ ((packed));
167 
174 struct usb_cdc_union_desc {
175  uint8_t bFunctionLength;
176  uint8_t bDescriptorType;
177  uint8_t bDescriptorSubType;
178  uint8_t bMasterInterface0;
182  /* ... and there could be other slave interfaces */
183 } __attribute__ ((packed));
196  uint8_t bFunctionLength;
197  uint8_t bDescriptorType;
198  uint8_t bDescriptorSubType;
199  uint8_t iCountryCodeRelDate;
201  uint8_t wCountyCode0;
204  /* ... and there can be a lot of country codes */
205 } __attribute__ ((packed));
212  uint8_t bFunctionLength;
213  uint8_t bDescriptorType;
214  uint8_t bDescriptorSubType;
215  uint8_t bmCapabilities;
217  uint8_t bDataInterface;
219 } __attribute__ ((packed));
220 
227  uint8_t bFunctionLength;
228  uint8_t bDescriptorType;
230  uint8_t bmCapabilities;
231 } __attribute__ ((packed));
234 struct usb_cdc_notification {
235  uint8_t bmRequestType;
237  uint8_t bNotificationType;
238  uint16_t wValue;
239  uint16_t wIndex;
240  uint16_t wLength;
241  uint8_t Data[];
242 } __attribute__ ((packed));
246  uint32_t dwDTERate;
247  uint8_t bCharFormat;
248  uint8_t bParityType;
249  uint8_t bDataBits;
250 } __attribute__ ((packed));
251 
254 #ifdef __cplusplus
255  }
256 #endif
258 #endif /* _USB_CDC_H_ */
Abstract Control Management Functional Descriptor.
Definition: usb_cdc.h:257
uint8_t bDescriptorType
CS_INTERFACE descriptor type.
Definition: usb_cdc.h:228
uint8_t bDescriptorSubType
Union Functional Descriptor.
Definition: usb_cdc.h:208
Union Functional Descriptor.
Definition: usb_cdc.h:205
uint8_t bSlaveInterface0
Interface number of first slave or associated interface in the union.
Definition: usb_cdc.h:211
uint8_t bDescriptorSubType
Country Selection Functional Descriptor.
Definition: usb_cdc.h:229
Line Coding Structure.
Definition: usb_cdc.h:276
uint8_t bMasterInterface0
The interface number of the CDC interface designated as the master or controlling interface for the u...
Definition: usb_cdc.h:209
Call Management Functional Descriptor.
Definition: usb_cdc.h:242
uint8_t bDescriptorType
CS_INTERFACE descriptor type.
Definition: usb_cdc.h:207
uint8_t bFunctionLength
Size of this functional descriptor, in bytes.
Definition: usb_cdc.h:206
Notification structure from CDC.
Definition: usb_cdc.h:265
uint8_t bFunctionLength
Size of this functional descriptor, in bytes.
Definition: usb_cdc.h:227
Country Selection Functional Descriptor.
Definition: usb_cdc.h:226