VSF Documented
vsf_usbd_CDCACM_desc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_USBD_CDCACM_DESC_H__
19#define __VSF_USBD_CDCACM_DESC_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26/*============================ MACROS ========================================*/
27
28// __IFS_START + 0: Control interface
29// __IFS_START + 1: Data interface
30// __INT_EP_INTERVAL: HS 0x10, otherwise 0xFF
31#define USB_DESC_CDC_ACM(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL)\
32 USB_DESC_IFS((__IFS_START), 0, 1, USB_CLASS_COMM, 0x02, 0x01, (__I_FUNC))\
33 /* Header Functional Descriptor */\
34 0x05, /* bLength: Endpoint Descriptor size */\
35 0x24, /* bDescriptorType: CS_INTERFACE */\
36 0x00, /* bDescriptorSubtype: Header Func Desc */\
37 USB_DESC_WORD(0x0110), /* bcdCDC: spec release number */\
38 /* Call Management Functional Descriptor */\
39 0x05, /* bFunctionLength */\
40 0x24, /* bDescriptorType: CS_INTERFACE */\
41 0x01, /* bDescriptorSubtype: Call Management Func Desc */\
42 0x00, /* bmCapabilities: D0+D1 */ \
43 0x01, /* bDataInterface: 1 */ \
44 /* ACM Functional Descriptor */ \
45 0x04, /* bFunctionLength */ \
46 0x24, /* bDescriptorType: CS_INTERFACE */\
47 0x02, /* bDescriptorSubtype: Abstract Control Management desc */\
48 0x02, /* bmCapabilities */\
49 /* Union Functional Descriptor */\
50 0x05, /* bFunctionLength */ \
51 0x24, /* bDescriptorType: CS_INTERFACE */\
52 0x06, /* bDescriptorSubtype: Union func desc */\
53 (__IFS_START), /* bMasterInterface: Communication class interface */\
54 1 + (__IFS_START), /* bSlaveInterface0: Data Class Interface */\
55 \
56 USB_DESC_EP(USB_DIR_IN | (__INT_IN_EP), USB_ENDPOINT_XFER_INT, 8, (__INT_EP_INTERVAL))\
57 USB_DESC_IFS((__IFS_START) + 1, 0, 2, USB_CLASS_CDC_DATA, 0x00, 0x00, (__I_FUNC))\
58 USB_DESC_EP(USB_DIR_IN | (__BULK_IN_EP), USB_ENDPOINT_XFER_BULK, (__BULK_EP_SIZE), 0x00)\
59 USB_DESC_EP(USB_DIR_OUT | (__BULK_OUT_EP), USB_ENDPOINT_XFER_BULK, (__BULK_EP_SIZE), 0x00)
60#define USB_DESC_CDC_ACM_LEN \
61 ( USB_DT_INTERFACE_SIZE + 5 + 5 + 4 + 5 + USB_DT_ENDPOINT_SIZE + \
62 USB_DT_INTERFACE_SIZE + 2 * USB_DT_ENDPOINT_SIZE)
63
64#define USB_DESC_CDC_ACM_IAD(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL)\
65 USB_DESC_IAD((__IFS_START), 2, USB_CLASS_COMM, 0x02, 0x01, (__I_FUNC))\
66 USB_DESC_CDC_ACM((__IFS_START), (__I_FUNC), (__INT_IN_EP), (__BULK_IN_EP), (__BULK_OUT_EP), (__BULK_EP_SIZE), (__INT_EP_INTERVAL))
67#define USB_DESC_CDC_ACM_IAD_LEN (USB_DESC_IAD_LEN + USB_DESC_CDC_ACM_LEN)
68
69#define USB_DESC_CDC_UART_HS(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP)\
70 USB_DESC_CDC_ACM((__IFS_START), (__I_FUNC), (__INT_IN_EP), (__BULK_IN_EP), (__BULK_OUT_EP), 512, 0x10)
71#define USB_DESC_CDC_UART_FS(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP)\
72 USB_DESC_CDC_ACM((__IFS_START), (__I_FUNC), (__INT_IN_EP), (__BULK_IN_EP), (__BULK_OUT_EP), 64, 0xFF)
73#define USB_DESC_CDC_UART_HS_IAD(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP)\
74 USB_DESC_CDC_ACM_IAD((__IFS_START), (__I_FUNC), (__INT_IN_EP), (__BULK_IN_EP), (__BULK_OUT_EP), 512, 0x10)
75#define USB_DESC_CDC_UART_FS_IAD(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP)\
76 USB_DESC_CDC_ACM_IAD((__IFS_START), (__I_FUNC), (__INT_IN_EP), (__BULK_IN_EP), (__BULK_OUT_EP), 64, 0xFF)
77
78/*============================ MACROFIED FUNCTIONS ===========================*/
79/*============================ TYPES =========================================*/
80/*============================ GLOBAL VARIABLES ==============================*/
81/*============================ PROTOTYPES ====================================*/
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif // __VSF_USBD_CDCACM_DESC_H__