VSF Documented
vsf_usbd_hidmsc.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_HIDMSC_H__
19#define __VSF_USBD_HIDMSC_H__
20
21/*============================ INCLUDES ======================================*/
22
24
25#if VSF_USE_USB_DEVICE == ENABLED && VSF_USBD_USE_HID == ENABLED && VSF_USBD_USE_MSC == ENABLED
26
27#include "../MSC/vsf_usbd_MSC.h"
28
29#if defined(__VSF_USBD_HIDMSC_CLASS_IMPLEMENT)
30# undef __VSF_USBD_HIDMSC_CLASS_IMPLEMENT
31# define __VSF_CLASS_IMPLEMENT__
32#endif
33#include "utilities/ooc_class.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*============================ MACROS ========================================*/
40
41#if VSF_USBD_CFG_STREAM_EN != ENABLED
42# error hidmsc need stream
43#endif
44
45
46
47#define __USB_HIDMSC_REPORT_DESC_SIZE 29
48
49#define USB_HIDMSC_PARAM(__INT_IN_EP, __INT_OUT_EP, __SCSI_DEV, __STREAM) \
50 .msc = { \
51 .ep_out = (__INT_OUT_EP), \
52 .ep_in = (__INT_IN_EP), \
53 .scsi = (__SCSI_DEV), \
54 .stream = (__STREAM), \
55 },
56
57#define USB_HIDMSC_IFS_NUM USB_HID_IFS_NUM
58#define USB_DESC_HIDMSC_LEN USB_DESC_HID_LEN
59#define USB_DESC_HIDMSC_IAD_LEN USB_DESC_HID_IAD_LEN
60#define USB_HIDMSC_IFS(__PARAM)USB_IFS(&vk_usbd_hidmsc, &(__PARAM))
61
62
63#define __usbd_hidmsc_desc(__name, __ifs, __i_func, __bulk_in_ep, __bulk_out_ep, __bulk_ep_size)\
64 USB_DESC_MSCBOT((__ifs), 4 + (__i_func), (__bulk_in_ep), (__bulk_out_ep), (__bulk_ep_size))
65#define __usbd_hidmsc_desc_iad(__name, __ifs, __i_func, __bulk_in_ep, __bulk_out_ep, __bulk_ep_size)\
66 USB_DESC_MSCBOT_IAD((__ifs), 4 + (__i_func), (__bulk_in_ep), (__bulk_out_ep), (__bulk_ep_size))
67
68#define __usbd_hidmsc_func(__name, __func_id, __int_in_ep, __int_out_ep, __scsi_dev, __stream)\
69 vk_usbd_hidmsc_t __##__name##_hidmsc##__func_id = { \
70 USB_HIDMSC_PARAM((__int_in_ep), (__int_out_ep), (__scsi_dev), (__stream))\
71 };
72
73#define __usbd_hidmsc_ifs(__name, __func_id) \
74 USB_HIDMSC_IFS(__##__name##_hidmsc##__func_id)
75
76#define usbd_hidmsc_desc(__name, __ifs, __i_func, __int_in_ep, __int_out_ep) \
77 usbd_hid_desc(__name, (__ifs), (__i_func), 0, 0, 0x0111, 0, __USB_HIDMSC_REPORT_DESC_SIZE, (__int_in_ep), 512, 1, (__int_out_ep), 512, 1)
78#define usbd_hidmsc_desc_iad(__name, __ifs, __i_func, __int_in_ep, __int_out_ep)\
79 usbd_hid_desc_iad(__name, (__ifs), (__i_func), 0, 0, 0x0111, 0, __USB_HIDMSC_REPORT_DESC_SIZE, (__int_in_ep), 512, 1, (__int_out_ep), 512, 1)
80#define usbd_hidmsc_func(__name, __func_id, __int_in_ep, __int_out_ep, __scsi_dev, __stream)\
81 __usbd_hidmsc_func(__name, __func_id, (__int_in_ep), (__int_out_ep), (__scsi_dev), (__stream))
82#define usbd_hidmsc_ifs(__name, __func_id) \
83 __usbd_hidmsc_ifs(__name, __func_id)
84
85/*============================ MACROFIED FUNCTIONS ===========================*/
86/*============================ TYPES =========================================*/
87
89 public_member(
90 implement(vk_usbd_hid_t)
91 vk_usbd_msc_t msc;
92 )
93 protected_member(
94 vk_usbd_ifs_t msc_ifs;
95 )
96};
97
98/*============================ GLOBAL VARIABLES ==============================*/
99
100extern const vk_usbd_class_op_t vk_usbd_hidmsc;
101
102/*============================ PROTOTYPES ====================================*/
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif // VSF_USE_USB_DEVICE && VSF_USBD_USE_HID && VSF_USBD_USE_MSC
109#endif // __VSF_USBD_HIDMSC_H__
Definition vsf_usbd_HID.h:162
Definition vsf_usbd_hidmsc.h:88
Definition vsf_usbd_MSC.h:132
#define vsf_class(__name)
Definition ooc_class.h:48
const vk_usbd_class_op_t vk_usbd_hidmsc
Definition vsf_usbd_hidmsc.c:46