VSF Documented
usb.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 __HAL_DRIVER_${SERIES}_USB_H__
19#define __HAL_DRIVER_${SERIES}_USB_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_USBD == ENABLED || VSF_HAL_USE_USBH == ENABLED
26
27// for basic types/structures/compilers etc
29
30#include "../../__device.h"
31#include "./dc/usbd.h"
32#include "./hc/usbh.h"
33
34/*\note Refer to template/README.md for usage cases.
35 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
36 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
37 * For emulated drivers, **** No reimplementation ****.
38 *
39 * This template is designed only for peripheral drivers with host and device functionality.
40 */
41
43
44/*\note Includes CAN ONLY be put here. */
45
46/*\note Use OOC because vsf_hw_usb_t should be open to dc/hc drivers, while should not open to users.
47 */
48
49#if defined(__VSF_HAL_HW_USB_CLASS_IMPLEMENT)
50# define __VSF_CLASS_IMPLEMENT__
51#elif defined(__VSF_HAL_HW_USB_CLASS_INHERIT__)
52# define __VSF_CLASS_INHERIT__
53#endif
54
55#include "utilities/ooc_class.h"
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61/*============================ MACROS ========================================*/
62/*============================ MACROFIED FUNCTIONS ===========================*/
63
64#define __VSF_HW_USB_OTG_DEF(__N, __VALUE) \
65 extern vsf_hw_usb_t VSF_HW_USB_OTG##__N; \
66 static vsf_hw_usb_t USB_DC##__N VSF_CAL_WEAK_ALIAS(VSF_HW_USB_OTG##__N, USB_DC##__N);\
67 extern const i_usb_dc_t VSF_USB_DC##__N;
68
69#define _VSF_HW_USB_OTG_DEF(__N, __VALUE) __VSF_HW_USB_OTG_DEF(__N, __VALUE)
70#define VSF_HW_USB_OTG_DEF(__N, __VALUE) _VSF_HW_USB_OTG_DEF(__N, __VALUE)
71
72/*============================ TYPES =========================================*/
73
75 protected_member(
77 bool is_host;
78#endif
79
80/*\note Add hc members to hc structure, dc members to dc structure.
81 */
82
83 IRQn_Type irq;
84 void *reg;
85 union {
86#if VSF_HAL_USE_USBH == ENABLED
87 struct {
88
89 } hc;
90#endif
91#if VSF_HAL_USE_USBD == ENABLED
92 struct {
93 usb_dc_evthandler_t evthandler;
94 void *param;
95 } dc;
96#endif
97 };
98 )
99};
100
101/*============================ INCLUDES ======================================*/
102
103#include "./hc/usbh.h"
104#include "./dc/usbd.h"
105
106/*============================ GLOBAL VARIABLES ==============================*/
107
109
110/*============================ INCLUDES ======================================*/
111/*============================ PROTOTYPES ====================================*/
112
113#if defined(__VSF_HAL_HW_USB_CLASS_IMPLEMENT) || defined(__VSF_HAL_HW_USB_CLASS_INHERIT__)
114// common APIs for both dc and hc driver only, not visible to user
115#endif
116
117#ifdef __cplusplus
118}
119#endif
120
121#undef __VSF_HAL_HW_USB_CLASS_IMPLEMENT
122#undef __VSF_HAL_HW_USB_CLASS_INHERIT__
123
124#endif // VSF_HAL_USE_USBD || VSF_HAL_USE_USBH
125#endif // __HAL_DRIVER_${SERIES}_USB_H__
126/* EOF */
#define ENABLED
Definition __type.h:28
enum IRQn IRQn_Type
#define VSF_HW_USB_OTG_COUNT
Definition device.h:62
#define VSF_HW_USB_OTG_DEF(__N, __VALUE)
Definition usb.h:70
#define NULL
Definition stddef.h:52
#define vsf_class(__name)
Definition ooc_class.h:48
Definition usb.h:53
class vsf_$ * reg
#define VSF_HAL_USE_USBD
Definition vsf_hal_cfg.h:113
#define VSF_HAL_USE_USBH
Definition vsf_hal_cfg.h:117
#define VSF_MREPEAT(__COUNT, __MACRO, __PARAM)
Definition vsf_repeat_macro.h:51
void(* usb_dc_evthandler_t)(void *param, usb_evt_t evt, uint_fast8_t value)
Definition vsf_template_usb.h:309