udi_cdc.h
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 #ifndef _UDI_CDC_H_
38 #define _UDI_CDC_H_
39 
40 #include "conf_usb.h"
41 #include "usb_protocol.h"
42 #include "usb_protocol_cdc.h"
43 #include "udd.h"
44 #include "udc_desc.h"
45 #include "udi.h"
46 
47 // Check the number of port
48 #ifndef UDI_CDC_PORT_NB
49 # define UDI_CDC_PORT_NB 1
50 #endif
51 #if (UDI_CDC_PORT_NB < 1) || (UDI_CDC_PORT_NB > 7)
52 # error UDI_CDC_PORT_NB must be between 1 and 7
53 #endif
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
68 
77 
84 typedef struct {
98 
99 
106 typedef struct {
113 
114 
116 #define UDI_CDC_COMM_EP_SIZE 64
117 #define UDI_CDC_DATA_EPS_FS_SIZE 64
119 #define UDI_CDC_DATA_EPS_HS_SIZE 512
121 
127 #ifndef UDI_CDC_IAD_STRING_ID_0
129 #define UDI_CDC_IAD_STRING_ID_0 0
130 #endif
131 #ifndef UDI_CDC_COMM_STRING_ID_0
132 #define UDI_CDC_COMM_STRING_ID_0 0
133 #endif
134 #ifndef UDI_CDC_DATA_STRING_ID_0
135 #define UDI_CDC_DATA_STRING_ID_0 0
136 #endif
137 #define UDI_CDC_IAD_DESC_0 UDI_CDC_IAD_DESC(0)
138 #define UDI_CDC_COMM_DESC_0 UDI_CDC_COMM_DESC(0)
139 #define UDI_CDC_DATA_DESC_0_FS UDI_CDC_DATA_DESC_FS(0)
140 #define UDI_CDC_DATA_DESC_0_HS UDI_CDC_DATA_DESC_HS(0)
141 
143 #ifndef UDI_CDC_IAD_STRING_ID_1
144 #define UDI_CDC_IAD_STRING_ID_1 0
145 #endif
146 #ifndef UDI_CDC_COMM_STRING_ID_1
147 #define UDI_CDC_COMM_STRING_ID_1 0
148 #endif
149 #ifndef UDI_CDC_DATA_STRING_ID_1
150 #define UDI_CDC_DATA_STRING_ID_1 0
151 #endif
152 #define UDI_CDC_IAD_DESC_1 UDI_CDC_IAD_DESC(1)
153 #define UDI_CDC_COMM_DESC_1 UDI_CDC_COMM_DESC(1)
154 #define UDI_CDC_DATA_DESC_1_FS UDI_CDC_DATA_DESC_FS(1)
155 #define UDI_CDC_DATA_DESC_1_HS UDI_CDC_DATA_DESC_HS(1)
156 
158 #ifndef UDI_CDC_IAD_STRING_ID_2
159 #define UDI_CDC_IAD_STRING_ID_2 0
160 #endif
161 #ifndef UDI_CDC_COMM_STRING_ID_2
162 #define UDI_CDC_COMM_STRING_ID_2 0
163 #endif
164 #ifndef UDI_CDC_DATA_STRING_ID_2
165 #define UDI_CDC_DATA_STRING_ID_2 0
166 #endif
167 #define UDI_CDC_IAD_DESC_2 UDI_CDC_IAD_DESC(2)
168 #define UDI_CDC_COMM_DESC_2 UDI_CDC_COMM_DESC(2)
169 #define UDI_CDC_DATA_DESC_2_FS UDI_CDC_DATA_DESC_FS(2)
170 #define UDI_CDC_DATA_DESC_2_HS UDI_CDC_DATA_DESC_HS(2)
171 
173 #ifndef UDI_CDC_IAD_STRING_ID_3
174 #define UDI_CDC_IAD_STRING_ID_3 0
175 #endif
176 #ifndef UDI_CDC_COMM_STRING_ID_3
177 #define UDI_CDC_COMM_STRING_ID_3 0
178 #endif
179 #ifndef UDI_CDC_DATA_STRING_ID_3
180 #define UDI_CDC_DATA_STRING_ID_3 0
181 #endif
182 #define UDI_CDC_IAD_DESC_3 UDI_CDC_IAD_DESC(3)
183 #define UDI_CDC_COMM_DESC_3 UDI_CDC_COMM_DESC(3)
184 #define UDI_CDC_DATA_DESC_3_FS UDI_CDC_DATA_DESC_FS(3)
185 #define UDI_CDC_DATA_DESC_3_HS UDI_CDC_DATA_DESC_HS(3)
186 
188 #ifndef UDI_CDC_IAD_STRING_ID_4
189 #define UDI_CDC_IAD_STRING_ID_4 0
190 #endif
191 #ifndef UDI_CDC_COMM_STRING_ID_4
192 #define UDI_CDC_COMM_STRING_ID_4 0
193 #endif
194 #ifndef UDI_CDC_DATA_STRING_ID_4
195 #define UDI_CDC_DATA_STRING_ID_4 0
196 #endif
197 #define UDI_CDC_IAD_DESC_4 UDI_CDC_IAD_DESC(4)
198 #define UDI_CDC_COMM_DESC_4 UDI_CDC_COMM_DESC(4)
199 #define UDI_CDC_DATA_DESC_4_FS UDI_CDC_DATA_DESC_FS(4)
200 #define UDI_CDC_DATA_DESC_4_HS UDI_CDC_DATA_DESC_HS(4)
201 
203 #ifndef UDI_CDC_IAD_STRING_ID_5
204 #define UDI_CDC_IAD_STRING_ID_5 0
205 #endif
206 #ifndef UDI_CDC_COMM_STRING_ID_5
207 #define UDI_CDC_COMM_STRING_ID_5 0
208 #endif
209 #ifndef UDI_CDC_DATA_STRING_ID_5
210 #define UDI_CDC_DATA_STRING_ID_5 0
211 #endif
212 #define UDI_CDC_IAD_DESC_5 UDI_CDC_IAD_DESC(5)
213 #define UDI_CDC_COMM_DESC_5 UDI_CDC_COMM_DESC(5)
214 #define UDI_CDC_DATA_DESC_5_FS UDI_CDC_DATA_DESC_FS(5)
215 #define UDI_CDC_DATA_DESC_5_HS UDI_CDC_DATA_DESC_HS(5)
216 
218 #ifndef UDI_CDC_IAD_STRING_ID_6
219 #define UDI_CDC_IAD_STRING_ID_6 0
220 #endif
221 #ifndef UDI_CDC_COMM_STRING_ID_6
222 #define UDI_CDC_COMM_STRING_ID_6 0
223 #endif
224 #ifndef UDI_CDC_DATA_STRING_ID_6
225 #define UDI_CDC_DATA_STRING_ID_6 0
226 #endif
227 #define UDI_CDC_IAD_DESC_6 UDI_CDC_IAD_DESC(6)
228 #define UDI_CDC_COMM_DESC_6 UDI_CDC_COMM_DESC(6)
229 #define UDI_CDC_DATA_DESC_6_FS UDI_CDC_DATA_DESC_FS(6)
230 #define UDI_CDC_DATA_DESC_6_HS UDI_CDC_DATA_DESC_HS(6)
231 
232 
233 
235 #define UDI_CDC_IAD_DESC(port) { \
236  .bLength = sizeof(usb_iad_desc_t),\
237  .bDescriptorType = USB_DT_IAD,\
238  .bInterfaceCount = 2,\
239  .bFunctionClass = CDC_CLASS_COMM,\
240  .bFunctionSubClass = CDC_SUBCLASS_ACM,\
241  .bFunctionProtocol = CDC_PROTOCOL_V25TER,\
242  .bFirstInterface = UDI_CDC_COMM_IFACE_NUMBER_##port,\
243  .iFunction = UDI_CDC_IAD_STRING_ID_##port,\
244  }
245 
247 #define UDI_CDC_COMM_DESC(port) { \
248  .iface.bLength = sizeof(usb_iface_desc_t),\
249  .iface.bDescriptorType = USB_DT_INTERFACE,\
250  .iface.bAlternateSetting = 0,\
251  .iface.bNumEndpoints = 1,\
252  .iface.bInterfaceClass = CDC_CLASS_COMM,\
253  .iface.bInterfaceSubClass = CDC_SUBCLASS_ACM,\
254  .iface.bInterfaceProtocol = CDC_PROTOCOL_V25TER,\
255  .header.bFunctionLength = sizeof(usb_cdc_hdr_desc_t),\
256  .header.bDescriptorType = CDC_CS_INTERFACE,\
257  .header.bDescriptorSubtype = CDC_SCS_HEADER,\
258  .header.bcdCDC = LE16(0x0110),\
259  .call_mgmt.bFunctionLength = sizeof(usb_cdc_call_mgmt_desc_t),\
260  .call_mgmt.bDescriptorType = CDC_CS_INTERFACE,\
261  .call_mgmt.bDescriptorSubtype = CDC_SCS_CALL_MGMT,\
262  .call_mgmt.bmCapabilities = \
263  CDC_CALL_MGMT_SUPPORTED | CDC_CALL_MGMT_OVER_DCI,\
264  .acm.bFunctionLength = sizeof(usb_cdc_acm_desc_t),\
265  .acm.bDescriptorType = CDC_CS_INTERFACE,\
266  .acm.bDescriptorSubtype = CDC_SCS_ACM,\
267  .acm.bmCapabilities = CDC_ACM_SUPPORT_LINE_REQUESTS,\
268  .union_desc.bFunctionLength = sizeof(usb_cdc_union_desc_t),\
269  .union_desc.bDescriptorType = CDC_CS_INTERFACE,\
270  .union_desc.bDescriptorSubtype= CDC_SCS_UNION,\
271  .ep_notify.bLength = sizeof(usb_ep_desc_t),\
272  .ep_notify.bDescriptorType = USB_DT_ENDPOINT,\
273  .ep_notify.bmAttributes = USB_EP_TYPE_INTERRUPT,\
274  .ep_notify.wMaxPacketSize = LE16(UDI_CDC_COMM_EP_SIZE),\
275  .ep_notify.bInterval = 0x10,\
276  .ep_notify.bEndpointAddress = UDI_CDC_COMM_EP_##port,\
277  .iface.bInterfaceNumber = UDI_CDC_COMM_IFACE_NUMBER_##port,\
278  .call_mgmt.bDataInterface = UDI_CDC_DATA_IFACE_NUMBER_##port,\
279  .union_desc.bMasterInterface = UDI_CDC_COMM_IFACE_NUMBER_##port,\
280  .union_desc.bSlaveInterface0 = UDI_CDC_DATA_IFACE_NUMBER_##port,\
281  .iface.iInterface = UDI_CDC_COMM_STRING_ID_##port,\
282  }
283 
285 #define UDI_CDC_DATA_DESC_COMMON \
286  .iface.bLength = sizeof(usb_iface_desc_t),\
287  .iface.bDescriptorType = USB_DT_INTERFACE,\
288  .iface.bAlternateSetting = 0,\
289  .iface.bNumEndpoints = 2,\
290  .iface.bInterfaceClass = CDC_CLASS_DATA,\
291  .iface.bInterfaceSubClass = 0,\
292  .iface.bInterfaceProtocol = 0,\
293  .ep_in.bLength = sizeof(usb_ep_desc_t),\
294  .ep_in.bDescriptorType = USB_DT_ENDPOINT,\
295  .ep_in.bmAttributes = USB_EP_TYPE_BULK,\
296  .ep_in.bInterval = 0,\
297  .ep_out.bLength = sizeof(usb_ep_desc_t),\
298  .ep_out.bDescriptorType = USB_DT_ENDPOINT,\
299  .ep_out.bmAttributes = USB_EP_TYPE_BULK,\
300  .ep_out.bInterval = 0,
301 
302 #define UDI_CDC_DATA_DESC_FS(port) { \
303  UDI_CDC_DATA_DESC_COMMON \
304  .ep_in.wMaxPacketSize = LE16(UDI_CDC_DATA_EPS_FS_SIZE),\
305  .ep_out.wMaxPacketSize = LE16(UDI_CDC_DATA_EPS_FS_SIZE),\
306  .ep_in.bEndpointAddress = UDI_CDC_DATA_EP_IN_##port,\
307  .ep_out.bEndpointAddress = UDI_CDC_DATA_EP_OUT_##port,\
308  .iface.bInterfaceNumber = UDI_CDC_DATA_IFACE_NUMBER_##port,\
309  .iface.iInterface = UDI_CDC_DATA_STRING_ID_##port,\
310  }
311 
312 #define UDI_CDC_DATA_DESC_HS(port) { \
313  UDI_CDC_DATA_DESC_COMMON \
314  .ep_in.wMaxPacketSize = LE16(UDI_CDC_DATA_EPS_HS_SIZE),\
315  .ep_out.wMaxPacketSize = LE16(UDI_CDC_DATA_EPS_HS_SIZE),\
316  .ep_in.bEndpointAddress = UDI_CDC_DATA_EP_IN_##port,\
317  .ep_out.bEndpointAddress = UDI_CDC_DATA_EP_OUT_##port,\
318  .iface.bInterfaceNumber = UDI_CDC_DATA_IFACE_NUMBER_##port,\
319  .iface.iInterface = UDI_CDC_DATA_STRING_ID_##port,\
320  }
321 
323 
341 
347 void udi_cdc_ctrl_signal_dcd(bool b_set);
348 
354 void udi_cdc_ctrl_signal_dsr(bool b_set);
355 
360 
364 void udi_cdc_signal_parity_error(void);
365 
369 void udi_cdc_signal_overrun(void);
370 
377 
383 bool udi_cdc_is_rx_ready(void);
384 
390 int udi_cdc_getc(void);
391 
400 iram_size_t udi_cdc_read_buf(void* buf, iram_size_t size);
401 
412 
419 
426 bool udi_cdc_is_tx_ready(void);
427 
436 int udi_cdc_putc(int value);
437 
446 iram_size_t udi_cdc_write_buf(const void* buf, iram_size_t size);
448 
453 
460 void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set);
461 
468 void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set);
469 
475 void udi_cdc_multi_signal_framing_error(uint8_t port);
476 
482 void udi_cdc_multi_signal_parity_error(uint8_t port);
483 
489 void udi_cdc_multi_signal_overrun(uint8_t port);
490 
499 
507 bool udi_cdc_multi_is_rx_ready(uint8_t port);
508 
516 int udi_cdc_multi_getc(uint8_t port);
517 
527 iram_size_t udi_cdc_multi_read_buf(uint8_t port, void* buf, iram_size_t size);
528 
537 
546 bool udi_cdc_multi_is_tx_ready(uint8_t port);
547 
557 int udi_cdc_multi_putc(uint8_t port, int value);
558 
568 iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t size);
570 
572 
797 #ifdef __cplusplus
798 }
799 #endif
800 #endif // _UDI_CDC_H_
Communication Class interface descriptor.
Definition: udi_cdc.h:84
void udi_cdc_ctrl_signal_dsr(bool b_set)
Notify a state change of DSR signal.
Definition: udi_cdc.c:786
void udi_cdc_ctrl_signal_dcd(bool b_set)
Notify a state change of DCD signal.
Definition: udi_cdc.c:781
Common API for USB Device Interface.
Common API for USB Device Drivers (UDD)
USB configuration file for CDC application.
bool udi_cdc_is_tx_ready(void)
This function checks if a new character sent is possible The type int is used to support scanf redire...
Definition: udi_cdc.c:1045
int udi_cdc_multi_putc(uint8_t port, int value)
Puts a byte on CDC line The type int is used to support printf redirection from compiler LIB...
Definition: udi_cdc.c:1050
usb_iface_desc_t iface
Standard interface descriptor.
Definition: udi_cdc.h:86
USB protocol definitions.
usb_cdc_acm_desc_t acm
CDC Abstract Control Model functional descriptor.
Definition: udi_cdc.h:90
Common API for USB Device Interface.
void udi_cdc_signal_parity_error(void)
Notify a parity error.
Definition: udi_cdc.c:796
Data Class interface descriptor.
Definition: udi_cdc.h:106
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:3589
void udi_cdc_signal_overrun(void)
Notify a overrun.
Definition: udi_cdc.c:801
void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set)
Notify a state change of DSR signal.
Definition: udi_cdc.c:811
iram_size_t udi_cdc_multi_read_buf(uint8_t port, void *buf, iram_size_t size)
Reads a RAM buffer on CDC line.
Definition: udi_cdc.c:911
void udi_cdc_multi_signal_parity_error(uint8_t port)
Notify a parity error.
Definition: udi_cdc.c:821
iram_size_t udi_cdc_get_nb_received_data(void)
Gets the number of byte received.
Definition: udi_cdc.c:847
iram_size_t udi_cdc_get_free_tx_buffer(void)
Gets the number of free byte in TX buffer.
Definition: udi_cdc.c:1035
UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm
Global structure which contains standard UDI API for UDC.
Definition: udi_cdc.c:86
iram_size_t udi_cdc_write_buf(const void *buf, iram_size_t size)
Writes a RAM buffer on CDC line.
Definition: udi_cdc.c:1146
iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void *buf, iram_size_t size)
Writes a RAM buffer on CDC line.
Definition: udi_cdc.c:1091
bool udi_cdc_multi_is_tx_ready(uint8_t port)
This function checks if a new character sent is possible The type int is used to support scanf redire...
Definition: udi_cdc.c:1040
UDC_DESC_STORAGE udi_api_t udi_api_cdc_data
Definition: udi_cdc.c:92
usb_iface_desc_t iface
Standard interface descriptor.
Definition: udi_cdc.h:108
bool udi_cdc_is_rx_ready(void)
This function checks if a character has been received on the CDC line.
Definition: udi_cdc.c:857
iram_size_t udi_cdc_read_no_polling(void *buf, iram_size_t size)
Non polling reads of a up to &#39;size&#39; data from CDC line.
Definition: udi_cdc.c:996
usb_ep_desc_t ep_out
Definition: udi_cdc.h:111
UDI API.
Definition: udi.h:64
CDC Call Management Functional Descriptor.
Standard USB interface descriptor structure.
Definition: usb_protocol.h:446
usb_ep_desc_t ep_notify
Notification endpoint descriptor.
Definition: udi_cdc.h:96
CDC Union Functional Descriptor.
int udi_cdc_getc(void)
Waits and gets a value on CDC line.
Definition: udi_cdc.c:906
bool udi_cdc_multi_is_rx_ready(uint8_t port)
This function checks if a character has been received on the CDC line.
Definition: udi_cdc.c:852
iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port)
Gets the number of byte received.
Definition: udi_cdc.c:831
usb_cdc_hdr_desc_t header
CDC Header functional descriptor.
Definition: udi_cdc.h:88
uint32_t iram_size_t
Definition: compiler.h:260
int udi_cdc_multi_getc(uint8_t port)
Waits and gets a value on CDC line.
Definition: udi_cdc.c:862
Standard USB endpoint descriptor structure.
Definition: usb_protocol.h:461
void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set)
Notify a state change of DCD signal.
Definition: udi_cdc.c:806
usb_cdc_union_desc_t union_desc
CDC Union functional descriptor.
Definition: udi_cdc.h:92
#define UDC_DESC_STORAGE
Defines the memory&#39;s location of USB descriptors.
Definition: udc_desc.h:70
iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port)
Gets the number of free byte in TX buffer.
Definition: udi_cdc.c:1006
void udi_cdc_signal_framing_error(void)
Notify a framing error.
Definition: udi_cdc.c:791
usb_cdc_call_mgmt_desc_t call_mgmt
CDC Call Management functional descriptor.
Definition: udi_cdc.h:94
usb_ep_desc_t ep_in
Data IN/OUT endpoint descriptors.
Definition: udi_cdc.h:110
USB Communication Device Class (CDC) protocol definitions.
CDC Header Functional Descriptor.
int udi_cdc_putc(int value)
Puts a byte on CDC line The type int is used to support printf redirection from compiler LIB...
Definition: udi_cdc.c:1086
iram_size_t udi_cdc_read_buf(void *buf, iram_size_t size)
Reads a RAM buffer on CDC line.
Definition: udi_cdc.c:1001
void udi_cdc_multi_signal_framing_error(uint8_t port)
Notify a framing error.
Definition: udi_cdc.c:816
CDC ACM Functional Descriptor.
void udi_cdc_multi_signal_overrun(uint8_t port)
Notify a overrun.
Definition: udi_cdc.c:826


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