VSF Documented
vsf_usbd_CDC.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_CDC_H__
19#define __VSF_USBD_CDC_H__
20
21/*============================ INCLUDES ======================================*/
22
24
25#if VSF_USE_USB_DEVICE == ENABLED && VSF_USBD_USE_CDC == ENABLED
26
28
29#if defined(__VSF_USBD_CDC_CLASS_IMPLEMENT)
30# undef __VSF_USBD_CDC_CLASS_IMPLEMENT
31# define __VSF_CLASS_IMPLEMENT__
32#elif defined(__VSF_USBD_CDC_CLASS_INHERIT__)
33# undef __VSF_USBD_CDC_CLASS_INHERIT__
34# define __VSF_CLASS_INHERIT__
35#endif
36#include "utilities/ooc_class.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/*============================ MACROS ========================================*/
43
44#if VSF_USBD_CFG_STREAM_EN != ENABLED
45# error "CDC need VSF_USBD_CFG_STREAM_EN!!!"
46#endif
47
48#define USB_CDC_IFS_NUM 2
49
50/*============================ MACROFIED FUNCTIONS ===========================*/
51/*============================ TYPES =========================================*/
52
54
55typedef union vk_usbd_cdc_ep_t {
56 struct {
60 };
63
68 union {
71 };
72};
73
75
76 public_member(
77 implement_ex(vk_usbd_cdc_ep_t, ep)
78 /*uint8_t ep_notify;
79 uint8_t ep_out;
80 uint8_t ep_in;*/
81
82 struct {
83#if VSF_USE_SIMPLE_STREAM == ENABLED
84 // stream.tx is used for data stream send to USB host
85 // stream.rx is used for data stream receive from USB host
86 vk_usbd_ep_stream_t tx;
87 vk_usbd_ep_stream_t rx;
88#elif VSF_USE_STREAM == ENABLED
89 implement (vk_usbd_ep_stream_t);
90#endif
91 } stream;
92
93 // no need to initialize below if encapsulate command/response is not used
95 )
96};
97
98/*============================ GLOBAL VARIABLES ==============================*/
99
100extern const struct vk_usbd_class_op_t vk_usbd_cdc_control;
101extern const struct vk_usbd_class_op_t vk_usbd_cdc_data;
102
103/*============================ PROTOTYPES ====================================*/
104
105// helper functions
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif // VSF_USE_USB_DEVICE && VSF_USBD_USE_CDC
113#endif // __VSF_USBD_CDC_H__
vsf_err_t
Definition __type.h:42
Definition vsf_usbd_CDC.h:74
#define vsf_dcl_class
Definition ooc_class.h:46
#define vsf_class(__name)
Definition ooc_class.h:48
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_usbd_CDC.h:65
vsf_err_t(* on_resp)(vk_usbd_cdc_encapsulate_t *resp)
Definition vsf_usbd_CDC.h:70
uint32_t size
Definition vsf_usbd_CDC.h:67
vsf_err_t(* on_cmd)(vk_usbd_cdc_encapsulate_t *cmd)
Definition vsf_usbd_CDC.h:69
uint8_t * buffer
Definition vsf_usbd_CDC.h:66
Definition vsf_usbd_CDC.h:55
uint32_t ep_cfg
Definition vsf_usbd_CDC.h:61
uint8_t in
Definition vsf_usbd_CDC.h:59
uint8_t out
Definition vsf_usbd_CDC.h:58
uint8_t notify
Definition vsf_usbd_CDC.h:57
void vk_usbd_cdc_data_connect(vk_usbd_cdc_t *cdc)
const struct vk_usbd_class_op_t vk_usbd_cdc_control
const struct vk_usbd_class_op_t vk_usbd_cdc_data