VSF Documented
vsf_usbd_CDCNCM_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_CDCNCM_DESC_H__
19#define __VSF_USBD_CDCNCM_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
32#define USB_DESC_CDC_NCM3(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
33 __I_MAC, __MAX_SEG_SIZE, __NETWORK_CAPABILITIES, __MC_FITER_NUM, __PWR_FILTER_NUM)\
34 USB_DESC_IFS((__IFS_START), 0, 1, USB_CLASS_COMM, 0x0D, 0x00, (__I_FUNC))\
35 /* Header Functional Descriptor */\
36 0x05, /* bLength: Endpoint Descriptor size */\
37 0x24, /* bDescriptorType: CS_INTERFACE */\
38 0x00, /* bDescriptorSubtype: Header Func Desc */\
39 USB_DESC_WORD(0x0110), /* bcdCDC: spec release number */\
40 /* Union Functional Descriptor */\
41 0x05, /* bFunctionLength */ \
42 0x24, /* bDescriptorType: CS_INTERFACE */\
43 0x06, /* bDescriptorSubtype: Union func desc */\
44 (__IFS_START), /* bMasterInterface: Communication class interface */\
45 1 + (__IFS_START), /* bSlaveInterface0: Data Class Interface */\
46 /* CDC Ethernet Networking Functional Descriptor */\
47 0x0D, /* bFunctionLength */ \
48 0x24, /* bDescriptorType: CS_INTERFACE */\
49 0x0F, /* bDescriptorSubtype: Ethernet Networking functional descriptor */\
50 (__I_MAC), /* iMACAddress */ \
51 USB_DESC_DWORD(0), /* bmEthernetStatistics */ \
52 USB_DESC_WORD(__MAX_SEG_SIZE), /* WmAXsEGMENTsIZE */ \
53 USB_DESC_WORD(__MC_FITER_NUM), /* WnUMBERmcfILTERS */ \
54 (__PWR_FILTER_NUM), /* BnUMBERpOWERfILTERS */ \
55 /* NCM Functional Descriptor */ \
56 0x06, /* bFunctionLength */ \
57 0x24, /* bDescriptorType: CS_INTERFACE */\
58 0x1A, /* bDescriptorSubtype: NCM Function Descriptor */\
59 USB_DESC_WORD(0x0100), /* bcdNcmVersion: 1.00 */ \
60 (__NETWORK_CAPABILITIES), /* bmNetworkCapabilities */ \
61 \
62 USB_DESC_EP(USB_DIR_IN | (__INT_IN_EP), USB_ENDPOINT_XFER_INT, 16, (__INT_EP_INTERVAL))\
63 USB_DESC_IFS((__IFS_START) + 1, 0, 0, USB_CLASS_CDC_DATA, 0x00, 0x01, (__I_FUNC))\
64 USB_DESC_IFS((__IFS_START) + 1, 1, 2, USB_CLASS_CDC_DATA, 0x00, 0x01, (__I_FUNC))\
65 USB_DESC_EP(USB_DIR_IN | (__BULK_IN_EP), USB_ENDPOINT_XFER_BULK, (__BULK_EP_SIZE), 0x00)\
66 USB_DESC_EP(USB_DIR_OUT | (__BULK_OUT_EP), USB_ENDPOINT_XFER_BULK, (__BULK_EP_SIZE), 0x00)
67#define USB_DESC_CDC_NCM2(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
68 __I_MAC, __MAX_SEG_SIZE, __NETWORK_CAPABILITIES, __MC_FITER_NUM) \
69 USB_DESC_CDC_NCM3(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
70 __I_MAC, __MAX_SEG_SIZE, __NETWORK_CAPABILITIES, __MC_FITER_NUM, 0)
71#define USB_DESC_CDC_NCM1(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
72 __I_MAC, __MAX_SEG_SIZE, __NETWORK_CAPABILITIES) \
73 USB_DESC_CDC_NCM2(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
74 __I_MAC, __MAX_SEG_SIZE, __NETWORK_CAPABILITIES, 0)
75#define USB_DESC_CDC_NCM0(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
76 __I_MAC, __MAX_SEG_SIZE) \
77 USB_DESC_CDC_NCM1(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
78 __I_MAC, __MAX_SEG_SIZE, 0)
79
80// prototype: USB_DESC_CDC_NCM(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,
81// __I_MAC, __MAX_SEG_SIZE, __NETWORK_CAPABILITIES = 0, __MC_FITER_NUM = 0, __PWR_FILTER_NUM = 0)
82#define USB_DESC_CDC_NCM(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
83 __I_MAC, __MAX_SEG_SIZE, ...) \
84 __PLOOC_EVAL(USB_DESC_CDC_NCM, __VA_ARGS__) \
85 (__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
86 __I_MAC, __MAX_SEG_SIZE, ##__VA_ARGS__)
87#define USB_DESC_CDC_NCM_LEN \
88 ( USB_DT_INTERFACE_SIZE + 5 + 5 + 13 + 6 + USB_DT_ENDPOINT_SIZE + \
89 2 * USB_DT_INTERFACE_SIZE + 2 * USB_DT_ENDPOINT_SIZE)
90
91#define USB_DESC_CDC_NCM_IAD(__IFS_START, __I_FUNC, __INT_IN_EP, __BULK_IN_EP, __BULK_OUT_EP, __BULK_EP_SIZE, __INT_EP_INTERVAL,\
92 __I_MAC, ...) \
93 USB_DESC_IAD((__IFS_START), 2, USB_CLASS_COMM, 0x0D, 0x00, (__I_FUNC))\
94 USB_DESC_CDC_NCM((__IFS_START), (__I_FUNC), (__INT_IN_EP), (__BULK_IN_EP), (__BULK_OUT_EP), (__BULK_EP_SIZE), (__INT_EP_INTERVAL),\
95 __I_MAC, ##__VA_ARGS__)
96#define USB_DESC_CDC_NCM_IAD_LEN (USB_DESC_IAD_LEN + USB_DESC_CDC_NCM_LEN)
97
98/*============================ MACROFIED FUNCTIONS ===========================*/
99/*============================ TYPES =========================================*/
100/*============================ GLOBAL VARIABLES ==============================*/
101/*============================ PROTOTYPES ====================================*/
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif // __VSF_USBD_CDCNCM_DESC_H__