1 /*********************************************************************************************************//**
2  * @file    ht32f5xxxx_usbdinit.h
3  * @version $Rev:: 5656         $
4  * @date    $Date:: 2021-11-24 #$
5  * @brief   The header file of the USB Device Driver.
6  *************************************************************************************************************
7  * @attention
8  *
9  * Firmware Disclaimer Information
10  *
11  * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
12  *    code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
13  *    proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
14  *    other intellectual property laws.
15  *
16  * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
17  *    code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
18  *    other than HOLTEK and the customer.
19  *
20  * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
21  *    only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
22  *    the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
23  *    the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
24  *
25  * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
26  ************************************************************************************************************/
27 
28 /* Define to prevent recursive inclusion -------------------------------------------------------------------*/
29 #ifndef __HT32F5XXXX_USBDINIT_H
30 #define __HT32F5XXXX_USBDINIT_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 /* Includes ------------------------------------------------------------------------------------------------*/
37 #include "ht32_retarget_usbdconf.h"
38 
39 /** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver
40   * @{
41   */
42 
43 /** @addtogroup USBDevice
44   * @{
45   */
46 
47 
48 /*----------------------------------------------------------------------------------------------------------*/
49 /* Endpoint 0 ~ 7 Configuration                                                                             */
50 /* !!! DO NOT MODIFY !!!                                                                                    */
51 /*----------------------------------------------------------------------------------------------------------*/
52 
53 #define EP_TYPE_ISO         (1)
54 #define EP_TYPE_BULK        (2)
55 #define EP_TYPE_INT         (3)
56 
57 #ifndef _UIER_ALL
58   #define _UIER_ALL _UIER
59 #endif
60 
61 /*----------------------------------------------------------------------------------------------------------*/
62 /* Endpoint0 Configuration                                                                                  */
63 /*----------------------------------------------------------------------------------------------------------*/
64 #define _EP0_CFG_EPEN       (1UL)
65 #define _EP0STADR           (HT_USB_SRAM_BASE + 0x8)
66 #define _EP0INTADR          (_EP0STADR)
67 #define _EP0OUTTADR         (_EP0STADR + _EP0LEN)
68 #define _EP0_CFG            ((_EP0_CFG_EPEN << 31) | \
69                              (_EP0LEN       << 10) | \
70                              (_EP0STADR & EPBUFA_MASK))
71 #define _EP0LEN_T           (_EP0LEN * 2)
72 
73 /*----------------------------------------------------------------------------------------------------------*/
74 /* Endpoint1 Configuration                                                                                  */
75 /*----------------------------------------------------------------------------------------------------------*/
76 #define _EP1STADR           (_EP0STADR + (_EP0LEN * 2))
77 
78 #if (_EP1_ENABLE == 1)
79   #define _EP1LEN           (_EP1LEN_TMP)
80 #else
81   #define _EP1LEN           (0)
82 #endif
83 
84 #if (_EP1_CFG_EPEN_TMP == 1)
85   #define _EP1_CFG_EPEN     (1UL)
86 #else
87   #define _EP1_CFG_EPEN     (0UL)
88 #endif
89 
90 #define _EP1_CFG            ((_EP1_CFG_EPEN  << 31) | \
91                              (_EP1_CFG_EPDIR << 28) | \
92                              (_EP1_CFG_EPADR << 24) | \
93                              (_EP1LEN        << 10) | \
94                              (_EP1STADR & EPBUFA_MASK))
95 
96 /*----------------------------------------------------------------------------------------------------------*/
97 /* Endpoint2 Configuration                                                                                  */
98 /*----------------------------------------------------------------------------------------------------------*/
99 #define _EP2STADR           (_EP1STADR + _EP1LEN)
100 
101 #if (_EP2_ENABLE == 1)
102   #define _EP2LEN           (_EP2LEN_TMP)
103 #else
104   #define _EP2LEN           (0)
105 #endif
106 
107 #if (_EP2_CFG_EPEN_TMP == 1)
108   #define _EP2_CFG_EPEN     (1UL)
109 #else
110   #define _EP2_CFG_EPEN     (0UL)
111 #endif
112 
113 #define _EP2_CFG            ((_EP2_CFG_EPEN  << 31) | \
114                              (_EP2_CFG_EPDIR << 28) | \
115                              (_EP2_CFG_EPADR << 24) | \
116                              (_EP2LEN        << 10) | \
117                              (_EP2STADR & EPBUFA_MASK))
118 
119 /*----------------------------------------------------------------------------------------------------------*/
120 /* Endpoint3 Configuration                                                                                  */
121 /*----------------------------------------------------------------------------------------------------------*/
122 #define _EP3STADR           (_EP2STADR + _EP2LEN)
123 
124 #if (_EP3_ENABLE == 1)
125   #define _EP3LEN           (_EP3LEN_TMP)
126 #else
127   #define _EP3LEN           (0)
128 #endif
129 
130 #if (_EP3_CFG_EPEN_TMP == 1)
131   #define _EP3_CFG_EPEN     (1UL)
132 #else
133   #define _EP3_CFG_EPEN     (0UL)
134 #endif
135 
136 #define _EP3_CFG            ((_EP3_CFG_EPEN  << 31) | \
137                              (_EP3_CFG_EPDIR << 28) | \
138                              (_EP3_CFG_EPADR << 24) | \
139                              (_EP3LEN        << 10) | \
140                              (_EP3STADR & EPBUFA_MASK))
141 
142 /*----------------------------------------------------------------------------------------------------------*/
143 /* Endpoint4 Configuration                                                                                  */
144 /*----------------------------------------------------------------------------------------------------------*/
145 #define _EP4STADR           (_EP3STADR + _EP3LEN)
146 
147 #if (_EP4_ENABLE == 1)
148   #define _EP4LEN           (_EP4LEN_TMP)
149   #define _EP4LEN_T         (_EP4LEN_TMP * (_EP4_CFG_SDBS + 1))
150 #else
151   #define _EP4LEN           (0)
152   #define _EP4LEN_T         (0)
153 #endif
154 #if (_EP4_TYPR == EP_TYPE_ISO)
155   #define _EP4_CFG_EPTYPE   (1)
156 #else
157   #define _EP4_CFG_EPTYPE   (0)
158 #endif
159 
160 #if (_EP4_CFG_EPEN_TMP == 1)
161   #define _EP4_CFG_EPEN     (1UL)
162 #else
163   #define _EP4_CFG_EPEN     (0UL)
164 #endif
165 
166 #define _EP4_CFG            ((_EP4_CFG_EPEN   << 31) | \
167                              (_EP4_CFG_EPTYPE << 29) | \
168                              (_EP4_CFG_EPDIR  << 28) | \
169                              (_EP4_CFG_EPADR  << 24) | \
170                              (_EP4_CFG_SDBS   << 23) | \
171                              (_EP4LEN         << 10) | \
172                              (_EP4STADR & EPBUFA_MASK))
173 
174 /*----------------------------------------------------------------------------------------------------------*/
175 /* Endpoint5 Configuration                                                                                  */
176 /*----------------------------------------------------------------------------------------------------------*/
177 #define _EP5STADR           (_EP4STADR + _EP4LEN_T)
178 
179 #if (_EP5_ENABLE == 1)
180   #define _EP5LEN           (_EP5LEN_TMP)
181   #define _EP5LEN_T         (_EP5LEN_TMP * (_EP5_CFG_SDBS + 1))
182 #else
183   #define _EP5LEN           (0)
184   #define _EP5LEN_T         (0)
185 #endif
186 #if (_EP5_TYPR == EP_TYPE_ISO)
187   #define _EP5_CFG_EPTYPE   (1)
188 #else
189   #define _EP5_CFG_EPTYPE   (0)
190 #endif
191 
192 #if (_EP5_CFG_EPEN_TMP == 1)
193   #define _EP5_CFG_EPEN     (1UL)
194 #else
195   #define _EP5_CFG_EPEN     (0UL)
196 #endif
197 
198 #define _EP5_CFG            ((_EP5_CFG_EPEN   << 31) | \
199                              (_EP5_CFG_EPTYPE << 29) | \
200                              (_EP5_CFG_EPDIR  << 28) | \
201                              (_EP5_CFG_EPADR  << 24) | \
202                              (_EP5_CFG_SDBS   << 23) | \
203                              (_EP5LEN         << 10) | \
204                              (_EP5STADR & EPBUFA_MASK))
205 
206 /*----------------------------------------------------------------------------------------------------------*/
207 /* Endpoint6 Configuration                                                                                  */
208 /*----------------------------------------------------------------------------------------------------------*/
209 #define _EP6STADR           (_EP5STADR + _EP5LEN_T)
210 
211 #if (_EP6_ENABLE == 1)
212   #define _EP6LEN           (_EP6LEN_TMP)
213   #define _EP6LEN_T         (_EP6LEN_TMP * (_EP6_CFG_SDBS + 1))
214 #else
215   #define _EP6LEN           (0)
216   #define _EP6LEN_T         (0)
217 #endif
218 #if (_EP6_TYPR == EP_TYPE_ISO)
219   #define _EP6_CFG_EPTYPE   (1)
220 #else
221   #define _EP6_CFG_EPTYPE   (0)
222 #endif
223 
224 #if (_EP6_CFG_EPEN_TMP == 1)
225   #define _EP6_CFG_EPEN     (1UL)
226 #else
227   #define _EP6_CFG_EPEN     (0UL)
228 #endif
229 
230 #define _EP6_CFG            ((_EP6_CFG_EPEN   << 31) | \
231                              (_EP6_CFG_EPTYPE << 29) | \
232                              (_EP6_CFG_EPDIR  << 28) | \
233                              (_EP6_CFG_EPADR  << 24) | \
234                              (_EP6_CFG_SDBS   << 23) | \
235                              (_EP6LEN         << 10) | \
236                              (_EP6STADR & EPBUFA_MASK))
237 
238 /*----------------------------------------------------------------------------------------------------------*/
239 /* Endpoint7 Configuration                                                                                  */
240 /*----------------------------------------------------------------------------------------------------------*/
241 #define _EP7STADR           (_EP6STADR + _EP6LEN_T)
242 
243 #if (_EP7_ENABLE == 1)
244   #define _EP7LEN           (_EP7LEN_TMP)
245   #define _EP7LEN_T         (_EP7LEN_TMP * (_EP7_CFG_SDBS + 1))
246 #else
247   #define _EP7LEN           (0)
248   #define _EP7LEN_T         (0)
249 #endif
250 #if (_EP7_TYPR == EP_TYPE_ISO)
251   #define _EP7_CFG_EPTYPE   (1)
252 #else
253   #define _EP7_CFG_EPTYPE   (0)
254 #endif
255 
256 #if (_EP7_CFG_EPEN_TMP == 1)
257   #define _EP7_CFG_EPEN     (1UL)
258 #else
259   #define _EP7_CFG_EPEN     (0UL)
260 #endif
261 
262 #define _EP7_CFG            ((_EP7_CFG_EPEN   << 31) | \
263                              (_EP7_CFG_EPTYPE << 29) | \
264                              (_EP7_CFG_EPDIR  << 28) | \
265                              (_EP7_CFG_EPADR  << 24) | \
266                              (_EP7_CFG_SDBS   << 23) | \
267                              (_EP7LEN         << 10) | \
268                              (_EP7STADR & EPBUFA_MASK))
269 
270 /*----------------------------------------------------------------------------------------------------------*/
271 /* Endpoint8 Configuration                                                                                  */
272 /*----------------------------------------------------------------------------------------------------------*/
273 #define _EP8STADR           (_EP7STADR + _EP7LEN_T)
274 
275 #if (_EP8_ENABLE == 1)
276   #define _EP8LEN           (_EP8LEN_TMP)
277 #else
278   #define _EP8LEN           (0)
279 #endif
280 
281 #if (_EP8_CFG_EPEN_TMP == 1)
282   #define _EP8_CFG_EPEN     (1UL)
283 #else
284   #define _EP8_CFG_EPEN     (0UL)
285 #endif
286 
287 #define _EP8_CFG            ((_EP8_CFG_EPEN  << 31) | \
288                              (_EP8_CFG_EPDIR << 28) | \
289                              (_EP8_CFG_EPADR << 24) | \
290                              (_EP8LEN        << 10) | \
291                              (_EP8STADR & EPBUFA_MASK))
292 
293 
294 /*----------------------------------------------------------------------------------------------------------*/
295 /* Endpoint9 Configuration                                                                                  */
296 /*----------------------------------------------------------------------------------------------------------*/
297 #define _EP9STADR           (_EP8STADR + _EP8LEN)
298 
299 #if (_EP9_ENABLE == 1)
300   #define _EP9LEN           (_EP9LEN_TMP)
301 #else
302   #define _EP9LEN           (0)
303 #endif
304 
305 #if (_EP9_CFG_EPEN_TMP == 1)
306   #define _EP9_CFG_EPEN     (1UL)
307 #else
308   #define _EP9_CFG_EPEN     (0UL)
309 #endif
310 
311 #define _EP9_CFG            ((_EP9_CFG_EPEN  << 31) | \
312                              (_EP9_CFG_EPDIR << 28) | \
313                              (_EP9_CFG_EPADR << 24) | \
314                              (_EP9LEN        << 10) | \
315                              (_EP9STADR & EPBUFA_MASK))
316 
317 
318 /**
319   * @}
320   */
321 
322 /**
323   * @}
324   */
325 
326 #ifdef __cplusplus
327 }
328 #endif
329 
330 #endif
331