udi_cdc_desc.c
Go to the documentation of this file.
1 
33 /*
34  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
35  */
36 
37 #include "conf_usb.h"
38 #include "udd.h"
39 #include "udc_desc.h"
40 #include "udi_cdc.h"
41 
42 
54 #define USB_DEVICE_NB_INTERFACE (2*UDI_CDC_PORT_NB)
56 
57 #ifdef USB_DEVICE_LPM_SUPPORT
58 # define USB_VERSION USB_V2_1
59 #else
60 # define USB_VERSION USB_V2_0
61 #endif
62 
64 COMPILER_WORD_ALIGNED
66  .bLength = sizeof(usb_dev_desc_t),
69 #if UDI_CDC_PORT_NB > 1
70  .bDeviceClass = 0,
71 #else
72  .bDeviceClass = CDC_CLASS_DEVICE,
73 #endif
74  .bDeviceSubClass = 0,
75  .bDeviceProtocol = 0,
76  .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
77  .idVendor = LE16(USB_DEVICE_VENDOR_ID),
78  .idProduct = LE16(USB_DEVICE_PRODUCT_ID),
79  .bcdDevice = LE16((USB_DEVICE_MAJOR_VERSION << 8)
81 #ifdef USB_DEVICE_MANUFACTURE_NAME
82  .iManufacturer = 1,
83 #else
84  .iManufacturer = 0, // No manufacture string
85 #endif
86 #ifdef USB_DEVICE_PRODUCT_NAME
87  .iProduct = 2,
88 #else
89  .iProduct = 0, // No product string
90 #endif
91 #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
92  .iSerialNumber = 3,
93 #else
94  .iSerialNumber = 0, // No serial string
95 #endif
96  .bNumConfigurations = 1
97 };
98 
99 
100 #ifdef USB_DEVICE_HS_SUPPORT
101 COMPILER_WORD_ALIGNED
103 UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
104  .bLength = sizeof(usb_dev_qual_desc_t),
106  .bcdUSB = LE16(USB_VERSION),
107 #if UDI_CDC_PORT_NB > 1
108  .bDeviceClass = 0,
109 #else
110  .bDeviceClass = CDC_CLASS_DEVICE,
111 #endif
112  .bDeviceSubClass = 0,
113  .bDeviceProtocol = 0,
114  .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
115  .bNumConfigurations = 1
116 };
117 #endif
118 
119 #ifdef USB_DEVICE_LPM_SUPPORT
120 COMPILER_WORD_ALIGNED
122 UDC_DESC_STORAGE usb_dev_lpm_desc_t udc_device_lpm = {
123  .bos.bLength = sizeof(usb_dev_bos_desc_t),
124  .bos.bDescriptorType = USB_DT_BOS,
125  .bos.wTotalLength = LE16(sizeof(usb_dev_bos_desc_t) + sizeof(usb_dev_capa_ext_desc_t)),
126  .bos.bNumDeviceCaps = 1,
127  .capa_ext.bLength = sizeof(usb_dev_capa_ext_desc_t),
128  .capa_ext.bDescriptorType = USB_DT_DEVICE_CAPABILITY,
129  .capa_ext.bDevCapabilityType = USB_DC_USB20_EXTENSION,
130  .capa_ext.bmAttributes = USB_DC_EXT_LPM,
131 };
132 #endif
133 
136 typedef struct {
138 #if UDI_CDC_PORT_NB == 1
141 #else
142 # define UDI_CDC_DESC_STRUCTURE(index, unused) \
143  usb_iad_desc_t udi_cdc_iad_##index; \
144  udi_cdc_comm_desc_t udi_cdc_comm_##index; \
145  udi_cdc_data_desc_t udi_cdc_data_##index;
146  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_STRUCTURE, ~)
147 # undef UDI_CDC_DESC_STRUCTURE
148 #endif
149 } udc_desc_t;
151 
152 COMPILER_WORD_ALIGNED
155  .conf.bLength = sizeof(usb_conf_desc_t),
157  .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
159  .conf.bConfigurationValue = 1,
160  .conf.iConfiguration = 0,
161  .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
162  .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
163 #if UDI_CDC_PORT_NB == 1
164  .udi_cdc_comm_0 = UDI_CDC_COMM_DESC_0,
165  .udi_cdc_data_0 = UDI_CDC_DATA_DESC_0_FS,
166 #else
167 # define UDI_CDC_DESC_FS(index, unused) \
168  .udi_cdc_iad_##index = UDI_CDC_IAD_DESC_##index,\
169  .udi_cdc_comm_##index = UDI_CDC_COMM_DESC_##index,\
170  .udi_cdc_data_##index = UDI_CDC_DATA_DESC_##index##_FS,
171  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_FS, ~)
172 # undef UDI_CDC_DESC_FS
173 #endif
174 };
175 
176 #ifdef USB_DEVICE_HS_SUPPORT
177 COMPILER_WORD_ALIGNED
178 UDC_DESC_STORAGE udc_desc_t udc_desc_hs = {
179  .conf.bLength = sizeof(usb_conf_desc_t),
181  .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
183  .conf.bConfigurationValue = 1,
184  .conf.iConfiguration = 0,
185  .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
186  .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
187 #if UDI_CDC_PORT_NB == 1
188  .udi_cdc_comm_0 = UDI_CDC_COMM_DESC_0,
189  .udi_cdc_data_0 = UDI_CDC_DATA_DESC_0_HS,
190 #else
191 # define UDI_CDC_DESC_HS(index, unused) \
192  .udi_cdc_iad_##index = UDI_CDC_IAD_DESC_##index, \
193  .udi_cdc_comm_##index = UDI_CDC_COMM_DESC_##index, \
194  .udi_cdc_data_##index = UDI_CDC_DATA_DESC_##index##_HS,
195  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_HS, ~)
196 # undef UDI_CDC_DESC_HS
197 #endif
198 };
199 #endif
200 
205 
208 # define UDI_CDC_API(index, unused) \
209  &udi_api_cdc_comm, \
210  &udi_api_cdc_data,
212 # undef UDI_CDC_API
213 };
214 
218  .udi_apis = udi_apis,
219 }};
220 #ifdef USB_DEVICE_HS_SUPPORT
221 UDC_DESC_STORAGE udc_config_speed_t udc_config_hs[1] = { {
222  .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs,
223  .udi_apis = udi_apis,
224 }};
225 #endif
226 
230  .conf_lsfs = udc_config_fs,
231 #ifdef USB_DEVICE_HS_SUPPORT
232  .confdev_hs = &udc_device_desc,
233  .qualifier = &udc_device_qual,
234  .conf_hs = udc_config_hs,
235 #endif
236 #ifdef USB_DEVICE_LPM_SUPPORT
237  .conf_bos = &udc_device_lpm.bos,
238 #else
239  .conf_bos = NULL,
240 #endif
241 };
242 
244 
Communication Class interface descriptor.
Definition: udi_cdc.h:84
#define USB_DEVICE_EP_CTRL_SIZE
Control endpoint size (Endpoint 0)
Definition: udi_cdc_conf.h:57
#define USB_DEVICE_ATTR
Definition: conf_usb.h:58
uint16_t bcdUSB
Common API for USB Device Interface.
Common API for USB Device Drivers (UDD)
USB configuration file for CDC application.
uint8_t bDescriptorType
UDC_DESC_STORAGE udc_config_speed_t udc_config_fs[1]
Add UDI with USB Descriptors FS & HS.
Definition: udi_cdc_desc.c:216
#define USB_CONFIG_ATTR_MUST_SET
Must always be set.
Definition: usb_protocol.h:422
USB Device Communication Device Class (CDC) interface definitions.
#define USB_VERSION
Definition: udi_cdc_desc.c:60
#define COMPILER_PACK_RESET()
Set default alignment for subsequent struct and union definitions.
Definition: compiler.h:120
#define USB_DEVICE_NB_INTERFACE
Two interfaces for a CDC device.
Definition: udi_cdc_desc.c:55
#define UDI_CDC_API(index, unused)
#define CDC_CLASS_DEVICE
USB Communication Device Class.
Data Class interface descriptor.
Definition: udi_cdc.h:106
#define UDI_CDC_PORT_NB
Definition: udi_cdc.h:49
Standard USB device descriptor structure.
Definition: usb_protocol.h:313
Standard USB configuration descriptor structure.
Definition: usb_protocol.h:410
#define USB_DEVICE_MAJOR_VERSION
Definition: conf_usb.h:55
#define UDI_CDC_COMM_DESC_0
Definition: udi_cdc.h:138
COMPILER_WORD_ALIGNED UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc
USB Device Descriptor.
Definition: udi_cdc_desc.c:65
#define USB_DEVICE_VENDOR_ID
Device definition (mandatory)
Definition: conf_usb.h:52
#define UDI_CDC_DATA_DESC_0_FS
Definition: udi_cdc.h:139
UDC_DESC_STORAGE udc_config_t udc_config
Add all information about USB Device in global structure for UDC.
Definition: udi_cdc_desc.c:228
#define NULL
Definition: nm_bsp.h:52
UDC_DESC_STORAGE udi_api_t * udi_apis[USB_DEVICE_NB_INTERFACE]
Associate an UDI for each USB interface.
Definition: udi_cdc_desc.c:207
#define COMPILER_PACK_SET(alignment)
Set maximum alignment for subsequent struct and union definitions to alignment.
Definition: compiler.h:113
#define USB_DEVICE_POWER
Definition: conf_usb.h:57
USB Device Capabilities - USB 2.0 Extension Descriptor structure.
Definition: usb_protocol.h:375
uint8_t bNumInterfaces
Definition: usb_protocol.h:414
Configuration descriptor and UDI link for one USB speed.
Definition: udc_desc.h:90
Standard USB device qualifier descriptor structure.
Definition: usb_protocol.h:338
#define USB_DEVICE_MINOR_VERSION
Definition: conf_usb.h:56
#define LE16(x)
Definition: compiler.h:890
#define MREPEAT(count, macro, data)
Macro repeat.
Definition: mrepeat.h:65
udi_cdc_comm_desc_t udi_cdc_comm_0
Definition: udi_cdc_desc.c:139
UDI API.
Definition: udi.h:64
uint8_t bDescriptorType
Definition: usb_protocol.h:412
udi_cdc_data_desc_t udi_cdc_data_0
Definition: udi_cdc_desc.c:140
USBDeviceCapabilities capa_ext
#define UDI_CDC_DATA_DESC_0_HS
Definition: udi_cdc.h:140
All information about the USB Device.
Definition: udc_desc.h:101
#define USB_CONFIG_MAX_POWER(ma)
Max power in mA.
Definition: usb_protocol.h:427
usb_dev_desc_t UDC_DESC_STORAGE * confdev_lsfs
USB device descriptor for low or full speed.
Definition: udc_desc.h:103
#define UDC_DESC_STORAGE
Defines the memory&#39;s location of USB descriptors.
Definition: udc_desc.h:70
usb_conf_desc_t UDC_DESC_STORAGE * desc
USB configuration descriptor.
Definition: udc_desc.h:92
USB Device LPM Descriptor structure.
Definition: usb_protocol.h:387
COMPILER_WORD_ALIGNED UDC_DESC_STORAGE udc_desc_t udc_desc_fs
USB Device Configuration Descriptor filled for full and high speed.
Definition: udi_cdc_desc.c:154
USBDeviceBOSDescriptor bos
Structure for USB Device Configuration Descriptor.
Definition: udi_cdc_desc.c:136
#define USB_DEVICE_PRODUCT_ID
Definition: conf_usb.h:54
usb_dev_bos_desc_t bos
Definition: usb_protocol.h:388
usb_conf_desc_t conf
Definition: udi_cdc_desc.c:137
USB Device BOS descriptor structure.
Definition: usb_protocol.h:362


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58