VSF Documented
vsf_usbd_bos.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_BOS_H__
19#define __VSF_USBD_BOS_H__
20
21/*============================ INCLUDES ======================================*/
22
24
25#if VSF_USE_USB_DEVICE == ENABLED
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/*============================ MACROS ========================================*/
32
33#define USB_DESC_BOS_CAPABILITY_LEN(__LEN) (20 + (__LEN))
34
35#define USB_DESC_BOS_CAPABILITY_HEADER(__LEN, __TYPE, ...) \
36 20 + (__LEN), /* bLength */ \
37 USB_DT_DEVICE_CAPABILITY, /* bDescriptorType */ \
38 (__TYPE), /* bDevCapabilityType */ \
39 0x00, /* bReserved */ \
40 __VA_ARGS__
41
42#define bos_desc_msos20(__len) __bos_desc_msos20(__len)
43
44#define __usbd_bos_desc(__name, __cap_num, __len, ...) \
45 const uint8_t __##__name##_bos_desc[USB_DT_BOS_SIZE + (__len)] = { \
46 USB_DT_BOS_SIZE, \
47 USB_DT_BOS, \
48 USB_DESC_WORD(USB_DT_BOS_SIZE + (__len)), \
49 (__cap_num), \
50 __VA_ARGS__ \
51 };
52
53#define __usbd_bos_desc_table(__name) \
54 {USB_DT_BOS, 0, 0, sizeof(__##__name##_bos_desc), (uint8_t*)(__##__name##_bos_desc)}
55
56#define usbd_bos_desc(__name, __cap_num, __len, ...) \
57 __usbd_bos_desc(__name, __cap_num, __len, __VA_ARGS__)
58#define usbd_bos_desc_table(__name) \
59 __usbd_bos_desc_table(__name)
60
61/*============================ MACROFIED FUNCTIONS ===========================*/
62/*============================ TYPES =========================================*/
63/*============================ GLOBAL VARIABLES ==============================*/
64/*============================ PROTOTYPES ====================================*/
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif // VSF_USE_USB_DEVICE
71#endif // __VSF_USBD_BOS_H__