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