1 /*********************************************************************************************************//**
2  * @file    IP/Example/ht32f1xxxx_conf.h
3  * @version $Rev:: 2922         $
4  * @date    $Date:: 2023-06-07 #$
5  * @brief   Library configuration file.
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 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
28 
29 /* Define to prevent recursive inclusion -------------------------------------------------------------------*/
30 #ifndef __HT32F1XXXX_CONF_H
31 #define __HT32F1XXXX_CONF_H
32 
33 /* Exported constants --------------------------------------------------------------------------------------*/
34 
35 #define RETARGET_ITM        0
36 #define RETARGET_USB        1
37 #define RETARGET_SYSLOG     2
38 #define RETARGET_COM1       10
39 #define RETARGET_COM2       11
40 #define RETARGET_USART0     12
41 #define RETARGET_USART1     13
42 #define RETARGET_UART0      14
43 #define RETARGET_UART1      15
44 
45 
46 /* Retarget settings of the C standard I/O library functions (printf, scanf, getchar, ...etc.)              */
47 /*
48 //  <q> Enable Retarget
49 //  <o1> Retarget Port
50 //      <0=> ITM
51 //      <1=> USB Virtual COM
52 //      <2=> Syslog
53 //      <10=> COM1
54 //      <11=> COM2
55 //      <12=> USART0
56 //      <13=> USART1
57 //      <14=> UART0
58 //      <15=> UART1
59 //  <q2> Enable Auto Return
60 //       <i> Auto Return function adds "\r" before "\n" automatically when print message by Retarget.
61 */
62 #define _RETARGET            1
63 #define RETARGET_PORT        10
64 #define _AUTO_RETURN         0
65 
66 #ifndef AUTO_RETURN
67 #if (_AUTO_RETURN == 1)
68 #define AUTO_RETURN
69 #endif
70 #endif
71 
72 /* Enable Interrupt Mode for UxART Retarget
73 // <h> Retarget COM/UxART Setting
74 //  <o0> UxART Baudrate
75 //  <q1> Enable Interrupt Mode for UxART Tx Retarget
76 //  <q2> Define UxARTn_IRQHandler By Retarget (ht32_serial.c)
77 //    <i> Disable (RETARGET_DEFINE_HANDLER = 0) if application already have UxARTn_IRQHandler.
78 //    <i> RETARGET_UART_IRQHandler() shall be called by UxARTn_IRQHandler when disable.
79 //  <o3> Tx Buffer Length (in byte)
80 // </h>
81 */
82 #define RETARGET_UxART_BAUDRATE       115200
83 #define RETARGET_INT_MODE             0
84 #define RETARGET_DEFINE_HANDLER       1
85 #define RETARGET_INT_BUFFER_SIZE      64
86 
87 #if (_RETARGET == 1)
88 #if (RETARGET_PORT == RETARGET_ITM)
89 #elif (RETARGET_PORT == RETARGET_USB)
90   #define RETARGET_IS_USB
91 //  <h> Retarget USB Virtual COM Setting
92 //  <o0> Communication (Interrupt IN)
93 //      <1=> Endpoint 1
94 //      <2=> Endpoint 2
95 //      <3=> Endpoint 3
96 //      <4=> Endpoint 4
97 //      <5=> Endpoint 5
98 //      <6=> Endpoint 6
99 //      <7=> Endpoint 7
100 //  <o1> Data Rx (Bulk OUT)
101 //      <1=> Endpoint 1
102 //      <2=> Endpoint 2
103 //      <3=> Endpoint 3
104 //      <4=> Endpoint 4
105 //      <5=> Endpoint 5
106 //      <6=> Endpoint 6
107 //      <7=> Endpoint 7
108 //  <o2> Data Tx (Bulk IN)
109 //      <1=> Endpoint 1
110 //      <2=> Endpoint 2
111 //      <3=> Endpoint 3
112 //      <4=> Endpoint 4
113 //      <5=> Endpoint 5
114 //      <6=> Endpoint 6
115 //      <7=> Endpoint 7
116 //  <o3> Communication Endpoint Buffer Length (in byte) <4-64:4>
117 //  <o4> Data Rx Endpoint Buffer Length (in byte) <4-64:4>
118 //  <o5> Data Tx Endpoint Buffer Length (in byte) <4-64:4>
119 //  <o6> Rx Buffer Length (in byte) <64-1024:4>
120 //  <o7> Tx Buffer Length (in byte) <1-63:1>
121 //    <i> Please use "SERIAL_Flush()" to sent out the buffer data immediately when Tx Buffer Length > 1.
122 //  <o8> USB Tx Mode (BULK IN)
123 //      <0=> Block Mode (Wait until both USB and terminal software are ready)
124 //      <1=> Non-Block Mode (Drop data if USB or terminal software is not ready)
125 //  <q9> Enable HSI Auto Trim By USB Function
126 //    <i> Need turn on if the USB clock source is from HSI (PLL USBPLL clock Source).
127   #define RETARGET_CTRL_EPT      (5)
128   #define RETARGET_RX_EPT        (6)
129   #define RETARGET_TX_EPT        (7)
130   #define RETARGET_CTRL_EPTLEN   (8)
131   #define RETARGET_RX_EPTLEN     (64)
132   #define RETARGET_TX_EPTLEN     (64)
133   #define RETARGET_BUFFER_SIZE   (64)
134   #define RETARGET_TXBUFFER_SIZE (1) // Use "SERIAL_Flush()" to sent out the buffer data immediately when Tx Buffer Length > 1.
135   #define RETARGET_USB_MODE      (0)
136   #define RETARGET_HSI_ATM       (1)
137 // </h>
138 #elif (RETARGET_PORT == RETARGET_COM1)
139   #define RETARGET_COM_PORT         COM1
140   #define RETARGET_USART_PORT       COM1_PORT
141   #define RETARGET_UART_IRQn        COM1_IRQn
142   #define RETARGET_UART_IRQHandler  COM1_IRQHandler
143   #define RETARGET_IS_UART
144 #elif (RETARGET_PORT == RETARGET_COM2)
145   #define RETARGET_COM_PORT         COM2
146   #define RETARGET_USART_PORT       COM2_PORT
147   #define RETARGET_UART_IRQn        COM2_IRQn
148   #define RETARGET_UART_IRQHandler  COM2_IRQHandler
149   #define RETARGET_IS_UART
150 #elif (RETARGET_PORT == RETARGET_USART0)
151   #define RETARGET_UxART_IPN        USART0
152   #define RETARGET_USART_PORT       STRCAT2(HT_, RETARGET_UxART_IPN)
153   #define RETARGET_UART_IRQn        STRCAT2(RETARGET_UxART_IPN, _IRQn)
154   #define RETARGET_UART_IRQHandler  STRCAT2(RETARGET_UxART_IPN, _IRQHandler)
155   #define RETARGET_IS_UART
156 #elif (RETARGET_PORT == RETARGET_USART1)
157   #define RETARGET_UxART_IPN        USART1
158   #define RETARGET_USART_PORT       STRCAT2(HT_, RETARGET_UxART_IPN)
159   #define RETARGET_UART_IRQn        STRCAT2(RETARGET_UxART_IPN, _IRQn)
160   #define RETARGET_UART_IRQHandler  STRCAT2(RETARGET_UxART_IPN, _IRQHandler)
161   #define RETARGET_IS_UART
162 #elif (RETARGET_PORT == RETARGET_UART0)
163   #define RETARGET_UxART_IPN        UART0
164   #define RETARGET_USART_PORT       STRCAT2(HT_, RETARGET_UxART_IPN)
165   #define RETARGET_UART_IRQn        STRCAT2(RETARGET_UxART_IPN, _IRQn)
166   #define RETARGET_UART_IRQHandler  STRCAT2(RETARGET_UxART_IPN, _IRQHandler)
167   #define RETARGET_IS_UART
168 #elif (RETARGET_PORT == RETARGET_UART1)
169   #define RETARGET_UxART_IPN        UART1
170   #define RETARGET_USART_PORT       STRCAT2(HT_, RETARGET_UxART_IPN)
171   #define RETARGET_UART_IRQn        STRCAT2(RETARGET_UxART_IPN, _IRQn)
172   #define RETARGET_UART_IRQHandler  STRCAT2(RETARGET_UxART_IPN, _IRQHandler)
173   #define RETARGET_IS_UART
174 #endif
175   extern void RETARGET_Configuration(void);
176 #else
177   #define RETARGET_Configuration(...)
178   #undef printf
179   #undef getchar
180   #define printf(...)
181   #define getchar()  (0)
182 #endif
183 
184 #if (RETARGET_DEFINE_HANDLER == 0)
185 #undef RETARGET_UART_IRQHandler
186 #endif
187 
188 /*
189 //<e0> Enable HT32 Time Function
190 //  <i> Provide "Time_GetTick()" and "Time_Dealy()" functions.
191 
192 //  <o1> Timer Selection
193 //      <0=> BFTM0
194 //      <1=> BFTM1
195 //      <2=> SCTM0
196 //      <3=> SCTM1
197 //      <4=> SCTM2
198 //      <5=> SCTM3
199 //      <6=> PWM0
200 //      <7=> PWM1
201 //      <8=> PWM2
202 //      <9=> GPTM0
203 //      <10=> GPTM1
204 //      <11=> MCTM0
205 
206 //  <h> Timer Clock Setting
207 //  </h>
208 //    <i> Timer Clock = (Core Clock) / (APB Peripheral Clock Prescaler)
209 //    <i> HTCFG_TIME_CLKSRC = _HTCFG_TIME_CORECLK / (2^HTCFG_TIME_PCLK_DIV)
210 //    <i> _HTCFG_TIME_CORECLK = LIBCFG_MAX_SPEED or HTCFG_TIME_CLK_MANUAL (selected by HTCFG_TIME_CLKSEL)
211 
212 //  <o2> -- Core Clock Setting (CK_AHB)
213 //    <i> HTCFG_TIME_CLKSEL
214 //    <i> 0 = Default Maximum (LIBCFG_MAX_SPEED)
215 //    <i> 1 = Manual Input (HTCFG_TIME_CLK_MANUAL)
216 //       <0=> Default Maximum (LIBCFG_MAX_SPEED)
217 //       <1=> Manual Input (HTCFG_TIME_CLK_MANUAL)
218 
219 //  <o3> -- Core Clock Manual Input (Hz)
220 //    <i> HTCFG_TIME_CLK_MANUAL
221 //    <i> Only meaningful when Core Clock Setting (HTCFG_TIME_CLKSEL) = Manual Input (1)
222 
223 //  <o4> -- APB Peripheral Clock Prescaler
224 //    <i> HTCFG_TIME_PCLK_DIV
225 //       <0=> /1
226 //       <1=> /2
227 //       <2=> /4
228 //       <3=> /8
229 
230 //  <o5> Time Tick (Hz, not applicable for BFTM) <1-1000000:100>
231 //    <i> Not applicable for BFTM, fixed TICKHZ to HTCFG_TIME_CLKSRC for BFTM.
232 */
233 #if (0) // Enable HT32 Time Function
234 #define HTCFG_TIME_IPSEL                          (0)
235 #define HTCFG_TIME_CLKSEL                         (0)         // 0 = Default Maximum (LIBCFG_MAX_SPEED), 1 = Manual Input (HTCFG_TIME_CLKSRC)
236 #define HTCFG_TIME_CLK_MANUAL                     (20000000)  // Only meaningful when HTCFG_TIME_CLKSEL = 1 (Manual Input)
237 #define HTCFG_TIME_PCLK_DIV                       (0)         // 0 ~ 3. (/1, /2, /4, /8)
238 #define HTCFG_TIME_TICKHZ                         (1000)      // Hz, not applicable for BFTM, fixed TICKHZ to HTCFG_TIME_CLKSRC for BFTM
239 #define HTCFG_TIME_MULTIPLE                       (1)         // MUST be 1, 2, 4, 8. TICK = COUNT / MULTIPLE. Not applicable for BFTM.
240 /*
241 
242   Timer Clock = (Core Clock) / (APB Peripheral Clock Prescaler)
243   HTCFG_TIME_CLKSRC = (_HTCFG_TIME_CORECLK) / (2^HTCFG_TIME_PCLK_DIV)
244   where _HTCFG_TIME_CORECLK can be LIBCFG_MAX_SPEED or HTCFG_TIME_CLK_MANUAL (selected by HTCFG_TIME_CLKSEL)
245 
246   Tick Range: 0 ~ 2^32 / HTCFG_TIME_TICKHZ (maximum tick time)
247   Interrupt Time: _HTCFG_TIME_OVERFLOW_VALUE / (HTCFG_TIME_TICKHZ * HTCFG_TIME_MULTIPLE) Second
248   (Interrupt Time is not applicable for BFTM)
249 
250   Example: 32-bit BFTM with 48 MHz Timer Clock
251     HTCFG_TIME_TICKHZ = HTCFG_TIME_CLKSRC = 48000000
252     Tick Range: 0 ~ 2^32 / 48000000 = 0 ~ 89.478485 Second (maximum tick time, return to 0 every 89.478485 Second)
253     BFTM do not use interrupt
254 
255   Example: 16-bit GPTM with 1 ms tick
256     HTCFG_TIME_TICKHZ = 1000 (Hz)
257     HTCFG_TIME_MULTIPLE = 1 (1 Timer Count = 1 Tick)
258     Tick Range: 0 ~ 2^32 / 1000 = 0 ~ 4294967 Second = 0 ~ 49.7 Day (maximum tick time, return to 0 every 49.7 Day)
259     Interrupt Time: 65536 / (1000 * 1) = 65.536 Second (Trigger interrupt every 65.536 Second)
260 */
261 #endif
262 /*
263 //</e>
264 */
265 
266 /* !!! NOTICE !!!
267  * How to adjust the value of High Speed External oscillator (HSE)?
268    The default value of HSE is define by "HSE_VALUE" in "ht32fxxxxx_nn.h".
269    If your board uses a different HSE speed, please add a new compiler preprocessor
270    C define, "HSE_VALUE=n000000" ("n" represents n MHz) in the toolchain/IDE,
271    or edit the "HSE_VALUE" in the "ht32f1xxxx_conf.h" file (this file).
272 */
273 /*
274 //<e0> Enable User Define HSE Value
275 //  <i> Enable user define HSE value to overwrite default "HSE_VALUE" define in "ht32fxxxxx_nn.h".
276 //  <o1> HSE Value (Hz)
277 */
278 #if (0)
279 #define HSE_VALUE                 16000000
280 #endif
281 /*
282 //</e>
283 */
284 
285 /*
286 //<q> Enable CKOUT Function
287 */
288 #define ENABLE_CKOUT              0
289 
290 
291 /* The DEBUG definition to enter debug mode for library                                                     */
292 /*
293 //<q> Library Debug Mode
294 */
295 #define HT32_LIB_DEBUG      0
296 
297 
298 /* Enable/disable the specific peripheral inclusion                                                         */
299 
300 //  <h> Library Inclusion Configuration
301 /* ADC -----------------------------------------------------------------------------------------------------*/
302 /*
303 //<q> ADC Library
304 */
305 #define _ADC          1
306 
307 /* AES -----------------------------------------------------------------------------------------------------*/
308 /*
309 //<q> AES Library
310 */
311 #define _AES          1
312 
313 /* BFTM ----------------------------------------------------------------------------------------------------*/
314 /*
315 //<q> BFTM Library
316 */
317 #define _BFTM         1
318 
319 /* Clock Control -------------------------------------------------------------------------------------------*/
320 /*
321 //<q> Clock Control Library
322 */
323 #define _CKCU         1
324 
325 /* Comparator/OPA ------------------------------------------------------------------------------------------*/
326 /*
327 //<q> Comparator/OPA Library
328 */
329 #define _CMP_OPA      1
330 
331 /* Comparator ----------------------------------------------------------------------------------------------*/
332 /*
333 //<q> Comparator Library
334 */
335 #define _CMP          1
336 
337 /* CRC -----------------------------------------------------------------------------------------------------*/
338 /*
339 //<q> CRC Library
340 */
341 #define _CRC          1
342 
343 /* CSIF ----------------------------------------------------------------------------------------------------*/
344 /*
345 //<q> CSIF Library
346 */
347 #define _CSIF         1
348 
349 /* EBI -----------------------------------------------------------------------------------------------------*/
350 /*
351 //<q> EBI Library
352 */
353 #define _EBI          1
354 
355 /* EXTI ----------------------------------------------------------------------------------------------------*/
356 /*
357 //<q> EXTI Library
358 */
359 #define _EXTI         1
360 
361 /* Flash ---------------------------------------------------------------------------------------------------*/
362 /*
363 //<q> Flash Library
364 */
365 #define _FLASH        1
366 
367 /* GPIO ----------------------------------------------------------------------------------------------------*/
368 /*
369 //<q> GPIO Library
370 */
371 #define _GPIO         1
372 
373 /* GPTM ----------------------------------------------------------------------------------------------------*/
374 /*
375 //<q> GPTM Library
376 */
377 #define _GPTM         1
378 
379 /* I2C -----------------------------------------------------------------------------------------------------*/
380 /*
381 //<q> I2C Library
382 */
383 #define _I2C          1
384 
385 /* I2S -----------------------------------------------------------------------------------------------------*/
386 /*
387 //<q> I2S Library
388 */
389 #define _I2S          1
390 
391 /* MCTM ----------------------------------------------------------------------------------------------------*/
392 /*
393 //<q> MCTM Library
394 */
395 #define _MCTM         1
396 
397 /* PDMA ----------------------------------------------------------------------------------------------------*/
398 /*
399 //<q> PDMA Library
400 */
401 #define _PDMA         1
402 
403 /* PWM -----------------------------------------------------------------------------------------------------*/
404 /*
405 //<q> PWM Library
406 */
407 #define _PWM          1
408 
409 /* PWRCU ---------------------------------------------------------------------------------------------------*/
410 /*
411 //<q> PWRCU Library
412 */
413 #define _PWRCU        1
414 
415 /* RSTCU ---------------------------------------------------------------------------------------------------*/
416 /*
417 //<q> RSTCU Library
418 */
419 #define _RSTCU        1
420 
421 /* RTC -----------------------------------------------------------------------------------------------------*/
422 /*
423 //<q> RTC Library
424 */
425 #define _RTC          1
426 
427 /* SCI -----------------------------------------------------------------------------------------------------*/
428 /*
429 //<q> SCI Library
430 */
431 #define _SCI          1
432 
433 /* SCTM ----------------------------------------------------------------------------------------------------*/
434 /*
435 //<q> SCTM Library
436 */
437 #define _SCTM         1
438 
439 /* SDIO ----------------------------------------------------------------------------------------------------*/
440 /*
441 //<q> SDIO Library
442 */
443 #define _SDIO         1
444 
445 /* SPI -----------------------------------------------------------------------------------------------------*/
446 /*
447 //<q> SPI Library
448 */
449 #define _SPI          1
450 
451 /* USART ---------------------------------------------------------------------------------------------------*/
452 /*
453 //<q0> USART/UART Library
454 */
455 #define _USART        1
456 
457 /* USBD ----------------------------------------------------------------------------------------------------*/
458 /*
459 //<q> USB Library
460 */
461 #define _USB          1
462 
463 /* WDT -----------------------------------------------------------------------------------------------------*/
464 /*
465 //<q> WDT Library
466 */
467 #define _WDT          1
468 
469 /* Misc ----------------------------------------------------------------------------------------------------*/
470 /*
471 //<q> Misc Library
472 */
473 #define _MISC         1
474 
475 /* Serial --------------------------------------------------------------------------------------------------*/
476 /*
477 //<q> Serial Library
478 */
479 #define _SERIAL       1
480 
481 /* Software Random Number ----------------------------------------------------------------------------------*/
482 /*
483 //<q> Software Random Number Library
484 */
485 #define _SWRAND       1
486 
487 
488 // </h>
489 
490 #endif
491