Blame view

Drivers/GD32F30x_usbfs_library/ustd/class/cdc/usb_cdc.h 8.63 KB
95ce2328   李外   完成USB移植,测试正常,
1
  /*!
3a54a732   李外   V100.0.16 GD32F3...
2
3
      \file    usb_cdc.h
      \brief   the header file of communication device class standard
95ce2328   李外   完成USB移植,测试正常,
4
5
  
      \version 2020-08-01, V3.0.0, firmware for GD32F30x
3a54a732   李外   V100.0.16 GD32F3...
6
      \version 2022-06-10, V3.1.0, firmware for GD32F30x
95ce2328   李外   完成USB移植,测试正常,
7
8
9
  */
  
  /*
3a54a732   李外   V100.0.16 GD32F3...
10
      Copyright (c) 2022, GigaDevice Semiconductor Inc.
95ce2328   李外   完成USB移植,测试正常,
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  
      Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:
  
      1. Redistributions of source code must retain the above copyright notice, this 
         list of conditions and the following disclaimer.
      2. Redistributions in binary form must reproduce the above copyright notice, 
         this list of conditions and the following disclaimer in the documentation 
         and/or other materials provided with the distribution.
      3. Neither the name of the copyright holder nor the names of its contributors 
         may be used to endorse or promote products derived from this software without 
         specific prior written permission.
  
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
  OF SUCH DAMAGE.
  */
  
3a54a732   李外   V100.0.16 GD32F3...
36
37
  #ifndef __USB_CDC_H
  #define __USB_CDC_H
95ce2328   李外   完成USB移植,测试正常,
38
  
3a54a732   李外   V100.0.16 GD32F3...
39
  #include "usb_ch9_std.h"
95ce2328   李外   完成USB移植,测试正常,
40
41
  
  /* communications device class code */
3a54a732   李外   V100.0.16 GD32F3...
42
  #define USB_CLASS_CDC                                       0x02U
95ce2328   李外   完成USB移植,测试正常,
43
44
  
  /* communications interface class control protocol codes */
3a54a732   李外   V100.0.16 GD32F3...
45
46
47
  #define USB_CDC_PROTOCOL_NONE                               0x00U
  #define USB_CDC_PROTOCOL_AT                                 0x01U
  #define USB_CDC_PROTOCOL_VENDOR                             0xFFU
95ce2328   李外   完成USB移植,测试正常,
48
49
  
  /* data interface class code */
3a54a732   李外   V100.0.16 GD32F3...
50
  #define USB_CLASS_DATA                                      0x0AU
95ce2328   李外   完成USB移植,测试正常,
51
  
3a54a732   李外   V100.0.16 GD32F3...
52
53
  #define USB_DESCTYPE_CDC_ACM                                0x21U
  #define USB_DESCTYPE_CS_INTERFACE                           0x24U
95ce2328   李外   完成USB移植,测试正常,
54
  
3a54a732   李外   V100.0.16 GD32F3...
55
  #define USB_CDC_ACM_CONFIG_DESC_SIZE                        0x43U
95ce2328   李外   完成USB移植,测试正常,
56
  
3a54a732   李外   V100.0.16 GD32F3...
57
58
  /* class-specific notification codes for pstn subclasses */
  #define USB_CDC_NOTIFY_SERIAL_STATE                         0x20U
95ce2328   李外   完成USB移植,测试正常,
59
60
  
  /* class-specific request codes */
3a54a732   李外   V100.0.16 GD32F3...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  #define SEND_ENCAPSULATED_COMMAND                           0x00U
  #define GET_ENCAPSULATED_RESPONSE                           0x01U
  #define SET_COMM_FEATURE                                    0x02U
  #define GET_COMM_FEATURE                                    0x03U
  #define CLEAR_COMM_FEATURE                                  0x04U
  
  #define SET_AUX_LINE_STATE                                  0x10U
  #define SET_HOOK_STATE                                      0x11U
  #define PULSE_SETUP                                         0x12U
  #define SEND_PULSE                                          0x13U
  #define SET_PULSE_TIME                                      0x14U
  #define RING_AUX_JACK                                       0x15U
  
  #define SET_LINE_CODING                                     0x20U
  #define GET_LINE_CODING                                     0x21U
  #define SET_CONTROL_LINE_STATE                              0x22U
  #define SEND_BREAK                                          0x23U
  #define NO_CMD                                              0xFFU
  
  #define SET_RINGER_PARMS                                    0x30U
  #define GET_RINGER_PARMS                                    0x31U
  #define SET_OPERATION_PARMS                                 0x32U
  #define GET_OPERATION_PARMS                                 0x33U
  #define SET_LINE_PARMS                                      0x34U
  #define GET_LINE_PARMS                                      0x35U
  #define DIAL_DIGITS                                         0x36U
  #define SET_UNIT_PARAMETER                                  0x37U
  #define GET_UNIT_PARAMETER                                  0x38U
  #define CLEAR_UNIT_PARAMETER                                0x39U
  #define GET_PROFILE                                         0x3AU
  
  #define SET_ETHERNET_MULTICAST_FILTERS                      0x40U
  #define SET_ETHERNET_POWER_MANAGEMENT_PATTERN FILTER        0x41U
  #define GET_ETHERNET_POWER_MANAGEMENT_PATTERN FILTER        0x42U
  #define SET_ETHERNET_PACKET_FILTER                          0x43U
  #define GET_ETHERNET_STATISTIC                              0x44U
  
  #define SET_ATM_DATA_FORMAT                                 0x50U
  #define GET_ATM_DEVICE_STATISTICS                           0x51U
  #define SET_ATM_DEFAULT_VC                                  0x52U
  #define GET_ATM_VC_STATISTICS                               0x53U
  
  /* wValue for set control line state */
  #define CDC_ACTIVATE_CARRIER_SIGNAL_RTS                     0x0002U
  #define CDC_DEACTIVATE_CARRIER_SIGNAL_RTS                   0x0000U
  #define CDC_ACTIVATE_SIGNAL_DTR                             0x0001U
  #define CDC_DEACTIVATE_SIGNAL_DTR                           0x0000U
  
  /* CDC subclass code */
  enum usb_cdc_subclass {
      USB_CDC_SUBCLASS_RESERVED = 0U,  /*!< reserved */
      USB_CDC_SUBCLASS_DLCM,           /*!< direct line control mode */
      USB_CDC_SUBCLASS_ACM,            /*!< abstract control mode */
      USB_CDC_SUBCLASS_TCM,            /*!< telephone control mode */
      USB_CDC_SUBCLASS_MCM,            /*!< multichannel control model */
      USB_CDC_SUBCLASS_CCM,            /*!< CAPI control model */
      USB_CDC_SUBCLASS_ENCM,           /*!< ethernet networking control model */
      USB_CDC_SUBCLASS_ANCM            /*!< ATM networking control model */
  };
95ce2328   李外   完成USB移植,测试正常,
120
121
122
  
  #pragma pack(1)
  
3a54a732   李外   V100.0.16 GD32F3...
123
  /* cdc acm line coding structure */
95ce2328   李外   完成USB移植,测试正常,
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  typedef struct {
      uint32_t dwDTERate;                   /*!< data terminal rate */
      uint8_t  bCharFormat;                 /*!< stop bits */
      uint8_t  bParityType;                 /*!< parity */
      uint8_t  bDataBits;                   /*!< data bits */
  } acm_line;
  
  /* notification structure */
  typedef struct {
      uint8_t bmRequestType;                /*!< type of request */
      uint8_t bNotification;                /*!< communication interface class notifications */
      uint16_t wValue;                      /*!< value of notification */
      uint16_t wIndex;                      /*!< index of interface */
      uint16_t wLength;                     /*!< length of notification data */
  } acm_notification;
  
95ce2328   李外   完成USB移植,测试正常,
140
141
142
143
144
145
  typedef struct {
      usb_desc_header header;               /*!< descriptor header, including type and size. */
      uint8_t   bDescriptorSubtype;         /*!< bDescriptorSubtype: header function descriptor */
      uint16_t  bcdCDC;                     /*!< bcdCDC: low byte of spec release number (CDC1.10) */
  } usb_desc_header_func;
  
95ce2328   李外   完成USB移植,测试正常,
146
147
148
149
150
151
152
  typedef struct {
      usb_desc_header header;               /*!< descriptor header, including type and size. */
      uint8_t  bDescriptorSubtype;          /*!< bDescriptorSubtype:  call management function descriptor */
      uint8_t  bmCapabilities;              /*!< bmCapabilities: D0 is reset, D1 is ignored */
      uint8_t  bDataInterface;              /*!< bDataInterface: 1 interface used for call management */
  } usb_desc_call_managment_func;
  
95ce2328   李外   完成USB移植,测试正常,
153
154
155
156
157
158
  typedef struct {
      usb_desc_header header;               /*!< descriptor header, including type and size. */
      uint8_t  bDescriptorSubtype;          /*!< bDescriptorSubtype: abstract control management descriptor */
      uint8_t  bmCapabilities;              /*!< bmCapabilities: D1 */
  } usb_desc_acm_func;
  
95ce2328   李外   完成USB移植,测试正常,
159
160
161
162
163
164
165
166
  typedef struct {
      usb_desc_header header;               /*!< descriptor header, including type and size. */
      uint8_t  bDescriptorSubtype;          /*!< bDescriptorSubtype: union function descriptor */
      uint8_t  bMasterInterface;            /*!< bMasterInterface: communication class interface */
      uint8_t  bSlaveInterface0;            /*!< bSlaveInterface0: data class interface */
  } usb_desc_union_func;
  
  #pragma pack()
3a54a732   李外   V100.0.16 GD32F3...
167
  
95ce2328   李外   完成USB移植,测试正常,
168
169
170
171
172
173
174
175
176
177
178
179
180
  typedef struct {
      usb_desc_config                  config;
      usb_desc_itf                     cmd_itf;
      usb_desc_header_func             cdc_header;
      usb_desc_call_managment_func     cdc_call_managment;
      usb_desc_acm_func                cdc_acm;
      usb_desc_union_func              cdc_union;
      usb_desc_ep                      cdc_cmd_endpoint;
      usb_desc_itf                     cdc_data_interface;
      usb_desc_ep                      cdc_out_endpoint;
      usb_desc_ep                      cdc_in_endpoint;
  } usb_cdc_desc_config_set;
  
3a54a732   李外   V100.0.16 GD32F3...
181
  #endif /* __USB_CDC_H */